Merge pull request #862 from ChrisBr/ichain
Fixes for production errors
This commit is contained in:
commit
62bc035e53
3 changed files with 18 additions and 2 deletions
|
|
@ -41,7 +41,11 @@ class Comment < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :find_since_last_login, lambda { |user|
|
scope :find_since_last_login, lambda { |user|
|
||||||
where(created_at: (user.last_sign_in_at..Time.now)).order(created_at: :desc)
|
if user.last_sign_in_at
|
||||||
|
where(created_at: (user.last_sign_in_at..Time.now)).order(created_at: :desc)
|
||||||
|
else
|
||||||
|
none
|
||||||
|
end
|
||||||
}
|
}
|
||||||
# Helper class method to look up a commentable object
|
# Helper class method to look up a commentable object
|
||||||
# given the commentable class name and id
|
# given the commentable class name and id
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,9 @@ class User < ActiveRecord::Base
|
||||||
raise UserDisabled if user && user.is_disabled
|
raise UserDisabled if user && user.is_disabled
|
||||||
|
|
||||||
if user
|
if user
|
||||||
user.update_attributes(email: attributes[:email])
|
user.update_attributes(email: attributes[:email],
|
||||||
|
last_sign_in_at: user.current_sign_in_at,
|
||||||
|
current_sign_in_at: Time.current)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
user = create!(username: username, email: attributes[:email])
|
user = create!(username: username, email: attributes[:email])
|
||||||
|
|
|
||||||
10
spec/models/comment_spec.rb
Normal file
10
spec/models/comment_spec.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Commercial do
|
||||||
|
|
||||||
|
describe '.find_since_last_login' do
|
||||||
|
it 'returns none if last_sign_in_at is nil' do
|
||||||
|
expect(Comment.find_since_last_login(create(:user))).to eq(Comment.none)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue