Skip to content

Commit e92ceb7

Browse files
committed
fix specs
1 parent 461731f commit e92ceb7

File tree

17 files changed

+73
-81
lines changed

17 files changed

+73
-81
lines changed

Gemfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ GEM
332332
github-markup (~> 1.3.3)
333333
gollum-grit_adapter (~> 1.0)
334334
nokogiri (~> 1.6.4)
335-
rouge (~> 1.7.4)
335+
rouge (~> 1.10.1)
336336
sanitize (~> 2.1.0)
337337
stringex (~> 2.5.1)
338338
gon (6.0.1)
@@ -610,7 +610,7 @@ GEM
610610
netrc (~> 0.7)
611611
rinku (1.7.3)
612612
rotp (2.1.1)
613-
rouge (1.7.7)
613+
rouge (1.10.1)
614614
rqrcode (0.7.0)
615615
chunky_png
616616
rqrcode-rails3 (0.1.7)

app/controllers/abuse_reports_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def create
1010

1111
if @abuse_report.save
1212
if current_application_settings.admin_notification_email.present?
13-
AbuseReportMailer.deliver_later.notify(@abuse_report.id)
13+
AbuseReportMailer.notify(@abuse_report.id).deliver_later
1414
end
1515

1616
message = "Thank you for your report. A GitLab administrator will look into it shortly."

app/models/project_services/ci/mail_service.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def execute(build)
6464
build.project_recipients.each do |recipient|
6565
case build.status.to_sym
6666
when :success
67-
mailer.build_success_email(build.id, recipient)
67+
mailer.build_success_email(build.id, recipient).deliver_later
6868
when :failed
69-
mailer.build_fail_email(build.id, recipient)
69+
mailer.build_fail_email(build.id, recipient).deliver_later
7070
end
7171
end
7272
end
@@ -78,7 +78,7 @@ def update_project
7878
end
7979

8080
def mailer
81-
Ci::Notify.deliver_later
81+
Ci::Notify
8282
end
8383
end
8484
end

app/views/ci/admin/runners/show.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
= label_tag :tag_list, class: 'control-label' do
3838
Tags
3939
.col-sm-10
40-
= f.text_field :tag_list, class: 'form-control'
40+
= f.text_field :tag_list, value: @runner.tag_list.to_s, class: 'form-control'
4141
.help-block You can setup builds to only use runners with specific tags
4242
.form-actions
4343
= f.submit 'Save', class: 'btn btn-save'

app/views/ci/notify/build_success_email.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
= @project.name
99
1010
%p
11-
Commit: #{link_to @build.short_sha, namespace_project_commit_path(@build.gl_project.namespace, @build.gl_project, @build.sha)}
11+
Commit: #{link_to @build.short_sha, namespace_project_commit_url(@build.gl_project.namespace, @build.gl_project, @build.sha)}
1212
%p
1313
Author: #{@build.commit.git_author_name}
1414
%p

app/views/projects/edit.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
.form-group
3636
= f.label :tag_list, "Tags", class: 'control-label'
3737
.col-sm-10
38-
= f.text_field :tag_list, maxlength: 2000, class: "form-control"
38+
= f.text_field :tag_list, value: @project.tag_list.to_s, maxlength: 2000, class: "form-control"
3939
%p.help-block Separate tags with commas.
4040

4141
%fieldset.features

app/views/projects/runners/edit.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
= label_tag :tag_list, class: 'control-label' do
2424
Tags
2525
.col-sm-10
26-
= f.text_field :tag_list, class: 'form-control'
26+
= f.text_field :tag_list, value: @runner.tag_list.to_s, class: 'form-control'
2727
.help-block You can setup jobs to only use runners with specific tags
2828
.form-actions
2929
= f.submit 'Save', class: 'btn btn-save'

app/workers/email_receiver_worker.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ def handle_failure(raw, e)
4646
return
4747
end
4848

49-
EmailRejectionMailer.deliver_later.rejection(reason, raw, can_retry)
49+
EmailRejectionMailer.rejection(reason, raw, can_retry).deliver_later
5050
end
5151
end

