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

AccountControllerTest#test_blocked_ips — Tried setting file times more explicitly so that this test works #962

Merged
merged 3 commits into from
May 30, 2022

Conversation

pellaea
Copy link
Member

@pellaea pellaea commented May 29, 2022

on all systems.

@@ -827,12 +827,20 @@ def test_blocked_ips
get(:blocked_ips, add_bad: "garbage")
assert_flash_error

time = 1.minute.ago
File.utime(time.to_time, time.to_time, MO.blocked_ips_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use to_time on Date objects, because they know nothing about the time zone in use.

@@ -827,12 +827,20 @@ def test_blocked_ips
get(:blocked_ips, add_bad: "garbage")
assert_flash_error

time = 1.minute.ago
File.utime(time.to_time, time.to_time, MO.blocked_ips_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use to_time on Date objects, because they know nothing about the time zone in use.

assert_true(IpStats.blocked?(new_ip))

time = 1.minute.ago
File.utime(time.to_time, time.to_time, MO.blocked_ips_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use to_time on Date objects, because they know nothing about the time zone in use.

assert_true(IpStats.blocked?(new_ip))

time = 1.minute.ago
File.utime(time.to_time, time.to_time, MO.blocked_ips_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use to_time on Date objects, because they know nothing about the time zone in use.

@coveralls
Copy link
Collaborator

coveralls commented May 29, 2022

Coverage Status

Coverage remained the same at 93.065% when pulling 846dcc6 on try-to-fix-ipstats-test into 2910501 on master.

@nimmolo
Copy link
Contributor

nimmolo commented May 29, 2022

The rubocop Do not use to_time on Date objects, because they know nothing about the time zone in use. is a false positive and has been corrected in recent rubocop, according to this issue thread:
rubocop/rubocop-rails#288

@nimmolo
Copy link
Contributor

nimmolo commented May 29, 2022

This fixes it for me. THANK YOU @pellaea !

@nimmolo nimmolo changed the title Tried setting file times more explicitly so that this test works AccountControllerTest#test_blocked_ips — Tried setting file times more explicitly so that this test works May 30, 2022
@nimmolo
Copy link
Contributor

nimmolo commented May 30, 2022

Added a tweak to match expectation format of calls to get(action, **args)

get(:blocked_ips, params: { add_bad: new_ip })
get(:blocked_ips, params: { remove_bad: new_ip })

(Other calls to get in this controller test, and others, pass a params hash)

@nimmolo
Copy link
Contributor

nimmolo commented May 30, 2022

Codeclimate checks should clear if #960 merges first (see note above)

@codeclimate
Copy link
Contributor

codeclimate bot commented May 30, 2022

Code Climate has analyzed commit 846dcc6 and detected 0 issues on this pull request.

View more on Code Climate.

@JoeCohen JoeCohen merged commit 319d80d into master May 30, 2022
@JoeCohen
Copy link
Member

JoeCohen commented May 30, 2022 via email

@JoeCohen JoeCohen deleted the try-to-fix-ipstats-test branch June 6, 2022 00:24
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.

4 participants