Fix build.

This commit is contained in:
Guo Xiang Tan 2016-11-08 17:00:44 +08:00
parent 3bc8b6c2f0
commit b18439a1e2
2 changed files with 7 additions and 1 deletions

View File

@ -344,7 +344,7 @@ class User < ActiveRecord::Base
end
def read_first_notification?
notifications.order(created_at: :asc).first.read
notifications.order(created_at: :asc).first&.read || false
end
def publish_notifications_state

View File

@ -1336,5 +1336,11 @@ describe User do
expect(user.read_first_notification?).to eq(true)
end
end
describe 'when user does not have any notifications' do
it 'should return the right value' do
expect(user.read_first_notification?).to eq(false)
end
end
end
end