Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Organizers do not rollback parent context #243

Closed
aka-momo opened this issue Sep 18, 2020 · 0 comments · Fixed by #248
Closed

Nested Organizers do not rollback parent context #243

aka-momo opened this issue Sep 18, 2020 · 0 comments · Fixed by #248
Labels
bug Something isn't working verified This issue has been verified.
Milestone

Comments

@aka-momo
Copy link
Contributor

Current Behavior

Failure in C2 does rollback C1 and P1 with wrong context.success? = true
While P2 perform is executed.

> [P1][Perform]  | context: true
> [C1][Perform]  | context: true
> [C2][Perform]  | context: true
> [C2][Rollback] | context: false
> [C1][Rollback] | context: true
> [P1][Rollback] | context: true
> [P2][Perform]  | context: false

Expected Behavior

C1 and P1 should have context.success? = false
P2 perform should not execute

> [P1][Perform]  | context: true
> [C1][Perform]  | context: true
> [C2][Perform]  | context: true
> [C2][Rollback] | context: false
> [C1][Rollback] | context: false
> [P1][Rollback] | context: false

Steps to Reproduce

class P1 < ::ActiveInteractor::Base
  def perform
    puts "> [P1][Perform]  | context: #{context.success?}"
  end

  def rollback
    puts "> [P1][Rollback] | context: #{context.success?}"
  end
end

class C1 < ::ActiveInteractor::Base
  def perform
    puts "> [C1][Perform]  | context: #{context.success?}"
  end

  def rollback
    puts "> [C1][Rollback] | context: #{context.success?}"
  end
end

class P2 < ::ActiveInteractor::Base
  def perform
    puts "> [P2][Perform]  | context: #{context.success?}"
  end

  def rollback
    puts "> [P2][Rollback] | context: #{context.success?}"
  end
end

class C2 < ::ActiveInteractor::Base
  def perform
    puts "> [C2][Perform]  | context: #{context.success?}"
    context.fail!
  end

  def rollback
    puts "> [C2][Rollback] | context: #{context.success?}"
  end
end

class ChildOrganizer < ActiveInteractor::Organizer::Base
  organize do
    add C1
    add C2
  end
end

class ParentOrganizer < ActiveInteractor::Organizer::Base
  organize do
    add P1
    add ChildOrganizer
    add P2
  end
end

ParentOrganizer.perform

Additional Comments

@aka-momo aka-momo added bug Something isn't working unverified This issue has not been verified labels Sep 18, 2020
@aaronmallen aaronmallen added this to the v1.1.0 milestone Oct 4, 2020
@aaronmallen aaronmallen added verified This issue has been verified. and removed unverified This issue has not been verified labels Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working verified This issue has been verified.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants