Commit 8589824f005dc6d0c8291c454ff7ecdcadacf695
1 parent
73446fe1
Exists in
master
and in
4 other branches
Add UsersGroup observer
Trigger notification service when new user-group relation was created
Showing
2 changed files
with
36 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
| 1 | +require 'spec_helper' | ||
| 2 | + | ||
| 3 | +describe UsersGroupObserver do | ||
| 4 | + before(:each) { enable_observers } | ||
| 5 | + after(:each) { disable_observers } | ||
| 6 | + | ||
| 7 | + subject { UsersGroupObserver.instance } | ||
| 8 | + before { subject.stub(notification: mock('NotificationService').as_null_object) } | ||
| 9 | + | ||
| 10 | + describe "#after_create" do | ||
| 11 | + it "should send email to user" do | ||
| 12 | + subject.should_receive(:notification) | ||
| 13 | + create(:users_group) | ||
| 14 | + end | ||
| 15 | + end | ||
| 16 | + | ||
| 17 | + describe "#after_update" do | ||
| 18 | + before do | ||
| 19 | + @membership = create :users_group | ||
| 20 | + end | ||
| 21 | + | ||
| 22 | + it "should send email to user" do | ||
| 23 | + subject.should_receive(:notification) | ||
| 24 | + @membership.update_attribute(:group_access, UsersGroup::MASTER) | ||
| 25 | + end | ||
| 26 | + end | ||
| 27 | +end |