Commit 8b02d962 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not require authentication for CI status badge

This changes only deprecated CI badge that we keep for backwards
compatibility. See !3030#note_4041498.
parent 6be22dbb
...@@ -19,7 +19,6 @@ module Ci ...@@ -19,7 +19,6 @@ module Ci
# #
def badge def badge
return render_404 unless @project return render_404 unless @project
authenticate_user! unless @project.public?
image = Ci::ImageForBuildService.new.execute(@project, params) image = Ci::ImageForBuildService.new.execute(@project, params)
send_file image.path, filename: image.name, disposition: 'inline', type:"image/svg+xml" send_file image.path, filename: image.name, disposition: 'inline', type:"image/svg+xml"
......
...@@ -9,6 +9,14 @@ describe Ci::ProjectsController do ...@@ -9,6 +9,14 @@ describe Ci::ProjectsController do
# Specs for *deprecated* CI badge # Specs for *deprecated* CI badge
# #
describe '#badge' do describe '#badge' do
shared_examples 'badge provider' do
it 'shows badge' do
expect(response.status).to eq 200
expect(response.headers)
.to include('Content-Type' => 'image/svg+xml')
end
end
context 'user not signed in' do context 'user not signed in' do
before { get(:badge, id: ci_id) } before { get(:badge, id: ci_id) }
...@@ -22,18 +30,12 @@ describe Ci::ProjectsController do ...@@ -22,18 +30,12 @@ describe Ci::ProjectsController do
context 'project is public' do context 'project is public' do
let(:visibility) { :public } let(:visibility) { :public }
it_behaves_like 'badge provider'
it 'is available without authentication' do
expect(response.status).to eq 200
end
end end
context 'project is private' do context 'project is private' do
let(:visibility) { :private } let(:visibility) { :private }
it_behaves_like 'badge provider'
it 'requires authentication' do
expect(response.status).to eq 302
end
end end
end end
...@@ -44,10 +46,7 @@ describe Ci::ProjectsController do ...@@ -44,10 +46,7 @@ describe Ci::ProjectsController do
context 'private is internal' do context 'private is internal' do
let(:visibility) { :internal } let(:visibility) { :internal }
it_behaves_like 'badge provider'
it 'shows badge to signed in user' do
expect(response.status).to eq 200
end
end end
end end
end end
......
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