summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-05-24 09:55:39 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-05-24 09:55:39 +0000
commit1fd5346c3c6069e1648ccab363e25aa8e917fb5f (patch)
treec61ac849ae6c7152150486d7b70c04cca1f64f84 /test/unit
parent1914d1a15984d5f255d76ba3d40e52b290c03a83 (diff)
downloadredmine-1fd5346c3c6069e1648ccab363e25aa8e917fb5f.tar.gz
redmine-1fd5346c3c6069e1648ccab363e25aa8e917fb5f.zip
Fixed that Member#destroy triggers after_destroy callbacks twice (#16795).
git-svn-id: http://svn.redmine.org/redmine/trunk@13140 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/member_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/member_test.rb b/test/unit/member_test.rb
index 586964b52..6ba9717c4 100644
--- a/test/unit/member_test.rb
+++ b/test/unit/member_test.rb
@@ -107,6 +107,23 @@ class MemberTest < ActiveSupport::TestCase
assert_nil category1.assigned_to_id
end
+ def test_destroy_should_trigger_callbacks_only_once
+ Member.class_eval { def destroy_test_callback; end}
+ Member.after_destroy :destroy_test_callback
+
+ m = Member.create!(:user_id => 1, :project_id => 1, :role_ids => [1,3])
+
+ Member.any_instance.expects(:destroy_test_callback).once
+ assert_difference 'Member.count', -1 do
+ assert_difference 'MemberRole.count', -2 do
+ m.destroy
+ end
+ end
+ assert m.destroyed?
+ ensure
+ Member._destroy_callbacks.reject! {|c| c.filter==:destroy_test_callback}
+ end
+
def test_sort_without_roles
a = Member.new(:roles => [Role.first])
b = Member.new