Commit 2c471ec2a124577ee7a898d7838b360389cd83be
1 parent
d2fad26e
Exists in
staging
and in
4 other branches
Avoid unecessary user save after update person
Showing
3 changed files
with
9 additions
and
1 deletions
Show diff stats
app/models/person.rb
test/functional/search_controller_test.rb
... | ... | @@ -30,6 +30,7 @@ class SearchControllerTest < ActionController::TestCase |
30 | 30 | # By pass user validation on person creation |
31 | 31 | user = mock() |
32 | 32 | user.stubs(:id).returns(1) |
33 | + user.stubs(:changes).returns(nil) | |
33 | 34 | user.stubs(:valid?).returns(true) |
34 | 35 | user.stubs(:email).returns('some@test.com') |
35 | 36 | user.stubs(:save!).returns(true) | ... | ... |
test/unit/person_test.rb
... | ... | @@ -1767,4 +1767,11 @@ class PersonTest < ActiveSupport::TestCase |
1767 | 1767 | assert person.voted_against?(article) |
1768 | 1768 | end |
1769 | 1769 | |
1770 | + should 'not save user after an update on person and user is not touched' do | |
1771 | + user = create_user('testuser') | |
1772 | + person = user.person | |
1773 | + person.user.expects(:save!).never | |
1774 | + person.save! | |
1775 | + end | |
1776 | + | |
1770 | 1777 | end | ... | ... |