[WIP][UNSTABLE] Re-added Devise. Next: steps and commands

pull/260/head
Rick Carlino 2016-08-28 16:03:44 -05:00
parent 5727dec084
commit b61931e083
4 changed files with 27 additions and 55 deletions

View File

@ -3,15 +3,20 @@ class Sequence < ActiveRecord::Base
belongs_to :schedule
belongs_to :device
belongs_to :regimen, class_name: "Regimen"
embeds_many :steps
has_many :steps
has_many :schedules, dependent: :destroy
has_many :regimen_items
field :name
validates :name, presence: true
# allowable label colors for the frontend.
COLORS = %w(blue green yellow orange purple pink gray red)
field :color, type: String, default: -> { COLORS.sample }
validates :name, presence: true
validates_inclusion_of :color, in: COLORS
# http://stackoverflow.com/a/5127684/1064917
after_initialize :init
def init
self.color ||= COLORS.sample
end
end

View File

@ -2,37 +2,7 @@
class User < ActiveRecord::Base
belongs_to :device, dependent: :destroy
# field :name, type: String
# validates_uniqueness_of :name
# validates_presence_of :name
# field :email, type: String, default: ""
# validates_uniqueness_of :email
# # BEGIN DEVISE CRAP ==========================================================
# devise :database_authenticatable, :registerable, :recoverable, :rememberable,
# :trackable, :validatable #, :omniauthable
# field :encrypted_password, type: String, default: ""
# field :reset_password_token, type: String
# field :reset_password_sent_at, type: Time
# field :remember_created_at, type: Time
# field :sign_in_count, type: Integer, default: 0
# field :current_sign_in_at, type: Time
# field :last_sign_in_at, type: Time
# field :current_sign_in_ip, type: String
# field :last_sign_in_ip, type: String
# # END DEVISE CRAP ============================================================
# # Lazy load a device into the account. Prevents weird edge cases, such as
# # device === nil on first login.
# def device
# Device.where(_id: self[:device]).first || Devices::Create.run!(user: self,
# uuid: SecureRandom.uuid,
# token: SecureRandom.hex)
# end
# def device_id
# self[:device_id] || device.id
# end
validates_uniqueness_of :email
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
:trackable, :validatable
end

View File

@ -75,19 +75,21 @@ class CreateEverything < ActiveRecord::Migration
t.string :device_id
t.string :name
t.string :email
# # Devise crap:
t.string :encrypted_password
t.string :reset_password_token
t.string :reset_password_sent_at
t.string :remember_created_at
t.string :sign_in_count
t.string :current_sign_in_at
t.string :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
# # END DEVISE CRAP ============================================================
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
t.string :reset_password_token
t.datetime :reset_password_sent_at
t.datetime :remember_created_at
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
t.timestamps null: false
end
add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
end

View File

@ -1,5 +0,0 @@
require 'rails_helper'
RSpec.describe Wow, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end