File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def append(elements)
1616 multi do
1717 remove elements
1818 super
19- ltrim ( limit - 1 ) , -1 if limit
19+ ltrim - limit , -1 if limit
2020 end if Array ( elements ) . flatten . any?
2121 end
2222 alias << append
Original file line number Diff line number Diff line change 11require "test_helper"
22
33class UniqueListTest < ActiveSupport ::TestCase
4- setup { @list = Kredis . unique_list "myuniquelist" }
4+ setup { @list = Kredis . unique_list "myuniquelist" , limit : 5 }
55
66 test "append" do
77 @list . append ( %w[ 1 2 3 ] )
@@ -51,4 +51,16 @@ class UniqueListTest < ActiveSupport::TestCase
5151 @list . append [ 1 , 2 ]
5252 assert @list . exists?
5353 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
5466end
You can’t perform that action at this time.
0 commit comments