From afb58bfbeb7ab0f57d2ccf5efcda277175877cc5 Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 22 Oct 2024 10:22:01 +0200 Subject: [PATCH] fixed determination of registration open to circumvent caching issue --- lib/competition_info.rb | 2 +- spec/factories/competition_factory.rb | 3 ++- spec/lib/competition_info_spec.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/competition_info.rb b/lib/competition_info.rb index 90a5e3ad..47b944f0 100644 --- a/lib/competition_info.rb +++ b/lib/competition_info.rb @@ -45,7 +45,7 @@ def guest_limit end def registration_open? - @competition_json['registration_currently_open?'] + @competition_json['registration_open'] <= Time.now && @competition_json['registration_close'] > Time.now end def using_wca_payment? diff --git a/spec/factories/competition_factory.rb b/spec/factories/competition_factory.rb index 298cefa4..a16bda02 100644 --- a/spec/factories/competition_factory.rb +++ b/spec/factories/competition_factory.rb @@ -5,7 +5,6 @@ FactoryBot.define do factory :competition, class: Hash do events { ['333', '222', '444', '555', '666', '777', '333bf', '333oh', 'clock', 'minx', 'pyram', 'skewb', 'sq1', '444bf', '555bf', '333mbf'] } - registration_currently_open? { true } id { 'CubingZANationalChampionship2023' } name { 'CubingZA National Championship 2023' } event_ids { events } @@ -118,6 +117,8 @@ end trait :closed do + registration_open { '2023-05-05T04:00:00.000Z' } + registration_close { 1.week.ago.iso8601 } registration_currently_open? { false } event_change_deadline_date { '2022-06-14T00:00:00.000Z' } end diff --git a/spec/lib/competition_info_spec.rb b/spec/lib/competition_info_spec.rb index 9b50fcff..1544da68 100644 --- a/spec/lib/competition_info_spec.rb +++ b/spec/lib/competition_info_spec.rb @@ -21,7 +21,7 @@ it 'false when closed' do # Instantiate a CompetitionInfo object with the sample data - competition_json = FactoryBot.build(:competition, registration_currently_open?: false) + competition_json = FactoryBot.build(:competition, :closed) competition_info = CompetitionInfo.new(competition_json) # Call the method being tested