Browse Source

CLDC-4325: Fix duplicate logs controller spec

also introduce a new helper for a dynamic way of setting year
pull/3250/head
samyou-softwire 2 weeks ago
parent
commit
50161119c6
  1. 13
      app/helpers/collection_time_helper.rb
  2. 1111
      spec/requests/duplicate_logs_controller_spec.rb

13
app/helpers/collection_time_helper.rb

@ -94,4 +94,17 @@ module CollectionTimeHelper
available_dates = (start_date..end_date).to_a - [date.to_date]
available_dates.empty? ? nil : available_dates.sample
end
# will time travel forwards only if needed.
# useful for writing future tests that will also test the current time if it can.
# stops tests being frozen on a specific year.
def collection_start_date_for_year_or_later(year)
Timecop.return do
if current_collection_start_year < year
collection_start_date_for_year(year)
else
current_collection_start_date
end
end
end
end

1111
spec/requests/duplicate_logs_controller_spec.rb

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save