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

Added a function to age at date #1143

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

CloevVeller
Copy link

Added the function that checks the user's age at the time of the event in stead of at the time of enrollment

SilasPeters
SilasPeters previously approved these changes Dec 10, 2024
Copy link
Member

@SilasPeters SilasPeters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work at first sight! However, our pipeline complains. You should see the logs of the pipeline. Perhaps some checks failed or your code does not match our style requirements.

@SilasPeters SilasPeters linked an issue Dec 10, 2024 that may be closed by this pull request
Copy link
Member

@SilasPeters SilasPeters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would approve the changes, but I want to test this beforehand (dates and timezones might give unexpected results). I'm quite busy though, so don't expect me to have done this in a day or two. Perhaps someone else could adjust (or expand?) the test suite to test this edge case (and, especially, if no one else unjustly can sign up).

def underage_at?(event_date)
return true if birth_date.blank?

return ((18.years.ago + (event_date - Date.today)) < birth_date)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think birth_date + 18.years < event_date would read better (if that's still correct (code)).

Copy link
Member

@SilasPeters SilasPeters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not create a scenario where someone under the age of 18 could sign up for an activity with alcohol past their 18th birthday. Thus, I think this does not work.

Reproduction steps:

  • Log in as [email protected] and note your name.
  • Find an activity that is open to sign up for, note its id.
  • Log out and back in as [email protected], and make your user underage.
  • Set the activity's start and end date one day before the day your user would turn 18, and make the activity 18+.
  • Assert that, when loggin in as test, you cannot sign up.
  • Log back in as dev, and change the date to start a day later (on test's birthday).
  • Logging back in as test, assert that you can sign up. <=== this fails. Same thing if the activity is in 2030.

@SilasPeters
Copy link
Member

I now realise the error was 'Could not enroll' instead of 'Could not enrol, its for adults only'. Perhaps something weird is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Age check activities not based on age at time of event
2 participants