File tree 2 files changed +3
-2
lines changed
2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ class Pecorino::Block
13
13
def self . set! ( key :, block_for :, adapter : Pecorino . adapter )
14
14
adapter . set_block ( key : key , block_for : block_for )
15
15
Time . now + block_for
16
+ rescue ArgumentError # negative block
17
+ nil
16
18
end
17
19
18
20
# Returns the time until a certain block is in effect
Original file line number Diff line number Diff line change @@ -15,8 +15,7 @@ class BlockTest < ActiveSupport::TestCase
15
15
test "does not return a block which has lapsed" do
16
16
k = Base64 . strict_encode64 ( Random . bytes ( 4 ) )
17
17
assert_nil Pecorino ::Block . blocked_until ( key : k )
18
- assert Pecorino ::Block . set! ( key : k , block_for : -30 . minutes )
19
-
18
+ Pecorino ::Block . set! ( key : k , block_for : -30 . minutes )
20
19
blocked_until = Pecorino ::Block . blocked_until ( key : k )
21
20
assert_nil blocked_until
22
21
end
You can’t perform that action at this time.
0 commit comments