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

Avoid depending on ActiveSupport #818

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented Dec 11, 2020

In #817 we ran into an issue relating to ActiveSupport not being loaded when updating to Rails 6.1.0. We only use it for some trivial time-related helpers – I think we can drop it completely.

@andyw8 andyw8 marked this pull request as ready for review December 11, 2020 22:02
@andyw8 andyw8 requested a review from a team as a code owner December 11, 2020 22:02
Copy link
Contributor

@paulomarg paulomarg left a comment

Choose a reason for hiding this comment

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

LGTM, I'm happy for my nitpick to be ignored.

@@ -373,7 +375,7 @@ def setup
end

test "raise error if timestamp is too old" do
params = { code: "any-code", timestamp: Time.now - 2.days }
params = { code: "any-code", timestamp: Time.now - 2 * SECONDS_IN_A_DAY }
Copy link
Contributor

Choose a reason for hiding this comment

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

Extremely nitpicky, but would it make sense to use Session.SECONDS_IN_A_DAY here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a couple of reasons why I usually avoid referencing a implementation's constants in the tests:

  • If the constant is wrong in the implementation, and the test references that, then you lose out on the 'double-entry bookkeeping' safeguard of writing a test.
  • If I choose to rename the constant, or move it somewhere else, the tests shouldn't break since the implementation hasn't changed.

@andyw8 andyw8 merged commit 72e2b6c into master Dec 14, 2020
@andyw8 andyw8 deleted the andyw8/avoid-depending-on-active-support branch December 14, 2020 14:32
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.

2 participants