summaryrefslogtreecommitdiff
path: root/spec/services/notification_service_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-03-17 14:19:51 -0700
committerStan Hu <stanhu@gmail.com>2017-03-17 14:19:51 -0700
commit70f1fe6915549c94ea8bdf7ab1aed9c1c364415c (patch)
tree045db56cfe8296e8052192324e00aa4220a58aee /spec/services/notification_service_spec.rb
parent11a964ced475049de86f4f20a4dc96be5bcf6824 (diff)
parent5d71d9fb9d6ca89710549fbfef62d105d9544a30 (diff)
downloadgitlab-ce-70f1fe6915549c94ea8bdf7ab1aed9c1c364415c.tar.gz
Merge branch 'master' into sh-bring-back-option-to-be-notified-of-own-activity
Diffstat (limited to 'spec/services/notification_service_spec.rb')
-rw-r--r--spec/services/notification_service_spec.rb71
1 files changed, 70 insertions, 1 deletions
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index ebbaea4e59a..229291f19e9 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -795,7 +795,7 @@ describe NotificationService, services: true do
update_custom_notification(:reopen_issue, @u_custom_global)
end
- it 'sends email to issue assignee and issue author' do
+ it 'sends email to issue notification recipients' do
notification.reopen_issue(issue, @u_disabled)
should_email(issue.assignee)
@@ -809,6 +809,7 @@ describe NotificationService, services: true do
should_email(@watcher_and_subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
+ should_not_email(@u_disabled)
should_not_email(@u_lazy_participant)
end
@@ -818,6 +819,32 @@ describe NotificationService, services: true do
let(:notification_trigger) { notification.reopen_issue(issue, @u_disabled) }
end
end
+
+ describe '#issue_moved' do
+ let(:new_issue) { create(:issue) }
+
+ it 'sends email to issue notification recipients' do
+ notification.issue_moved(issue, new_issue, @u_disabled)
+
+ should_email(issue.assignee)
+ should_email(issue.author)
+ should_email(@u_watcher)
+ should_email(@u_guest_watcher)
+ should_email(@u_participant_mentioned)
+ should_email(@subscriber)
+ should_email(@watcher_and_subscriber)
+ should_not_email(@unsubscriber)
+ should_not_email(@u_participating)
+ should_not_email(@u_disabled)
+ should_not_email(@u_lazy_participant)
+ end
+
+ it_behaves_like 'participating notifications' do
+ let(:participant) { create(:user, username: 'user-participant') }
+ let(:issuable) { issue }
+ let(:notification_trigger) { notification.issue_moved(issue, new_issue, @u_disabled) }
+ end
+ end
end
describe 'Merge Requests' do
@@ -1251,6 +1278,48 @@ describe NotificationService, services: true do
end
end
+ describe 'Pipelines' do
+ describe '#pipeline_finished' do
+ let(:project) { create(:project, :public) }
+ let(:current_user) { create(:user) }
+ let(:u_member) { create(:user) }
+ let(:u_other) { create(:user) }
+
+ let(:commit) { project.commit }
+ let(:pipeline) do
+ create(:ci_pipeline, :success,
+ project: project,
+ user: current_user,
+ ref: 'refs/heads/master',
+ sha: commit.id,
+ before_sha: '00000000')
+ end
+
+ before do
+ project.add_master(current_user)
+ project.add_master(u_member)
+ reset_delivered_emails!
+ end
+
+ context 'without custom recipients' do
+ it 'notifies the pipeline user' do
+ notification.pipeline_finished(pipeline)
+
+ should_only_email(current_user, kind: :bcc)
+ end
+ end
+
+ context 'with custom recipients' do
+ it 'notifies the custom recipients' do
+ users = [u_member, u_other]
+ notification.pipeline_finished(pipeline, users.map(&:notification_email))
+
+ should_only_email(*users, kind: :bcc)
+ end
+ end
+ end
+ end
+
def build_team(project)
@u_watcher = create_global_setting_for(create(:user), :watch)
@u_participating = create_global_setting_for(create(:user), :participating)