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

Fix errors on callbacks #486 #487

Merged
merged 4 commits into from
Aug 23, 2020
Merged

Fix errors on callbacks #486 #487

merged 4 commits into from
Aug 23, 2020

Conversation

jonian
Copy link
Contributor

@jonian jonian commented Aug 6, 2020

Fixes #486

@AaronLasseigne
Copy link
Owner

Can you add a test for this?

@jonian
Copy link
Contributor Author

jonian commented Aug 8, 2020

Yes, I can write a test for this. I have also updated issue #486 with more info and examples to explain the issue better. Is the test below ok?

context 'with block not called and error added in execute around callback' do
  class CheckExecuteAroundCallbackForFailure
    include ActiveInteraction::ActiveModelable
    include ActiveInteraction::Runnable

    set_callback :execute, :around, -> { errors.add(:base, 'invalid') }

    def execute
      true
    end
  end

  it 'is invalid' do
    outcome = CheckExecuteAroundCallbackForFailure.run
    expect(outcome).to_not be_valid
  end
end

@AaronLasseigne
Copy link
Owner

Looks good.

@jonian
Copy link
Contributor Author

jonian commented Aug 23, 2020

Test added. If there anything else I should do, please let me know.

@AaronLasseigne AaronLasseigne merged commit 85b8117 into AaronLasseigne:master Aug 23, 2020
@AaronLasseigne
Copy link
Owner

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[3.8.2] valid? returns true if block not called and error added in execute around callback
2 participants