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/active_interactor/organizer/interactor_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def skip_deferred_after_perform_callbacks
return unless deferred_after_perform_callbacks.present?

deferred_after_perform_callbacks.each do |callback|
interactor_class.skip_callback(:perform, :after, callback.filter, raise: false)
interactor_class.skip_callback(:perform, :after, callback.filter, raise: false, if: -> { self.options.organizer.present? })
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

after_perform do
context.steps << 'after_perform_1a'
context.called_test_after_perform = true
end

after_perform do
context.steps << 'after_perform_1b'
end

def perform
context.fail! if context.should_fail
context.steps = []
context.steps << 'perform_1'
end
Expand Down Expand Up @@ -57,6 +59,8 @@ def perform
organize TestInteractor1, TestInteractor2, TestInteractor3
end
end

let(:organizer) { interactor_class }

include_examples 'a class with interactor methods'
include_examples 'a class with interactor callback methods'
Expand Down Expand Up @@ -147,5 +151,55 @@ def perform
]
)}
end

context 'when interactor is called via organizer' do
context 'and interactor is called individually prior' do
it 'calls the after_perform callbacks in both cases' do
result = test_interactor_1.perform
expect(result).to be_success
expect(result.called_test_after_perform).to be(true)

result = organizer.perform
expect(result).to be_success
expect(result.called_test_after_perform).to be(true)
end

context 'and interactor fails when called individually' do
it 'calls the after_perform callbacks just when organized' do
result = test_interactor_1.perform(should_fail: true)
expect(result).to be_failure
expect(result.called_test_after_perform).to be_nil

result = organizer.perform
expect(result).to be_success
expect(result.called_test_after_perform).to be(true)
end
end
end

context 'and interactor is called individually after' do
it 'calls the after_perform callbacks in both cases' do
result = organizer.perform
expect(result).to be_success
expect(result.called_test_after_perform).to be(true)

result = test_interactor_1.perform
expect(result).to be_success
expect(result.called_test_after_perform).to be(true)
end

context 'and interactor fails when called individually' do
it 'calls the after_perform callbacks just when organized' do
result = organizer.perform
expect(result).to be_success
expect(result.called_test_after_perform).to be(true)

result = test_interactor_1.perform(should_fail: true)
expect(result).to be_failure
expect(result.called_test_after_perform).to be_nil
end
end
end
end
end
end
end