Skip to content

.success? still reporting true when interactor invoked via .call is calling internally another interactor with .call! and latter fails #170

@thaiden

Description

@thaiden

Context

I've noticed in our code base that we had cases where Interactor was encapsulating more interactors and calling them via .call!. One of the interactors was raising Interactor::Failure exception, but because parent interactor was invoked via .call context .success? was still reporting true.

I believe that is wrong behavior and since .call is not raising exception it at least should return false when .success? is invoked.

Steps to reproduce

  class ParentInteractor
    include Interactor

    def call
      InteractorWithError.call!
    end
  end

  class InteractorWithError
    include Interactor

    def call
      raise Interactor::Failure.new('test')
    end
  end

  test 'interactor still reports success after it failed' do
    context = ParentInteractor.call
    assert context.failure?
    assert_not context.success?
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions