diff --git a/app/observers/users_group_observer.rb b/app/observers/users_group_observer.rb index ecdbede89d9..42a05b5e177 100644 --- a/app/observers/users_group_observer.rb +++ b/app/observers/users_group_observer.rb @@ -4,6 +4,6 @@ class UsersGroupObserver < BaseObserver end def after_update(membership) - notification.update_group_member(membership) + notification.update_group_member(membership) if membership.group_access_changed? end end diff --git a/spec/observers/users_group_observer_spec.rb b/spec/observers/users_group_observer_spec.rb index 3bf562edbb7..65484806b19 100644 --- a/spec/observers/users_group_observer_spec.rb +++ b/spec/observers/users_group_observer_spec.rb @@ -23,5 +23,10 @@ describe UsersGroupObserver do subject.should_receive(:notification) @membership.update_attribute(:group_access, UsersGroup::MASTER) end + + it "does not send an email when the access level has not changed" do + subject.should_not_receive(:notification) + @membership.update_attribute(:group_access, UsersGroup::OWNER) + end end end