Avoid duplicate group membership emails

This commit is contained in:
Jacob Vosmaer 2013-12-06 13:20:35 +01:00
parent 845b98ec2b
commit 1af65c96c9
2 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -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