File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def append(elements)
16
16
multi do
17
17
remove elements
18
18
super
19
- ltrim ( limit - 1 ) , -1 if limit
19
+ ltrim - limit , -1 if limit
20
20
end if Array ( elements ) . flatten . any?
21
21
end
22
22
alias << append
Original file line number Diff line number Diff line change 1
1
require "test_helper"
2
2
3
3
class UniqueListTest < ActiveSupport ::TestCase
4
- setup { @list = Kredis . unique_list "myuniquelist" }
4
+ setup { @list = Kredis . unique_list "myuniquelist" , limit : 5 }
5
5
6
6
test "append" do
7
7
@list . append ( %w[ 1 2 3 ] )
@@ -51,4 +51,16 @@ class UniqueListTest < ActiveSupport::TestCase
51
51
@list . append [ 1 , 2 ]
52
52
assert @list . exists?
53
53
end
54
+
55
+ test "appending over limit" do
56
+ @list . append ( %w[ 1 2 3 4 5 ] )
57
+ @list . append ( %w[ 6 7 8 ] )
58
+ assert_equal %w[ 4 5 6 7 8 ] , @list . elements
59
+ end
60
+
61
+ test "prepending over limit" do
62
+ @list . prepend ( %w[ 1 2 3 4 5 ] )
63
+ @list . prepend ( %w[ 6 7 8 ] )
64
+ assert_equal %w[ 8 7 6 5 4 ] , @list . elements
65
+ end
54
66
end
You can’t perform that action at this time.
0 commit comments