12 remaining issues in SQL conversion

pull/260/head
Rick Carlino 2016-09-01 12:48:20 -05:00
parent 8d5d2e4712
commit 5ee3891963
5 changed files with 13 additions and 16 deletions

View File

@ -1,7 +1,6 @@
module Api
class SchedulesController < Api::AbstractController
def index
binding.pry
render json: current_device.schedules
end

View File

@ -5,16 +5,17 @@ class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
:trackable, :validatable
# Lazy load a device into the account. Prevents weird edge cases, such as
# device === nil on first login.
# # 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)
# Device.where(id: self[:device]).first || Devices::Create.run!(user: self,
# uuid: SecureRandom.uuid,
# token: SecureRandom.hex)
super || Devices::Create.run!(user: self, uuid: SecureRandom.uuid, token: SecureRandom.hex)
end
def device_id
self[:device_id] || device.id
end
# def device_id
# self[:device_id] || device.id
# end
end

View File

@ -14,7 +14,7 @@ describe Api::RegimensController do
expect(response.status).to eq(200)
expect(old_count).to be > new_count
expect { regimen.reload }
.to(raise_error(Mongoid::Errors::DocumentNotFound))
.to(raise_error(ActiveRecord::RecordNotFound))
end
end
end

View File

@ -12,11 +12,8 @@ describe Api::SchedulesController do
sign_in user
# schedules = FactoryGirl
# .create_list(:schedule, 2, device_id: user.device.id)
FactoryGirl.create(:schedule, device: user.device)
# Schedule.create!(device: user.device)
$thatuser=user
schedules = FactoryGirl
.create_list(:schedule, 2, device_id: user.device.id)
schedule_ids = user.device.schedules
.map(&:id)

View File

@ -7,7 +7,7 @@ FactoryGirl.define do
after(:build) do |s|
s.next_time ||= s.calculate_next_occurence
s.sequence ||= create(:sequence)
s.device ||= s.sequence.device
# s.device ||= s.sequence.device
end
end
end