lib/gitlab/github_import/client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def config
4646
end
4747

4848
def github_options
49-
OmniAuth::Strategies::GitHub.default_options[:client_options].symbolize_keys
49+
OmniAuth::Strategies::GitHub.default_options[:client_options].to_h.symbolize_keys
5050
end
5151
end
5252
end

lib/gitlab/gitlab_import/client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def config
7575
end
7676

7777
def gitlab_options
78-
OmniAuth::Strategies::GitLab.default_options[:client_options].symbolize_keys
78+
OmniAuth::Strategies::GitLab.default_options[:client_options].to_h.symbolize_keys
7979
end
8080
end
8181
end

spec/controllers/abuse_reports_controller_spec.rb

+20-16
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,31 @@
1818
end
1919

2020
it "sends a notification email" do
21-
post :create,
22-
abuse_report: {
23-
user_id: user.id,
24-
message: message
25-
}
26-
27-
email = ActionMailer::Base.deliveries.last
28-
29-
expect(email.to).to eq([admin_email])
30-
expect(email.subject).to include(user.username)
31-
expect(email.text_part.body).to include(message)
32-
end
33-
34-
it "saves the abuse report" do
35-
expect do
21+
perform_enqueued_jobs do
3622
post :create,
3723
abuse_report: {
3824
user_id: user.id,
3925
message: message
4026
}
41-
end.to change { AbuseReport.count }.by(1)
27+
28+
email = ActionMailer::Base.deliveries.last
29+
30+
expect(email.to).to eq([admin_email])
31+
expect(email.subject).to include(user.username)
32+
expect(email.text_part.body).to include(message)
33+
end
34+
end
35+
36+
it "saves the abuse report" do
37+
perform_enqueued_jobs do
38+
expect do
39+
post :create,
40+
abuse_report: {
41+
user_id: user.id,
42+
message: message
43+
}
44+
end.to change { AbuseReport.count }.by(1)
45+
end
4246
end
4347
end
4448

spec/features/admin/admin_users_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
end
8888

8989
it "should call send mail" do
90-
expect(Notify).to receive(:new_user_email)
90+
expect_any_instance_of(NotificationService).to receive(:new_user)
9191

9292
click_button "Create user"
9393
end

spec/helpers/application_helper_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def stub_action_name(value)
5959

6060
avatar_url = "http://localhost/uploads/project/avatar/#{project.id}/banana_sample.gif"
6161
expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s).
62-
to eq "<img alt=\"Banana sample\" src=\"#{avatar_url}\" />"
62+
to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />"
6363
end
6464

6565
it 'should give uploaded icon when present' do

spec/lib/gitlab/markdown/label_reference_filter_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module Gitlab::Markdown
7171
doc = filter("See #{reference}")
7272

7373
expect(doc.css('a').first.attr('href')).to eq urls.
74-
namespace_project_issues_url(project.namespace, project, label_name: label.name)
74+
namespace_project_issues_path(project.namespace, project, label_name: label.name)
7575
end
7676

7777
it 'links with adjacent text' do
@@ -94,7 +94,7 @@ module Gitlab::Markdown
9494
doc = filter("See #{reference}")
9595

9696
expect(doc.css('a').first.attr('href')).to eq urls.
97-
namespace_project_issues_url(project.namespace, project, label_name: label.name)
97+
namespace_project_issues_path(project.namespace, project, label_name: label.name)
9898
expect(doc.text).to eq 'See gfm'
9999
end
100100

@@ -118,7 +118,7 @@ module Gitlab::Markdown
118118
doc = filter("See #{reference}")
119119

120120
expect(doc.css('a').first.attr('href')).to eq urls.
121-
namespace_project_issues_url(project.namespace, project, label_name: label.name)
121+
namespace_project_issues_path(project.namespace, project, label_name: label.name)
122122
expect(doc.text).to eq 'See gfm references'
123123
end
124124

spec/models/ci/project_services/mail_service_spec.rb

+24-38
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,10 @@
4444
end
4545

