Update method last_sync_timestamp from Last to First user

This commit is contained in:
Urban Rotnik 2019-04-25 09:18:26 +02:00
parent 2364c2653f
commit 62bc0520e9
2 changed files with 4 additions and 3 deletions

View file

@ -51,6 +51,6 @@ class SystemNotification < ApplicationRecord
SystemNotification
.order(last_time_changed_at: :desc)
.first&.last_time_changed_at&.to_i ||
User.order(created_at: :desc).first&.created_at&.to_i
User.order(created_at: :asc).first&.created_at&.to_i
end
end

View file

@ -56,11 +56,12 @@ describe SystemNotification do
end
context 'when there is no system notifications in db' do
it 'returns last user created_at' do
it 'returns first users created_at' do
create :user
create :user, created_at: Time.now + 5.seconds
expect(described_class.last_sync_timestamp)
.to be == User.last.created_at.to_i
.to be == User.first.created_at.to_i
end
end