fix specs

This commit is contained in:
Valery Sizov 2015-11-30 16:12:31 +02:00
parent 461731f076
commit e92ceb7b57
17 changed files with 72 additions and 80 deletions

View file

@ -332,7 +332,7 @@ GEM
github-markup (~> 1.3.3)
gollum-grit_adapter (~> 1.0)
nokogiri (~> 1.6.4)
rouge (~> 1.7.4)
rouge (~> 1.10.1)
sanitize (~> 2.1.0)
stringex (~> 2.5.1)
gon (6.0.1)
@ -610,7 +610,7 @@ GEM
netrc (~> 0.7)
rinku (1.7.3)
rotp (2.1.1)
rouge (1.7.7)
rouge (1.10.1)
rqrcode (0.7.0)
chunky_png
rqrcode-rails3 (0.1.7)

View file

@ -10,7 +10,7 @@ class AbuseReportsController < ApplicationController
if @abuse_report.save
if current_application_settings.admin_notification_email.present?
AbuseReportMailer.deliver_later.notify(@abuse_report.id)
AbuseReportMailer.notify(@abuse_report.id).deliver_later
end
message = "Thank you for your report. A GitLab administrator will look into it shortly."

View file

@ -64,9 +64,9 @@ module Ci
build.project_recipients.each do |recipient|
case build.status.to_sym
when :success
mailer.build_success_email(build.id, recipient)
mailer.build_success_email(build.id, recipient).deliver_later
when :failed
mailer.build_fail_email(build.id, recipient)
mailer.build_fail_email(build.id, recipient).deliver_later
end
end
end
@ -78,7 +78,7 @@ module Ci
end
def mailer
Ci::Notify.deliver_later
Ci::Notify
end
end
end

View file

@ -37,7 +37,7 @@
= label_tag :tag_list, class: 'control-label' do
Tags
.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
.form-actions
= f.submit 'Save', class: 'btn btn-save'

View file

@ -8,7 +8,7 @@
= @project.name
%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
Author: #{@build.commit.git_author_name}
%p

View file

@ -35,7 +35,7 @@
.form-group
= f.label :tag_list, "Tags", class: 'control-label'
.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.
%fieldset.features

View file

@ -23,7 +23,7 @@
= label_tag :tag_list, class: 'control-label' do
Tags
.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
.form-actions
= f.submit 'Save', class: 'btn btn-save'

View file

@ -46,6 +46,6 @@ class EmailReceiverWorker
return
end
EmailRejectionMailer.deliver_later.rejection(reason, raw, can_retry)
EmailRejectionMailer.rejection(reason, raw, can_retry).deliver_later
end
end

View file

@ -46,7 +46,7 @@ module Gitlab
end
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

View file

@ -75,7 +75,7 @@ module Gitlab
end
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

View file

@ -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

View file

@ -87,7 +87,7 @@ 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

View file

@ -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

View file

@ -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
@ -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
@ -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

View file

@ -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
@ -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
@ -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
@ -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
@ -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

View file

@ -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

View file

@ -21,12 +21,14 @@ describe EmailReceiverWorker do
end
it "sends out a rejection email" do
described_class.new.perform(raw_message)
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")
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