4646
it do
47-
should_email("[email protected]")
48-
mail.execute(build)
49-
end
50-
51-
def should_email(email)
52-
expect(Ci::Notify).to receive(:build_fail_email).with(build.id, email)
53-
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
47+
perform_enqueued_jobs do
48+
expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
49+
expect(ActionMailer::Base.deliveries.last.to).to eq(["[email protected]"])
50+
end
5451
end
5552
end
5653

@@ -67,13 +64,10 @@ def should_email(email)
6764
end
6865

6966
it do
70-
should_email("[email protected]")
71-
mail.execute(build)
72-
end
73-
74-
def should_email(email)
75-
expect(Ci::Notify).to receive(:build_success_email).with(build.id, email)
76-
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
67+
perform_enqueued_jobs do
68+
expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
69+
expect(ActionMailer::Base.deliveries.last.to).to eq(["[email protected]"])
70+
end
7771
end
7872
end
7973

@@ -95,14 +89,12 @@ def should_email(email)
9589
end
9690

9791
it do
98-
should_email("[email protected]")
99-
should_email("[email protected]")
100-
mail.execute(build)
101-
end
102-
103-
def should_email(email)
104-
expect(Ci::Notify).to receive(:build_success_email).with(build.id, email)
105-
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
92+
perform_enqueued_jobs do
93+
expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(2)
94+
expect(
95+
ActionMailer::Base.deliveries.map(&:to).flatten
96+
97+
end
10698
end
10799
end
108100

@@ -124,14 +116,11 @@ def should_email(email)
124116
end
125117

126118
it do
127-
should_email(commit.git_author_email)
128-
should_email("[email protected]")
129-
mail.execute(build) if mail.can_execute?(build)
130-
end
131-
132-
def should_email(email)
133-
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
134-
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
119+
perform_enqueued_jobs do
120+
expect do
121+
mail.execute(build) if mail.can_execute?(build)
122+
end.to_not change{ ActionMailer::Base.deliveries.size }
123+
end
135124
end
136125
end
137126

@@ -177,14 +166,11 @@ def should_email(email)
177166

178167
it do
179168
Ci::Build.retry(build)
180-
should_email(commit.git_author_email)
181-
should_email("[email protected]")
182-
mail.execute(build) if mail.can_execute?(build)
183-
end
184-
185-
def should_email(email)
186-
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
187-
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
169+
perform_enqueued_jobs do
170+
expect do
171+
mail.execute(build) if mail.can_execute?(build)
172+
end.to_not change{ ActionMailer::Base.deliveries.size }
173+
end
188174
end
189175
end
190176
end

spec/models/project_services/jira_service_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@
9494
end
9595

9696
it 'should be prepopulated with the settings' do
97-
expect(@service.properties[:project_url]).to eq('http://jira.sample/projects/project_a')
98-
expect(@service.properties[:issues_url]).to eq("http://jira.sample/issues/:id")
99-
expect(@service.properties[:new_issue_url]).to eq("http://jira.sample/projects/project_a/issues/new")
97+
expect(@service.properties["project_url"]).to eq('http://jira.sample/projects/project_a')
98+
expect(@service.properties["issues_url"]).to eq("http://jira.sample/issues/:id")
99+
expect(@service.properties["new_issue_url"]).to eq("http://jira.sample/projects/project_a/issues/new")
100100
end
101101
end
102102
end

spec/workers/email_receiver_worker_spec.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
end
2222

2323
it "sends out a rejection email" do
24-
described_class.new.perform(raw_message)
25-
26-
email = ActionMailer::Base.deliveries.last
27-
expect(email).not_to be_nil
28-
expect(email.to).to eq(["[email protected]"])
29-
expect(email.subject).to include("Rejected")
24+
perform_enqueued_jobs do
25+
described_class.new.perform(raw_message)
26+
27+
email = ActionMailer::Base.deliveries.last
28+
expect(email).not_to be_nil
29+
expect(email.to).to eq(["[email protected]"])
30+
expect(email.subject).to include("Rejected")
31+
end
3032
end
3133
end
3234
end

0 commit comments

Comments
 (0)