diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-09-12 18:40:41 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-09-12 18:40:41 +0000 |
commit | 839c3b198e50ac38d1c647189927e18f36133518 (patch) | |
tree | 79041e4c3b20fabe57d79c9486456b2664e2febe /spec | |
parent | 069a6dfa9152dc61042bc3385651e9a81c8d3392 (diff) | |
parent | c1dd31cf8bd98ec1a8d951fa6211bfa799233650 (diff) | |
download | gitlab-ce-839c3b198e50ac38d1c647189927e18f36133518.tar.gz |
Merge branch 'feature/email_when_added_to_group' of /home/git/repositories/gitlab/gitlabhq
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mailers/notify_spec.rb | 20 | ||||
-rw-r--r-- | spec/observers/users_group_observer_spec.rb | 27 |
2 files changed, 47 insertions, 0 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 2f0475e5f02..0787bdbea6f 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -347,4 +347,24 @@ describe Notify do end end end + + describe 'group access changed' do + let(:group) { create(:group) } + let(:user) { create(:user) } + let(:membership) { create(:users_group, group: group, user: user) } + + subject { Notify.group_access_granted_email(membership.id) } + + it 'has the correct subject' do + should have_subject /access to group was granted/ + end + + it 'contains name of project' do + should have_body_text /#{group.name}/ + end + + it 'contains new user role' do + should have_body_text /#{membership.human_access}/ + end + end end diff --git a/spec/observers/users_group_observer_spec.rb b/spec/observers/users_group_observer_spec.rb new file mode 100644 index 00000000000..3bf562edbb7 --- /dev/null +++ b/spec/observers/users_group_observer_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe UsersGroupObserver do + before(:each) { enable_observers } + after(:each) { disable_observers } + + subject { UsersGroupObserver.instance } + before { subject.stub(notification: mock('NotificationService').as_null_object) } + + describe "#after_create" do + it "should send email to user" do + subject.should_receive(:notification) + create(:users_group) + end + end + + describe "#after_update" do + before do + @membership = create :users_group + end + + it "should send email to user" do + subject.should_receive(:notification) + @membership.update_attribute(:group_access, UsersGroup::MASTER) + end + end +end |