Commit e92ceb7b authored by Valery Sizov's avatar Valery Sizov

fix specs

parent 461731f0
...@@ -332,7 +332,7 @@ GEM ...@@ -332,7 +332,7 @@ GEM
github-markup (~> 1.3.3) github-markup (~> 1.3.3)
gollum-grit_adapter (~> 1.0) gollum-grit_adapter (~> 1.0)
nokogiri (~> 1.6.4) nokogiri (~> 1.6.4)
rouge (~> 1.7.4) rouge (~> 1.10.1)
sanitize (~> 2.1.0) sanitize (~> 2.1.0)
stringex (~> 2.5.1) stringex (~> 2.5.1)
gon (6.0.1) gon (6.0.1)
...@@ -610,7 +610,7 @@ GEM ...@@ -610,7 +610,7 @@ GEM
netrc (~> 0.7) netrc (~> 0.7)
rinku (1.7.3) rinku (1.7.3)
rotp (2.1.1) rotp (2.1.1)
rouge (1.7.7) rouge (1.10.1)
rqrcode (0.7.0) rqrcode (0.7.0)
chunky_png chunky_png
rqrcode-rails3 (0.1.7) rqrcode-rails3 (0.1.7)
......
...@@ -10,7 +10,7 @@ class AbuseReportsController < ApplicationController ...@@ -10,7 +10,7 @@ class AbuseReportsController < ApplicationController
if @abuse_report.save if @abuse_report.save
if current_application_settings.admin_notification_email.present? if current_application_settings.admin_notification_email.present?
AbuseReportMailer.deliver_later.notify(@abuse_report.id) AbuseReportMailer.notify(@abuse_report.id).deliver_later
end end
message = "Thank you for your report. A GitLab administrator will look into it shortly." message = "Thank you for your report. A GitLab administrator will look into it shortly."
......
...@@ -64,9 +64,9 @@ module Ci ...@@ -64,9 +64,9 @@ module Ci
build.project_recipients.each do |recipient| build.project_recipients.each do |recipient|
case build.status.to_sym case build.status.to_sym
when :success when :success
mailer.build_success_email(build.id, recipient) mailer.build_success_email(build.id, recipient).deliver_later
when :failed when :failed
mailer.build_fail_email(build.id, recipient) mailer.build_fail_email(build.id, recipient).deliver_later
end end
end end
end end
...@@ -78,7 +78,7 @@ module Ci ...@@ -78,7 +78,7 @@ module Ci
end end
def mailer def mailer
Ci::Notify.deliver_later Ci::Notify
end end
end end
end end
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
= label_tag :tag_list, class: 'control-label' do = label_tag :tag_list, class: 'control-label' do
Tags Tags
.col-sm-10 .col-sm-10
= f.text_field :tag_list, class: 'form-control' = f.text_field :tag_list, value: @runner.tag_list.to_s, class: 'form-control'
.help-block You can setup builds to only use runners with specific tags .help-block You can setup builds to only use runners with specific tags
.form-actions .form-actions
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save'
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= @project.name = @project.name
%p %p
Commit: #{link_to @build.short_sha, namespace_project_commit_path(@build.gl_project.namespace, @build.gl_project, @build.sha)} Commit: #{link_to @build.short_sha, namespace_project_commit_url(@build.gl_project.namespace, @build.gl_project, @build.sha)}
%p %p
Author: #{@build.commit.git_author_name} Author: #{@build.commit.git_author_name}
%p %p
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
.form-group .form-group
= f.label :tag_list, "Tags", class: 'control-label' = f.label :tag_list, "Tags", class: 'control-label'
.col-sm-10 .col-sm-10
= f.text_field :tag_list, maxlength: 2000, class: "form-control" = f.text_field :tag_list, value: @project.tag_list.to_s, maxlength: 2000, class: "form-control"
%p.help-block Separate tags with commas. %p.help-block Separate tags with commas.
%fieldset.features %fieldset.features
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
= label_tag :tag_list, class: 'control-label' do = label_tag :tag_list, class: 'control-label' do
Tags Tags
.col-sm-10 .col-sm-10
= f.text_field :tag_list, class: 'form-control' = f.text_field :tag_list, value: @runner.tag_list.to_s, class: 'form-control'
.help-block You can setup jobs to only use runners with specific tags .help-block You can setup jobs to only use runners with specific tags
.form-actions .form-actions
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save'
...@@ -46,6 +46,6 @@ class EmailReceiverWorker ...@@ -46,6 +46,6 @@ class EmailReceiverWorker
return return
end end
EmailRejectionMailer.deliver_later.rejection(reason, raw, can_retry) EmailRejectionMailer.rejection(reason, raw, can_retry).deliver_later
end end
end end
...@@ -46,7 +46,7 @@ module Gitlab ...@@ -46,7 +46,7 @@ module Gitlab
end end
def github_options def github_options
OmniAuth::Strategies::GitHub.default_options[:client_options].symbolize_keys OmniAuth::Strategies::GitHub.default_options[:client_options].to_h.symbolize_keys
end end
end end
end end
......
...@@ -75,7 +75,7 @@ module Gitlab ...@@ -75,7 +75,7 @@ module Gitlab
end end
def gitlab_options def gitlab_options
OmniAuth::Strategies::GitLab.default_options[:client_options].symbolize_keys OmniAuth::Strategies::GitLab.default_options[:client_options].to_h.symbolize_keys
end end
end end
end end
......
...@@ -18,6 +18,7 @@ describe AbuseReportsController do ...@@ -18,6 +18,7 @@ describe AbuseReportsController do
end end
it "sends a notification email" do it "sends a notification email" do
perform_enqueued_jobs do
post :create, post :create,
abuse_report: { abuse_report: {
user_id: user.id, user_id: user.id,
...@@ -30,8 +31,10 @@ describe AbuseReportsController do ...@@ -30,8 +31,10 @@ describe AbuseReportsController do
expect(email.subject).to include(user.username) expect(email.subject).to include(user.username)
expect(email.text_part.body).to include(message) expect(email.text_part.body).to include(message)
end end
end
it "saves the abuse report" do it "saves the abuse report" do
perform_enqueued_jobs do
expect do expect do
post :create, post :create,
abuse_report: { abuse_report: {
...@@ -41,6 +44,7 @@ describe AbuseReportsController do ...@@ -41,6 +44,7 @@ describe AbuseReportsController do
end.to change { AbuseReport.count }.by(1) end.to change { AbuseReport.count }.by(1)
end end
end end
end
context "without admin notification email set" do context "without admin notification email set" do
before(:each) do before(:each) do
......
...@@ -87,7 +87,7 @@ describe "Admin::Users", feature: true do ...@@ -87,7 +87,7 @@ describe "Admin::Users", feature: true do
end end
it "should call send mail" do 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" click_button "Create user"
end end
......
...@@ -59,7 +59,7 @@ describe ApplicationHelper do ...@@ -59,7 +59,7 @@ describe ApplicationHelper do
avatar_url = "http://localhost/uploads/project/avatar/#{project.id}/banana_sample.gif" 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). 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 end
it 'should give uploaded icon when present' do it 'should give uploaded icon when present' do
......
...@@ -71,7 +71,7 @@ module Gitlab::Markdown ...@@ -71,7 +71,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}") doc = filter("See #{reference}")
expect(doc.css('a').first.attr('href')).to eq urls. 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 end
it 'links with adjacent text' do it 'links with adjacent text' do
...@@ -94,7 +94,7 @@ module Gitlab::Markdown ...@@ -94,7 +94,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}") doc = filter("See #{reference}")
expect(doc.css('a').first.attr('href')).to eq urls. 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' expect(doc.text).to eq 'See gfm'
end end
...@@ -118,7 +118,7 @@ module Gitlab::Markdown ...@@ -118,7 +118,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}") doc = filter("See #{reference}")
expect(doc.css('a').first.attr('href')).to eq urls. 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' expect(doc.text).to eq 'See gfm references'
end end
......
...@@ -44,13 +44,10 @@ describe Ci::MailService do ...@@ -44,13 +44,10 @@ describe Ci::MailService do
end end
it do it do
should_email("git@example.com") perform_enqueued_jobs do
mail.execute(build) 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
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)
end end
end end
...@@ -67,13 +64,10 @@ describe Ci::MailService do ...@@ -67,13 +64,10 @@ describe Ci::MailService do
end end
it do it do
should_email("git@example.com") perform_enqueued_jobs do
mail.execute(build) 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
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)
end end
end end
...@@ -95,14 +89,12 @@ describe Ci::MailService do ...@@ -95,14 +89,12 @@ describe Ci::MailService do
end end
it do it do
should_email("git@example.com") perform_enqueued_jobs do
should_email("jeroen@example.com") expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(2)
mail.execute(build) expect(
ActionMailer::Base.deliveries.map(&:to).flatten
).to include("git@example.com", "jeroen@example.com")
end 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)
end end
end end
...@@ -124,14 +116,11 @@ describe Ci::MailService do ...@@ -124,14 +116,11 @@ describe Ci::MailService do
end end
it do it do
should_email(commit.git_author_email) perform_enqueued_jobs do
should_email("jeroen@example.com") expect do
mail.execute(build) if mail.can_execute?(build) mail.execute(build) if mail.can_execute?(build)
end.to_not change{ ActionMailer::Base.deliveries.size }
end 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)
end end
end end
...@@ -177,14 +166,11 @@ describe Ci::MailService do ...@@ -177,14 +166,11 @@ describe Ci::MailService do
it do it do
Ci::Build.retry(build) Ci::Build.retry(build)
should_email(commit.git_author_email) perform_enqueued_jobs do
should_email("jeroen@example.com") expect do
mail.execute(build) if mail.can_execute?(build) mail.execute(build) if mail.can_execute?(build)
end.to_not change{ ActionMailer::Base.deliveries.size }
end 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)
end end
end end
end end
......
...@@ -94,9 +94,9 @@ describe JiraService do ...@@ -94,9 +94,9 @@ describe JiraService do
end end
it 'should be prepopulated with the settings' do it 'should be prepopulated with the settings' do
expect(@service.properties[:project_url]).to eq('http://jira.sample/projects/project_a') 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["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["new_issue_url"]).to eq("http://jira.sample/projects/project_a/issues/new")
end end
end end
end end
......
...@@ -21,6 +21,7 @@ describe EmailReceiverWorker do ...@@ -21,6 +21,7 @@ describe EmailReceiverWorker do
end end
it "sends out a rejection email" do it "sends out a rejection email" do
perform_enqueued_jobs do
described_class.new.perform(raw_message) described_class.new.perform(raw_message)
email = ActionMailer::Base.deliveries.last email = ActionMailer::Base.deliveries.last
...@@ -30,6 +31,7 @@ describe EmailReceiverWorker do ...@@ -30,6 +31,7 @@ describe EmailReceiverWorker do
end end
end end
end end
end
context "when reply by email is disabled" do context "when reply by email is disabled" do
before do before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment