Skip to content
Snippets Groups Projects
Commit e0131c5d authored by Valery Sizov's avatar Valery Sizov
Browse files

Merge branch 'rails_update_to_4_2' into 'master'

Rails update to 4.2.4

https://gitlab.com/gitlab-org/gitlab-ce/issues/2694

See merge request !1902
parents a8e05cec f1504e1a
No related branches found
No related tags found
No related merge requests found
Showing
with 224 additions and 283 deletions
Loading
Loading
@@ -18,27 +18,31 @@ describe AbuseReportsController do
end
 
it "sends a notification email" do
post :create,
abuse_report: {
user_id: user.id,
message: message
}
email = ActionMailer::Base.deliveries.last
expect(email.to).to eq([admin_email])
expect(email.subject).to include(user.username)
expect(email.text_part.body).to include(message)
end
it "saves the abuse report" do
expect do
perform_enqueued_jobs do
post :create,
abuse_report: {
user_id: user.id,
message: message
}
end.to change { AbuseReport.count }.by(1)
email = ActionMailer::Base.deliveries.last
expect(email.to).to eq([admin_email])
expect(email.subject).to include(user.username)
expect(email.text_part.body).to include(message)
end
end
it "saves the abuse report" do
perform_enqueued_jobs do
expect do
post :create,
abuse_report: {
user_id: user.id,
message: message
}
end.to change { AbuseReport.count }.by(1)
end
end
end
 
Loading
Loading
Loading
Loading
@@ -87,13 +87,16 @@ describe "Admin::Users", feature: true do
end
 
it "should call send mail" do
expect(Notify).to receive(:new_user_email)
expect_any_instance_of(NotificationService).to receive(:new_user)
 
click_button "Create user"
end
 
it "should send valid email to user with email & password" do
click_button "Create user"
perform_enqueued_jobs do
click_button "Create user"
end
user = User.find_by(username: 'bang')
email = ActionMailer::Base.deliveries.last
expect(email.subject).to have_content('Account was created')
Loading
Loading
Loading
Loading
@@ -59,7 +59,7 @@ describe ApplicationHelper do
 
avatar_url = "http://localhost/uploads/project/avatar/#{project.id}/banana_sample.gif"
expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s).
to eq "<img alt=\"Banana sample\" src=\"#{avatar_url}\" />"
to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />"
end
 
it 'should give uploaded icon when present' do
Loading
Loading
Loading
Loading
@@ -71,7 +71,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}")
 
expect(doc.css('a').first.attr('href')).to eq urls.
namespace_project_issues_url(project.namespace, project, label_name: label.name)
namespace_project_issues_path(project.namespace, project, label_name: label.name)
end
 
it 'links with adjacent text' do
Loading
Loading
@@ -94,7 +94,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}")
 
expect(doc.css('a').first.attr('href')).to eq urls.
namespace_project_issues_url(project.namespace, project, label_name: label.name)
namespace_project_issues_path(project.namespace, project, label_name: label.name)
expect(doc.text).to eq 'See gfm'
end
 
Loading
Loading
@@ -118,7 +118,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}")
 
expect(doc.css('a').first.attr('href')).to eq urls.
namespace_project_issues_url(project.namespace, project, label_name: label.name)
namespace_project_issues_path(project.namespace, project, label_name: label.name)
expect(doc.text).to eq 'See gfm references'
end
 
Loading
Loading
Loading
Loading
@@ -44,13 +44,10 @@ describe Ci::MailService do
end
 
