From 757d091e1a477c4d15d8dfe7102865cfd38aa8c3 Mon Sep 17 00:00:00 2001 From: Joel Van Horn Date: Thu, 18 May 2017 21:51:56 -0400 Subject: [PATCH] Added tests to make sure inverse associations are updated after `delete` and `destroy` --- spec/active_record_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/active_record_spec.rb b/spec/active_record_spec.rb index d8abf20..2841188 100644 --- a/spec/active_record_spec.rb +++ b/spec/active_record_spec.rb @@ -220,6 +220,9 @@ class ProjectMember < ActiveRecord::Base group.users.delete(user) group.widgets.destroy(widget) + expect(user.groups).to_not include(group) + expect(widget.groups).to_not include(group) + expect(group.widgets).to_not include(widget) expect(group.users).to_not include(user) @@ -234,6 +237,9 @@ class ProjectMember < ActiveRecord::Base user.groups.delete(group) widget.groups.destroy(group) + expect(group.users).to_not include(user) + expect(group.widgets).to_not include(widget) + expect(group.widgets).to_not include(widget) expect(group.users).to_not include(user)