Skip to content

Commit

Permalink
Merge pull request #962 from MushroomObserver/try-to-fix-ipstats-test
Browse files Browse the repository at this point in the history
AccountControllerTest#test_blocked_ips — Tried setting file times more explicitly so that this test works
  • Loading branch information
JoeCohen authored May 30, 2022
2 parents 2910501 + 846dcc6 commit 319d80d
Showing 1 changed file with 10 additions and 2 deletions.
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)
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)
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

0 comments on commit 319d80d

Please sign in to comment.