it do
should_email("git@example.com")
mail.execute(build)
end
def should_email(email)
expect(Ci::Notify).to receive(:build_fail_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
perform_enqueued_jobs do
expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
expect(ActionMailer::Base.deliveries.last.to).to eq(["git@example.com"])
end
end
end
 
Loading
Loading
@@ -67,13 +64,10 @@ describe Ci::MailService do
end
 
it do
should_email("git@example.com")
mail.execute(build)
end
def should_email(email)
expect(Ci::Notify).to receive(:build_success_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
perform_enqueued_jobs do
expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
expect(ActionMailer::Base.deliveries.last.to).to eq(["git@example.com"])
end
end
end
 
Loading
Loading
@@ -95,14 +89,12 @@ describe Ci::MailService do
end
 
it do
should_email("git@example.com")
should_email("jeroen@example.com")
mail.execute(build)
end
def should_email(email)
expect(Ci::Notify).to receive(:build_success_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
perform_enqueued_jobs do
expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(2)
expect(
ActionMailer::Base.deliveries.map(&:to).flatten
).to include("git@example.com", "jeroen@example.com")
end
end
end
 
Loading
Loading
@@ -124,14 +116,11 @@ describe Ci::MailService do
end
 
it do
should_email(commit.git_author_email)
should_email("jeroen@example.com")
mail.execute(build) if mail.can_execute?(build)
end
def should_email(email)
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
perform_enqueued_jobs do
expect do
mail.execute(build) if mail.can_execute?(build)
end.to_not change{ ActionMailer::Base.deliveries.size }
end
end
end
 
Loading
Loading
@@ -177,14 +166,11 @@ describe Ci::MailService do
 
it do
Ci::Build.retry(build)
should_email(commit.git_author_email)
should_email("jeroen@example.com")
mail.execute(build) if mail.can_execute?(build)
end
def should_email(email)
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
perform_enqueued_jobs do
expect do
mail.execute(build) if mail.can_execute?(build)
end.to_not change{ ActionMailer::Base.deliveries.size }
end
end
end
end
Loading
Loading
Loading
Loading
@@ -94,9 +94,9 @@ describe JiraService do
end
 
it 'should be prepopulated with the settings' do
expect(@service.properties[:project_url]).to eq('http://jira.sample/projects/project_a')
expect(@service.properties[:issues_url]).to eq("http://jira.sample/issues/:id")
expect(@service.properties[:new_issue_url]).to eq("http://jira.sample/projects/project_a/issues/new")
expect(@service.properties["project_url"]).to eq('http://jira.sample/projects/project_a')
expect(@service.properties["issues_url"]).to eq("http://jira.sample/issues/:id")
expect(@service.properties["new_issue_url"]).to eq("http://jira.sample/projects/project_a/issues/new")
end
end
end
Loading
Loading
Loading
Loading
@@ -14,7 +14,9 @@ describe Issues::CloseService do
describe :execute do
context "valid params" do
before do
@issue = Issues::CloseService.new(project, user, {}).execute(issue)
perform_enqueued_jobs do
@issue = Issues::CloseService.new(project, user, {}).execute(issue)
end
end
 
it { expect(@issue).to be_valid }
Loading
Loading
Loading
Loading
@@ -36,7 +36,10 @@ describe Issues::UpdateService do
label_ids: [label.id]
}
 
@issue = Issues::UpdateService.new(project, user, opts).execute(issue)
perform_enqueued_jobs do
@issue = Issues::UpdateService.new(project, user, opts).execute(issue)
end
@issue.reload
end
 
Loading
Loading
Loading
Loading
@@ -18,7 +18,9 @@ describe MergeRequests::CloseService do
before do
allow(service).to receive(:execute_hooks)
 
@merge_request = service.execute(merge_request)
perform_enqueued_jobs do
@merge_request = service.execute(merge_request)
end
end
 
it { expect(@merge_request).to be_valid }
Loading
Loading
Loading
Loading
@@ -17,8 +17,9 @@ describe MergeRequests::MergeService do
 
before do
allow(service).to receive(:execute_hooks)
service.execute(merge_request, 'Awesome message')
perform_enqueued_jobs do
service.execute(merge_request, 'Awesome message')
end
end
 
it { expect(merge_request).to be_valid }
Loading
Loading
Loading
Loading
@@ -19,7 +19,9 @@ describe MergeRequests::ReopenService do
allow(service).to receive(:execute_hooks)
 
merge_request.state = :closed
service.execute(merge_request)
perform_enqueued_jobs do
service.execute(merge_request)
end
end
 
it { expect(merge_request).to be_valid }
Loading
Loading
Loading
Loading
@@ -42,8 +42,10 @@ describe MergeRequests::UpdateService do
before do
allow(service).to receive(:execute_hooks)
 
@merge_request = service.execute(merge_request)
@merge_request.reload
perform_enqueued_jobs do
@merge_request = service.execute(merge_request)
@merge_request.reload
end
end
 
it { expect(@merge_request).to be_valid }
Loading
Loading
Loading
Loading
@@ -3,6 +3,12 @@ require 'spec_helper'
describe NotificationService do
let(:notification) { NotificationService.new }
 
around(:each) do |example|
perform_enqueued_jobs do
example.run
end
end
describe 'Keys' do
describe :new_key do
let!(:key) { create(:personal_key) }
Loading
Loading
@@ -10,8 +16,7 @@ describe NotificationService do
it { expect(notification.new_key(key)).to be_truthy }
 
it 'should sent email to key owner' do
expect(Notify).to receive(:new_ssh_key_email).with(key.id)
notification.new_key(key)
expect{ notification.new_key(key) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
end
end
end
Loading
Loading
@@ -23,8 +28,7 @@ describe NotificationService do
it { expect(notification.new_email(email)).to be_truthy }
 
it 'should send email to email owner' do
expect(Notify).to receive(:new_email_email).with(email.id)
notification.new_email(email)
expect{ notification.new_email(email) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
end
end
end
Loading
Loading
@@ -47,18 +51,20 @@ describe NotificationService do
it do
add_users_with_subscription(note.project, issue)
 
should_email(@u_watcher.id)
should_email(note.noteable.author_id)
should_email(note.noteable.assignee_id)
should_email(@u_mentioned.id)
should_email(@subscriber.id)
should_not_email(note.author_id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
should_not_email(@unsubscriber.id)
should_not_email(@u_outsider_mentioned)
ActionMailer::Base.deliveries.clear
 
notification.new_note(note)
should_email(@u_watcher)
should_email(note.noteable.author)
should_email(note.noteable.assignee)
should_email(@u_mentioned)
should_email(@subscriber)
should_not_email(note.author)
should_not_email(@u_participating)
should_not_email(@u_disabled)
should_not_email(@unsubscriber)
should_not_email(@u_outsider_mentioned)
end
 
it 'filters out "mentioned in" notes' do
Loading
Loading
@@ -82,26 +88,20 @@ describe NotificationService do
group_member = note.project.group.group_members.find_by_user_id(@u_watcher.id)
group_member.notification_level = Notification::N_GLOBAL
group_member.save
ActionMailer::Base.deliveries.clear
end
 
it do
should_email(note.noteable.author_id)
should_email(note.noteable.assignee_id)
should_email(@u_mentioned.id)
should_not_email(@u_watcher.id)
should_not_email(note.author_id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.new_note(note)
end
end
 
def should_email(user_id)
expect(Notify).to receive(:note_issue_email).with(user_id, note.id)
end
def should_not_email(user_id)
expect(Notify).not_to receive(:note_issue_email).with(user_id, note.id)
should_email(note.noteable.author)
should_email(note.noteable.assignee)
should_email(@u_mentioned)
should_not_email(@u_watcher)
should_not_email(note.author)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
end
end
 
Loading
Loading
@@ -113,24 +113,26 @@ describe NotificationService do
 
before do
build_team(note.project)
ActionMailer::Base.deliveries.clear
end
 
describe :new_note do
it do
notification.new_note(note)
# Notify all team members
note.project.team.members.each do |member|
# User with disabled notification should not be notified
next if member.id == @u_disabled.id
should_email(member.id)
should_email(member)
end
should_email(note.noteable.author_id)
should_email(note.noteable.assignee_id)
 
should_not_email(note.author_id)
should_not_email(@u_mentioned.id)
should_not_email(@u_disabled.id)
should_not_email(@u_not_mentioned.id)
notification.new_note(note)
should_email(note.noteable.author)
should_email(note.noteable.assignee)
should_not_email(note.author)
should_email(@u_mentioned)
should_not_email(@u_disabled)
should_email(@u_not_mentioned)
end
 
it 'filters out "mentioned in" notes' do
Loading
Loading
@@ -140,14 +142,6 @@ describe NotificationService do
notification.new_note(mentioned_note)
end
end
def should_email(user_id)
expect(Notify).to receive(:note_issue_email).with(user_id, note.id)
end
def should_not_email(user_id)
expect(Notify).not_to receive(:note_issue_email).with(user_id, note.id)
end
end
 
context 'commit note' do
Loading
Loading
@@ -156,43 +150,38 @@ describe NotificationService do
 
before do
build_team(note.project)
ActionMailer::Base.deliveries.clear
allow_any_instance_of(Commit).to receive(:author).and_return(@u_committer)
end
 
describe :new_note do
describe :new_note, :perform_enqueued_jobs do
it do
should_email(@u_committer.id, note)
should_email(@u_watcher.id, note)
should_not_email(@u_mentioned.id, note)
should_not_email(note.author_id, note)
should_not_email(@u_participating.id, note)
should_not_email(@u_disabled.id, note)
notification.new_note(note)
should_email(@u_committer)
should_email(@u_watcher)
should_not_email(@u_mentioned)
should_not_email(note.author)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
 
it do
note.update_attribute(:note, '@mention referenced')
should_email(@u_committer.id, note)
should_email(@u_watcher.id, note)
should_email(@u_mentioned.id, note)
should_not_email(note.author_id, note)
should_not_email(@u_participating.id, note)
should_not_email(@u_disabled.id, note)
notification.new_note(note)
should_email(@u_committer)
should_email(@u_watcher)
should_email(@u_mentioned)
should_not_email(note.author)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
 
it do
@u_committer.update_attributes(notification_level: Notification::N_MENTION)
should_not_email(@u_committer.id, note)
notification.new_note(note)
end
def should_email(user_id, n)
expect(Notify).to receive(:note_commit_email).with(user_id, n.id)
end
def should_not_email(user_id, n)
expect(Notify).not_to receive(:note_commit_email).with(user_id, n.id)
should_not_email(@u_committer)
end
end
end
Loading
Loading
@@ -205,99 +194,69 @@ describe NotificationService do
before do
build_team(issue.project)
add_users_with_subscription(issue.project, issue)
ActionMailer::Base.deliveries.clear
end
 
describe :new_issue do
it do
should_email(issue.assignee_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_not_email(@u_mentioned.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.new_issue(issue, @u_disabled)
should_email(issue.assignee)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_not_email(@u_mentioned)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
 
it do
issue.assignee.update_attributes(notification_level: Notification::N_MENTION)
should_not_email(issue.assignee_id)
notification.new_issue(issue, @u_disabled)
end
def should_email(user_id)
expect(Notify).to receive(:new_issue_email).with(user_id, issue.id)
end
 
def should_not_email(user_id)
expect(Notify).not_to receive(:new_issue_email).with(user_id, issue.id)
should_not_email(issue.assignee)
end
end
 
describe :reassigned_issue do
it 'should email new assignee' do
should_email(issue.assignee_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_email(@subscriber.id)
should_not_email(@unsubscriber.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.reassigned_issue(issue, @u_disabled)
end
def should_email(user_id)
expect(Notify).to receive(:reassigned_issue_email).with(user_id, issue.id, nil, @u_disabled.id)
end
 
def should_not_email(user_id)
expect(Notify).not_to receive(:reassigned_issue_email).with(user_id, issue.id, issue.assignee_id, @u_disabled.id)
should_email(issue.assignee)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
end
 
describe :close_issue do
it 'should sent email to issue assignee and issue author' do
should_email(issue.assignee_id)
should_email(issue.author_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_email(@subscriber.id)
should_not_email(@unsubscriber.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.close_issue(issue, @u_disabled)
end
 
def should_email(user_id)
expect(Notify).to receive(:closed_issue_email).with(user_id, issue.id, @u_disabled.id)
end
def should_not_email(user_id)
expect(Notify).not_to receive(:closed_issue_email).with(user_id, issue.id, @u_disabled.id)
should_email(issue.assignee)
should_email(issue.author)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
end
 
describe :reopen_issue do
it 'should send email to issue assignee and issue author' do
should_email(issue.assignee_id)
should_email(issue.author_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_email(@subscriber.id)
should_not_email(@unsubscriber.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.reopen_issue(issue, @u_disabled)
end
def should_email(user_id)
expect(Notify).to receive(:issue_status_changed_email).with(user_id, issue.id, 'reopened', @u_disabled.id)
end
 
def should_not_email(user_id)
expect(Notify).not_to receive(:issue_status_changed_email).with(user_id, issue.id, 'reopened', @u_disabled.id)
should_email(issue.assignee)
should_email(issue.author)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
end
end
end
Loading
Loading
@@ -309,108 +268,74 @@ describe NotificationService do
before do
build_team(merge_request.target_project)
add_users_with_subscription(merge_request.target_project, merge_request)
ActionMailer::Base.deliveries.clear
end
 
describe :new_merge_request do
it do
should_email(merge_request.assignee_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.new_merge_request(merge_request, @u_disabled)
end
 
def should_email(user_id)
expect(Notify).to receive(:new_merge_request_email).with(user_id, merge_request.id)
end
def should_not_email(user_id)
expect(Notify).not_to receive(:new_merge_request_email).with(user_id, merge_request.id)
should_email(merge_request.assignee)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
end
 
describe :reassigned_merge_request do
it do
should_email(merge_request.assignee_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_email(@subscriber.id)
should_not_email(@unsubscriber.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.reassigned_merge_request(merge_request, merge_request.author)
end
def should_email(user_id)
expect(Notify).to receive(:reassigned_merge_request_email).with(user_id, merge_request.id, nil, merge_request.author_id)
end
 
def should_not_email(user_id)
expect(Notify).not_to receive(:reassigned_merge_request_email).with(user_id, merge_request.id, merge_request.assignee_id, merge_request.author_id)
should_email(merge_request.assignee)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
end
 
describe :closed_merge_request do
it do
should_email(merge_request.assignee_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_email(@subscriber.id)
should_not_email(@unsubscriber.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.close_mr(merge_request, @u_disabled)
end
def should_email(user_id)
expect(Notify).to receive(:closed_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
end
 
def should_not_email(user_id)
expect(Notify).not_to receive(:closed_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
should_email(merge_request.assignee)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
end
 
describe :merged_merge_request do
it do
should_email(merge_request.assignee_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_email(@subscriber.id)
should_not_email(@unsubscriber.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.merge_mr(merge_request, @u_disabled)
end
def should_email(user_id)
expect(Notify).to receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
end
 
def should_not_email(user_id)
expect(Notify).not_to receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
should_email(merge_request.assignee)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
end
 
describe :reopen_merge_request do
it do
should_email(merge_request.assignee_id)
should_email(@u_watcher.id)
should_email(@u_participant_mentioned.id)
should_email(@subscriber.id)
should_not_email(@unsubscriber.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.reopen_mr(merge_request, @u_disabled)
end
 
def should_email(user_id)
expect(Notify).to receive(:merge_request_status_email).with(user_id, merge_request.id, 'reopened', @u_disabled.id)
end
def should_not_email(user_id)
expect(Notify).not_to receive(:merge_request_status_email).with(user_id, merge_request.id, 'reopened', @u_disabled.id)
should_email(merge_request.assignee)
should_email(@u_watcher)
should_email(@u_participant_mentioned)
should_email(@subscriber)
should_not_email(@unsubscriber)
should_not_email(@u_participating)
should_not_email(@u_disabled)
end
end
end
Loading
Loading
@@ -420,22 +345,16 @@ describe NotificationService do
 
before do
build_team(project)
ActionMailer::Base.deliveries.clear
end
 
describe :project_was_moved do
it do
should_email(@u_watcher.id)
should_email(@u_participating.id)
should_not_email(@u_disabled.id)
notification.project_was_moved(project, "gitlab/gitlab")
end
def should_email(user_id)
expect(Notify).to receive(:project_was_moved_email).with(project.id, user_id, "gitlab/gitlab")
end
 
def should_not_email(user_id)
expect(Notify).not_to receive(:project_was_moved_email).with(project.id, user_id, "gitlab/gitlab")
should_email(@u_watcher)
should_email(@u_participating)
should_not_email(@u_disabled)
end
end
end
Loading
Loading
@@ -469,4 +388,18 @@ describe NotificationService do
issuable.subscriptions.create(user: @subscriber, subscribed: true)
issuable.subscriptions.create(user: @unsubscriber, subscribed: false)
end
def sent_to_user?(user)
ActionMailer::Base.deliveries.any? do |message|
message.to.include?(user.email)
end
end
def should_email(user)
expect(sent_to_user?(user)).to be_truthy
end
def should_not_email(user)
expect(sent_to_user?(user)).to be_falsey
end
end
Loading
Loading
@@ -31,6 +31,7 @@ RSpec.configure do |config|
config.include StubConfiguration
config.include RelativeUrl, type: feature
config.include TestEnv
config.include ActiveJob::TestHelper
config.include StubGitlabCalls
config.include StubGitlabData
config.include BenchmarkMatchers, benchmark: true
Loading
Loading
Loading
Loading
@@ -21,12 +21,14 @@ describe EmailReceiverWorker do
end
 
it "sends out a rejection email" do
described_class.new.perform(raw_message)
email = ActionMailer::Base.deliveries.last
expect(email).not_to be_nil
expect(email.to).to eq(["jake@adventuretime.ooo"])
expect(email.subject).to include("Rejected")
perform_enqueued_jobs do
described_class.new.perform(raw_message)
email = ActionMailer::Base.deliveries.last
expect(email).not_to be_nil
expect(email.to).to eq(["jake@adventuretime.ooo"])
expect(email.subject).to include("Rejected")
end
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment