Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2016-07-13 00:19:47 +0300
committerFelipe Artur <felipefac@gmail.com>2016-07-16 02:38:27 +0300
commit2e9d53586874a83cea7e7d29a49bde1180e15829 (patch)
tree8118f6c65c9b610f143e34f8b6a1e8f252065ec4 /spec/models/project_services
parent2d96c66d63d480f24fd023fe73bf95e67d5ad257 (diff)
Allow build email service to be tested
Diffstat (limited to 'spec/models/project_services')
-rw-r--r--spec/models/project_services/builds_email_service_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/project_services/builds_email_service_spec.rb b/spec/models/project_services/builds_email_service_spec.rb
index 236df8f047d..ca2cd8aa551 100644
--- a/spec/models/project_services/builds_email_service_spec.rb
+++ b/spec/models/project_services/builds_email_service_spec.rb
@@ -23,6 +23,44 @@ describe BuildsEmailService do
end
end
+ describe '#test_data' do
+ let(:build) { create(:ci_build) }
+ let(:project) { build.project }
+ let(:user) { create(:user) }
+
+ before { project.team << [user, :developer] }
+
+ it 'builds test data' do
+ data = subject.test_data(project)
+
+ expect(data[:object_kind]).to eq("build")
+ end
+ end
+
+ describe '#test' do
+ it 'sends email' do
+ data = Gitlab::BuildDataBuilder.build(create(:ci_build))
+ subject.recipients = 'test@gitlab.com'
+
+ expect(BuildEmailWorker).to receive(:perform_async)
+
+ subject.test(data)
+ end
+
+ context 'notify only failed builds is true' do
+ it 'sends email' do
+ data = Gitlab::BuildDataBuilder.build(create(:ci_build))
+ data[:build_status] = "success"
+ subject.recipients = 'test@gitlab.com'
+
+ expect(subject).not_to receive(:notify_only_broken_builds)
+ expect(BuildEmailWorker).to receive(:perform_async)
+
+ subject.test(data)
+ end
+ end
+ end
+
describe '#execute' do
it 'sends email' do
subject.recipients = 'test@gitlab.com'