Skip to content

Fix learning_hour test for date that is not in the future#6865

Open
alanparmenter wants to merge 1 commit intorubyforgood:mainfrom
alanparmenter:fix/learning-hour-test
Open

Fix learning_hour test for date that is not in the future#6865
alanparmenter wants to merge 1 commit intorubyforgood:mainfrom
alanparmenter:fix/learning-hour-test

Conversation

@alanparmenter
Copy link
Copy Markdown
Contributor

What github issue is this PR for, if any?

No Issue. Small fix.

What changed, and why?

Pass a datetime, not a String, for comparison in occurred_at_not_in_future. String formatting with strftime was inappropriate for testing this function.

def occurred_at_not_in_future
return false if !occurred_at
if occurred_at > Date.today
errors.add(:date, "cannot be in the future")
end
end

How is this tested? (please write rspec and jest tests!) 💖💪

bundle exec rspec ./spec/models/learning_hour_spec.rb

Screenshots please :)

Before:
Screenshot 2026-04-19 at 01 11 27

After:
Screenshot 2026-04-19 at 01 09 19

Screenshot 2026-04-19 at 01 52 51 (2)

Feelings gif (optional)

Mr Bean time

Pass a datetime, not a String, for comparison in occurred_at_not_in_future.
@github-actions github-actions bot added ruby Pull requests that update Ruby code Tests! 🎉💖👏 labels Apr 19, 2026
@alanparmenter
Copy link
Copy Markdown
Contributor Author

More relevant screenshots:

Screenshot 2026-04-19 at 02 42 44 (2)
Screenshot 2026-04-19 at 02 42 24 (2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code Tests! 🎉💖👏

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant