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
Merged
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
12 changes: 10 additions & 2 deletions test/controllers/account_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -827,12 +827,20 @@ def test_blocked_ips
get(:blocked_ips, add_bad: "garbage")
assert_flash_error

get(:blocked_ips, add_bad: 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.

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.

get(:blocked_ips, params: { add_bad: new_ip })
assert_no_flash
assert(time < File.mtime(MO.blocked_ips_file))
IpStats.reset!
assert_true(IpStats.blocked?(new_ip))

get(:blocked_ips, remove_bad: 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.

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.

get(:blocked_ips, params: { remove_bad: new_ip })
assert_no_flash
assert(time < File.mtime(MO.blocked_ips_file))
IpStats.reset!
assert_false(IpStats.blocked?(new_ip))
end

Expand Down