-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add before_validation hooks to resources #153
Add before_validation hooks to resources #153
Conversation
Thanks @A-Boudi - I want to take a closer look soon, but just glancing looks like a great PR. Just want you to know it's on my radar 👍 |
end | ||
|
||
it "does not run before_commit callbacks" do | ||
expect_any_instance_of(Graphiti::Util::ValidationResponse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did a great job with the general setup, but I think this is the issue that would hold up the PR. We wanted something to fire before validation. As you can see and line 126 of resource_proxy.rb
, this is happening after validation. IOW, we want to_not receive
- and probably a Rails integration spec that addresses the original issue.
I don't think you're too far off though! Hope we get this in 👏 !
Hi, @richmolj, I'm not sure if I did understand the issue correctly. Here is what I originally understood:
If a resource has validation on its children, it can't be saved because the children are not accessible when the resource is being saved. To fix this issue, the validation on children are scoped via a Now, if we want something to fire before validation. Would this mean that this new callback should be fired before |
Hi @richmolj, what do you think? |
@A-Boudi thanks for the reminder and sorry for the delay. I think you have correct understanding of the issue, but the word So, this is maybe this is better named as Still, it should fire before |
9c9c769
to
83fbfcb
Compare
83fbfcb
to
42269e9
Compare
Hi @richmolj, Like asked, I moved this hook to fire before graphiti validation. I also changed the name to For the tests, I have kept the test introduced in the first commit. And I added new integration tests that addresses the original issue. |
Really, REALLY great job @A-Boudi 💯 🥇 ! Thanks so much for sticking with it - I really appreciate the integration tests in particular ❤️ If you could please add an entry to the CHANGELOG, I'd be happy to merge! |
@richmolj CHANGELOG updated! |
Solves #122
This adds a before_validation hook to be fired just before the before_commit hook.