Commit 74b720034a41a599f4fc0341e57f046794e5aa73

Authored by Dmitriy Zaporozhets
2 parents 845b98ec 1af65c96

Merge branch 'users_group_observer' of /home/git/repositories/gitlab/gitlabhq

app/observers/users_group_observer.rb
@@ -4,6 +4,6 @@ class UsersGroupObserver < BaseObserver @@ -4,6 +4,6 @@ class UsersGroupObserver < BaseObserver
4 end 4 end
5 5
6 def after_update(membership) 6 def after_update(membership)
7 - notification.update_group_member(membership) 7 + notification.update_group_member(membership) if membership.group_access_changed?
8 end 8 end
9 end 9 end
spec/observers/users_group_observer_spec.rb
@@ -23,5 +23,10 @@ describe UsersGroupObserver do @@ -23,5 +23,10 @@ describe UsersGroupObserver do
23 subject.should_receive(:notification) 23 subject.should_receive(:notification)
24 @membership.update_attribute(:group_access, UsersGroup::MASTER) 24 @membership.update_attribute(:group_access, UsersGroup::MASTER)
25 end 25 end
  26 +
  27 + it "does not send an email when the access level has not changed" do
  28 + subject.should_not_receive(:notification)
  29 + @membership.update_attribute(:group_access, UsersGroup::OWNER)
  30 + end
26 end 31 end
27 end 32 end