From 62bc0520e9855e6306306705ec365003e4f58506 Mon Sep 17 00:00:00 2001 From: Urban Rotnik Date: Thu, 25 Apr 2019 09:18:26 +0200 Subject: [PATCH] Update method last_sync_timestamp from Last to First user --- app/models/system_notification.rb | 2 +- spec/models/system_notification_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/system_notification.rb b/app/models/system_notification.rb index 62ddfdcc4..310d5542f 100644 --- a/app/models/system_notification.rb +++ b/app/models/system_notification.rb @@ -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 diff --git a/spec/models/system_notification_spec.rb b/spec/models/system_notification_spec.rb index db03fadf4..cd72ee6f4 100644 --- a/spec/models/system_notification_spec.rb +++ b/spec/models/system_notification_spec.rb @@ -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