diff --git a/Gemfile.lock b/Gemfile.lock index 7c5723aac..21074057b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -527,7 +527,7 @@ GEM rubocop-performance (1.13.2) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.13.1) + rubocop-rails (2.13.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) diff --git a/app/models/calendar.rb b/app/models/calendar.rb index af804efa3..e8c140989 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -235,8 +235,8 @@ returns if event.rrule # loop till days - interval_frame_start = Date.parse("#{Time.zone.now - 1.year}-01-01") - interval_frame_end = Date.parse("#{Time.zone.now + 3.years}-12-31") + interval_frame_start = Date.parse("#{1.year.ago}-01-01") + interval_frame_end = Date.parse("#{3.years.from_now}-12-31") occurrences = event.occurrences_between(interval_frame_start, interval_frame_end) if occurrences.present? occurrences.each do |occurrence| @@ -247,8 +247,8 @@ returns end end end - next if event.dtstart < Time.zone.now - 1.year - next if event.dtstart > Time.zone.now + 3.years + next if event.dtstart < 1.year.ago + next if event.dtstart > 3.years.from_now result = Calendar.day_and_comment_by_event(event, event.dtstart) next if !result diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb index 2b7b6de6a..4a8f91fc3 100644 --- a/app/models/online_notification.rb +++ b/app/models/online_notification.rb @@ -225,7 +225,7 @@ with dedicated times =end - def self.cleanup(max_age = Time.zone.now - 9.months, max_own_seen = 10.minutes.ago, max_auto_seen = 8.hours.ago) + def self.cleanup(max_age = 9.months.ago, max_own_seen = 10.minutes.ago, max_auto_seen = 8.hours.ago) OnlineNotification.where('created_at < ?', max_age).delete_all OnlineNotification.where('seen = ? AND updated_at < ?', true, max_own_seen).each do |notification| diff --git a/test/unit/online_notifiaction_test.rb b/test/unit/online_notifiaction_test.rb index f4faa8031..69f884f0f 100644 --- a/test/unit/online_notifiaction_test.rb +++ b/test/unit/online_notifiaction_test.rb @@ -560,8 +560,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase user_id: @agent_user1.id, created_by_id: 1, updated_by_id: 1, - created_at: Time.zone.now - 10.months, - updated_at: Time.zone.now - 10.months, + created_at: 10.months.ago, + updated_at: 10.months.ago, ) online_notification2 = OnlineNotification.add( type: 'create', @@ -571,8 +571,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase user_id: @agent_user1.id, created_by_id: 1, updated_by_id: 1, - created_at: Time.zone.now - 10.months, - updated_at: Time.zone.now - 10.months, + created_at: 10.months.ago, + updated_at: 10.months.ago, ) online_notification3 = OnlineNotification.add( type: 'create', @@ -652,8 +652,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase user_id: @agent_user1.id, created_by_id: 1, updated_by_id: 1, - created_at: Time.zone.now - 10.months, - updated_at: Time.zone.now - 10.months, + created_at: 10.months.ago, + updated_at: 10.months.ago, ) end assert_raises(ActiveRecord::RecordNotFound) do @@ -665,8 +665,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase user_id: @agent_user1.id, created_by_id: 1, updated_by_id: 1, - created_at: Time.zone.now - 10.months, - updated_at: Time.zone.now - 10.months, + created_at: 10.months.ago, + updated_at: 10.months.ago, ) end end