Skip to content

Organizer's top-level rollback should be called #151

@lazyatom

Description

@lazyatom

If I have an Organizer which defines a rollback method, I'd expect it to be called at some point if any of the organised interactors fail. For example:

class SomeInteractor
  include Interactor
  def call
    # do something
  end
  def rollback
    puts "rolling back SomeInteractor"
  end
end

class SomeOtherInteractor
  include Interactor
  def call
    context.fail!
  end
  def rollback
    puts "rolling back SomeOtherInteractor"
  end
end

class MyThing
  include Interactor::Organizer

  organize SomeInteractor, SomeOtherInteractor

  def rollback
    puts "rolling back organizer"
  end
end

Given the interactors above, when I call MyThing.call, I'd hope to see:

rolling back SomeInteractor
rolling back organiser

but instead, I see:

rolling back SomeInteractor

I think this is because when we run! the organiser interactor, it doesn't mark itself as having been called within the context. Is there a good reason for this?

(If we did change this such that the organiser's rollback was called, this might also go some way towards addressing the same use cases as #147.)

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