Skip to content

Allow subclasses to redefine autosave callbacks for associated records - #33378

Merged
rafaelfranca merged 1 commit into
rails:masterfrom
numbata:subclass-redefine-autosave-callbacks
Sep 13, 2018
Merged

Allow subclasses to redefine autosave callbacks for associated records#33378
rafaelfranca merged 1 commit into
rails:masterfrom
numbata:subclass-redefine-autosave-callbacks

Conversation

@numbata

@numbata numbata commented Jul 17, 2018

Copy link
Copy Markdown
Contributor

Summary

This addresses this issue #33305

AutosaveAssociation skip creation of callback method if it's already defined (even in parent class).

@rails-bot

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@bogdanvlviv bogdanvlviv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
Could you please fix rubocop issues in https://codeclimate.com/github/rails/rails/pull/33378?

Comment thread activerecord/CHANGELOG.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing dot after #33305

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line

@bogdanvlviv bogdanvlviv Jul 17, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IN => In. I would also add suffix WithAcceptsNestedAttributes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change order of arguments since assert_equal receive expected value as first argument and actual values as the second.
It would improve error message:

Expected: "Initial"
  Actual: "Updated"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the order of arguments since assert_equal receive an expected value as the first argument and an actual values as the second.
It would improve error message:

Expected: "Initial"
  Actual: "Updated"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogdanvlviv Sure. Can i squash commits into one after?

@bogdanvlviv

Copy link
Copy Markdown
Contributor

Could you squash commits into one?

@numbata
numbata force-pushed the subclass-redefine-autosave-callbacks branch from c27adf7 to a6aabf4 Compare July 17, 2018 11:14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but maybe it would be better to move this class definition to activerecord/test/models/company.rb

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm not sure too. This specific class used in this specific place only. It should be useless in other cases. Especially when activerecord/test/models/company.rb full of other classes.

Also maybe i should move this spec to activerecord/test/cases/nested_attributes_test.rb?

@numbata
numbata force-pushed the subclass-redefine-autosave-callbacks branch from a6aabf4 to 3e271dc Compare July 26, 2018 06:14
@numbata
numbata force-pushed the subclass-redefine-autosave-callbacks branch from 3e271dc to 35ee756 Compare July 26, 2018 21:38
@rafaelfranca
rafaelfranca merged commit 35ee756 into rails:master Sep 13, 2018
rafaelfranca added a commit that referenced this pull request Sep 13, 2018
…lbacks

Allow subclasses to redefine autosave callbacks for associated records
suketa added a commit to suketa/rails_sandbox that referenced this pull request Jun 1, 2019
Allow subclasses to redefine autosave callbacks for associated records
rails/rails#33378
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.

4 participants