summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-08-03 00:43:51 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-08-03 21:55:48 +0800
commitbb5f79d43e0bb20bacd5ecd8b66832d9857bd079 (patch)
treeb480f8496e3e93e5a845e4a710e2d46901871413
parentb0464fa4e19e187adc46ec054ccd68832faec08c (diff)
downloadgitlab-ce-bb5f79d43e0bb20bacd5ecd8b66832d9857bd079.tar.gz
Don't include EmailHelpers manually, pick with rspecuse-rspec-support-helper
`:mailer` is needed to pick it easily, while `type: :mailer` is needed for picking it automatically for tests located in spec/mailers/*_spec.rb It's a bit complicated in spec/services/notification_service_spec.rb but we'll leave it alone for now.
-rw-r--r--spec/models/ci/pipeline_spec.rb6
-rw-r--r--spec/models/deploy_key_spec.rb4
-rw-r--r--spec/models/gpg_key_spec.rb4
-rw-r--r--spec/models/key_spec.rb4
-rw-r--r--spec/models/project_services/pipelines_email_service_spec.rb8
-rw-r--r--spec/requests/api/issues_spec.rb4
-rw-r--r--spec/requests/api/v3/issues_spec.rb4
-rw-r--r--spec/services/issues/update_service_spec.rb4
-rw-r--r--spec/services/merge_requests/update_service_spec.rb4
-rw-r--r--spec/services/notification_service_spec.rb11
-rw-r--r--spec/support/notify_shared_examples.rb1
-rw-r--r--spec/support/updating_mentions_shared_examples.rb2
-rw-r--r--spec/workers/emails_on_push_worker_spec.rb6
-rw-r--r--spec/workers/pipeline_notification_worker_spec.rb4
14 files changed, 15 insertions, 51 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index f63ff19c2fc..ac75c6501ee 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe Ci::Pipeline do
- include EmailHelpers
-
+describe Ci::Pipeline, :mailer do
let(:user) { create(:user) }
let(:project) { create(:project) }
@@ -1248,8 +1246,6 @@ describe Ci::Pipeline do
pipeline.user.global_notification_setting
.update(level: 'custom', failed_pipeline: true, success_pipeline: true)
- reset_delivered_emails!
-
perform_enqueued_jobs do
pipeline.enqueue
pipeline.run
diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb
index 2aece75b817..3d7283e2164 100644
--- a/spec/models/deploy_key_spec.rb
+++ b/spec/models/deploy_key_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe DeployKey do
- include EmailHelpers
-
+describe DeployKey, :mailer do
describe "Associations" do
it { is_expected.to have_many(:deploy_keys_projects) }
it { is_expected.to have_many(:projects) }
diff --git a/spec/models/gpg_key_spec.rb b/spec/models/gpg_key_spec.rb
index 59c074199db..e48f20bf53b 100644
--- a/spec/models/gpg_key_spec.rb
+++ b/spec/models/gpg_key_spec.rb
@@ -114,9 +114,7 @@ describe GpgKey do
end
end
- describe 'notification' do
- include EmailHelpers
-
+ describe 'notification', :mailer do
let(:user) { create(:user) }
it 'sends a notification' do
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index d41717d0223..882522c0a97 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe Key do
- include EmailHelpers
-
+describe Key, :mailer do
describe "Associations" do
it { is_expected.to belong_to(:user) }
end
diff --git a/spec/models/project_services/pipelines_email_service_spec.rb b/spec/models/project_services/pipelines_email_service_spec.rb
index 03932895b0e..5faab9ba38b 100644
--- a/spec/models/project_services/pipelines_email_service_spec.rb
+++ b/spec/models/project_services/pipelines_email_service_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe PipelinesEmailService do
- include EmailHelpers
-
+describe PipelinesEmailService, :mailer do
let(:pipeline) do
create(:ci_pipeline, project: project, sha: project.commit('master').sha)
end
@@ -14,10 +12,6 @@ describe PipelinesEmailService do
Gitlab::DataBuilder::Pipeline.build(pipeline)
end
- before do
- reset_delivered_emails!
- end
-
describe 'Validations' do
context 'when service is active' do
before do
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 60687db9316..7d120e4a234 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe API::Issues do
- include EmailHelpers
-
+describe API::Issues, :mailer do
set(:user) { create(:user) }
set(:project) do
create(:project, :public, creator_id: user.id, namespace: user.namespace)
diff --git a/spec/requests/api/v3/issues_spec.rb b/spec/requests/api/v3/issues_spec.rb
index b092c863c8a..9eb538c4b09 100644
--- a/spec/requests/api/v3/issues_spec.rb
+++ b/spec/requests/api/v3/issues_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe API::V3::Issues do
- include EmailHelpers
-
+describe API::V3::Issues, :mailer do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:non_member) { create(:user) }
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index ff0d876e6da..814e2cfbed0 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -1,9 +1,7 @@
# coding: utf-8
require 'spec_helper'
-describe Issues::UpdateService do
- include EmailHelpers
-
+describe Issues::UpdateService, :mailer do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index dd3ac9c4ac6..9368594bc86 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe MergeRequests::UpdateService do
- include EmailHelpers
-
+describe MergeRequests::UpdateService, :mailer do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:user2) { create(:user) }
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 882ee7751b5..5354591642b 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe NotificationService do
- include EmailHelpers
-
+describe NotificationService, :mailer do
let(:notification) { described_class.new }
let(:assignee) { create(:user) }
@@ -14,7 +12,6 @@ describe NotificationService do
shared_examples 'notifications for new mentions' do
def send_notifications(*new_mentions)
- reset_delivered_emails!
notification.send(notification_method, mentionable, new_mentions, @u_disabled)
end
@@ -137,12 +134,11 @@ describe NotificationService do
describe '#new_note' do
it do
add_users_with_subscription(note.project, issue)
+ reset_delivered_emails!
# Ensure create SentNotification by noteable = issue 6 times, not noteable = note
expect(SentNotification).to receive(:record).with(issue, any_args).exactly(8).times
- reset_delivered_emails!
-
notification.new_note(note)
should_email(@u_watcher)
@@ -165,9 +161,10 @@ describe NotificationService do
it "emails the note author if they've opted into notifications about their activity" do
add_users_with_subscription(note.project, issue)
- note.author.notified_of_own_activity = true
reset_delivered_emails!
+ note.author.notified_of_own_activity = true
+
notification.new_note(note)
should_email(note.author)
diff --git a/spec/support/notify_shared_examples.rb b/spec/support/notify_shared_examples.rb
index d6117d604f2..136f92c6419 100644
--- a/spec/support/notify_shared_examples.rb
+++ b/spec/support/notify_shared_examples.rb
@@ -7,7 +7,6 @@ shared_context 'gitlab email notification' do
let(:new_user_address) { 'newguy@example.com' }
before do
- reset_delivered_emails!
email = recipient.emails.create(email: "notifications@example.com")
recipient.update_attribute(:notification_email, email.email)
stub_incoming_email_setting(enabled: true, address: "reply+%{key}@#{Gitlab.config.gitlab.host}")
diff --git a/spec/support/updating_mentions_shared_examples.rb b/spec/support/updating_mentions_shared_examples.rb
index eeec3e1d79b..565d3203e4f 100644
--- a/spec/support/updating_mentions_shared_examples.rb
+++ b/spec/support/updating_mentions_shared_examples.rb
@@ -7,8 +7,6 @@ RSpec.shared_examples 'updating mentions' do |service_class|
end
def update_mentionable(opts)
- reset_delivered_emails!
-
perform_enqueued_jobs do
service_class.new(project, user, opts).execute(mentionable)
end
diff --git a/spec/workers/emails_on_push_worker_spec.rb b/spec/workers/emails_on_push_worker_spec.rb
index 5b6b38e0f76..318aad4bc1e 100644
--- a/spec/workers/emails_on_push_worker_spec.rb
+++ b/spec/workers/emails_on_push_worker_spec.rb
@@ -1,8 +1,7 @@
require 'spec_helper'
-describe EmailsOnPushWorker do
+describe EmailsOnPushWorker, :mailer do
include RepoHelpers
- include EmailHelpers
include EmailSpec::Matchers
let(:project) { create(:project, :repository) }
@@ -90,7 +89,6 @@ describe EmailsOnPushWorker do
context "when there is an SMTP error" do
before do
- reset_delivered_emails!
allow(Notify).to receive(:repository_push_email).and_raise(Net::SMTPFatalError)
allow(subject).to receive_message_chain(:logger, :info)
perform
@@ -114,8 +112,6 @@ describe EmailsOnPushWorker do
allow_any_instance_of(Mail::TestMailer).to receive(:deliver!).and_wrap_original do |original, mail|
original.call(Mail.new(mail.encoded))
end
-
- reset_delivered_emails!
end
it "sends the mail to each of the recipients" do
diff --git a/spec/workers/pipeline_notification_worker_spec.rb b/spec/workers/pipeline_notification_worker_spec.rb
index 139032d77bd..eb539ffd893 100644
--- a/spec/workers/pipeline_notification_worker_spec.rb
+++ b/spec/workers/pipeline_notification_worker_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe PipelineNotificationWorker do
- include EmailHelpers
-
+describe PipelineNotificationWorker, :mailer do
let(:pipeline) { create(:ci_pipeline) }
describe '#execute' do