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

Move NoTouching down the inheritance chain on AR::Base #14842

Merged
merged 1 commit into from
Apr 23, 2014
Merged

Move NoTouching down the inheritance chain on AR::Base #14842

merged 1 commit into from
Apr 23, 2014

Conversation

lucasmazza
Copy link
Contributor

This way the no_touching blocks won't trigger any touch related callbacks and won't create empty transactions (since it is included after the Transactions module).

Fixes #14841.


DeveloperWithTouchCallback.no_touching do
developer.touch
assert !developer.after_touch_called
Copy link
Member

Choose a reason for hiding this comment

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

assert_not

@rafaelfranca
Copy link
Member

Looks good. Please include a CHANGELOG entry and I'll merge

@robin850 robin850 added this to the 4.1.1 milestone Apr 23, 2014
@lucasmazza
Copy link
Contributor Author

@rafaelfranca :shipit:

@@ -170,6 +170,15 @@ def test_no_touching_threadsafe
assert !@developer.no_touching?
end

def test_no_touching_with_callbacks
developer = DeveloperWithTouchCallback.first
Copy link
Member

Choose a reason for hiding this comment

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

Can we define DeveloperWithTouchCallback inside this test case?

dev_with_touch_callback = Class.new(ActiveRecord::Base)
  # ...
end

This will keep the context together and not increase the global models count any further.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. @rafaelfranca thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

👍

@lucasmazza
Copy link
Contributor Author

@senny @rafaelfranca PR updated 👍

senny added a commit that referenced this pull request Apr 23, 2014
Move `NoTouching` down the inheritance chain on AR::Base
@senny senny merged commit 32cdc03 into rails:master Apr 23, 2014
@senny
Copy link
Member

senny commented Apr 23, 2014

@lucasmazza thanks 💛

senny added a commit that referenced this pull request Apr 23, 2014
Move `NoTouching` down the inheritance chain on AR::Base
Conflicts:
	activerecord/test/cases/timestamp_test.rb
@lucasmazza lucasmazza deleted the lm-no-touching-callbacks branch June 19, 2014 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no_touching should bypass after_touch callback.
4 participants