Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow qualification on the day of the deadline #9412

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/qualification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def self.load(json)

def can_register?(user, event_id)
return false if user.person.nil?
before_deadline_results = user.person.results.in_event(event_id).before(self.when_date)
before_deadline_results = user.person.results.in_event(event_id).on_or_before(self.when_date)
# Allow any competitor with a result to register when type == "ranking" or type == "anyResult".
# When type == "ranking", the results need to be manually cleared out later.
case self.wcif_type
Expand Down
32 changes: 30 additions & 2 deletions spec/lib/qualification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@
expect(qualification.can_register?(user, '333')).to be true
end

# User's qualifying result was achieved on the 2nd
it "requires end date before" do
# Result must be achieved by the 3rd - user qualifies because result achieved before whenDate
input = {
'resultType' => 'single',
'type' => 'attemptResult',
Expand All @@ -211,6 +213,7 @@
expect(qualification).to be_valid
expect(qualification.can_register?(user, '333')).to be true

# Result must be achieved by the 2nd - user qualifies because result achieved on whenDate
input = {
'resultType' => 'single',
'type' => 'attemptResult',
Expand All @@ -219,6 +222,17 @@
}
qualification = Qualification.load(input)
expect(qualification).to be_valid
expect(qualification.can_register?(user, '333')).to be true

# Result must be achieved by the 1st - user does not qualify because result achieved after whenDate
input = {
'resultType' => 'single',
'type' => 'attemptResult',
'whenDate' => '2021-03-01',
'level' => 1150,
}
qualification = Qualification.load(input)
expect(qualification).to be_valid
expect(qualification.can_register?(user, '333')).to be false
end
end
Expand Down Expand Up @@ -331,7 +345,9 @@
expect(qualification.can_register?(user, '333')).to be true
end

it "requires end date before" do
# User's qualifying result was achieved on the 2nd
it "supports achieving result on qualification date" do
# Result must be achieved by the 3rd - user qualifies because result achieved before whenDate
input = {
'resultType' => 'average',
'type' => 'attemptResult',
Expand All @@ -342,11 +358,23 @@
expect(qualification).to be_valid
expect(qualification.can_register?(user, '333oh')).to be true

# Result must be achieved by the 2nd - user qualifies because result achieved on whenDate
input = {
'resultType' => 'average',
'type' => 'attemptResult',
'whenDate' => '2021-03-02',
'level' => 2510,
'level' => 2500,
}
qualification = Qualification.load(input)
expect(qualification).to be_valid
expect(qualification.can_register?(user, '333oh')).to be true

# Result must be achieved by the 1st - user does not qualify because result achieved after whenDate
input = {
'resultType' => 'average',
'type' => 'attemptResult',
'whenDate' => '2021-03-01',
'level' => 2500,
}
qualification = Qualification.load(input)
expect(qualification).to be_valid
Expand Down
Loading