Skip to content

Commit

Permalink
fixed determination of registration open to circumvent caching issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dunkOnIT committed Oct 22, 2024
1 parent 83d0d59 commit afb58bf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/competition_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
3 changes: 2 additions & 1 deletion spec/factories/competition_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/competition_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit afb58bf

Please sign in to comment.