Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/kredis/types/callbacks_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Kredis::Types::CallbacksProxy

AFTER_CHANGE_OPERATIONS = {
Kredis::Types::Counter => %i[ increment decrement reset ],
Kredis::Types::Cycle => %i[ next ],
Kredis::Types::Cycle => %i[ next reset ],
Kredis::Types::Enum => %i[ value= reset ],
Kredis::Types::Flag => %i[ mark remove ],
Kredis::Types::Hash => %i[ update delete []= remove ],
Expand Down
11 changes: 11 additions & 0 deletions test/callbacks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ class CallbacksTest < ActiveSupport::TestCase
assert_equal 1, @callback_check
end

test "cycle with after_change proc callback" do
@callback_check = nil
amount = Kredis.cycle "semaphore_light", after_change: ->(cycle) { @callback_check = cycle.value }, values: %w[ green yellow red ]

amount.next
assert_equal "yellow", @callback_check

amount.reset
assert_equal "green", @callback_check
end

test "unique list with after_change proc callback" do
@callback_check = nil
names = Kredis.unique_list "names", after_change: ->(list) { @callback_check = list.elements }
Expand Down