Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
6fdbc229
Commit
6fdbc229
authored
Mar 01, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove deprecated legacy CI project status badge
parent
46252628
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
153 deletions
+1
-153
app/controllers/ci/projects_controller.rb
app/controllers/ci/projects_controller.rb
+0
-47
app/services/ci/image_for_build_service.rb
app/services/ci/image_for_build_service.rb
+0
-25
config/routes/ci.rb
config/routes/ci.rb
+1
-7
spec/controllers/ci/projects_controller_spec.rb
spec/controllers/ci/projects_controller_spec.rb
+0
-74
No files found.
app/controllers/ci/projects_controller.rb
deleted
100644 → 0
View file @
46252628
module
Ci
class
ProjectsController
<
::
ApplicationController
before_action
:project
before_action
:no_cache
,
only:
[
:badge
]
before_action
:authorize_read_project!
,
except:
[
:badge
,
:index
]
skip_before_action
:authenticate_user!
,
only:
[
:badge
]
protect_from_forgery
def
index
redirect_to
root_path
end
def
show
# Temporary compatibility with CI badges pointing to CI project page
redirect_to
namespace_project_path
(
project
.
namespace
,
project
)
end
# Project status badge
# Image with build status for sha or ref
#
# This action in DEPRECATED, this is here only for backwards compatibility
# with projects migrated from GitLab CI.
#
def
badge
return
render_404
unless
@project
image
=
Ci
::
ImageForBuildService
.
new
.
execute
(
@project
,
params
)
send_file
image
.
path
,
filename:
image
.
name
,
disposition:
'inline'
,
type:
"image/svg+xml"
end
protected
def
project
@project
||=
Project
.
find_by
(
ci_id:
params
[
:id
].
to_i
)
end
def
no_cache
response
.
headers
[
"Cache-Control"
]
=
"no-cache, no-store, max-age=0, must-revalidate"
response
.
headers
[
"Pragma"
]
=
"no-cache"
response
.
headers
[
"Expires"
]
=
"Fri, 01 Jan 1990 00:00:00 GMT"
end
def
authorize_read_project!
return
access_denied!
unless
can?
(
current_user
,
:read_project
,
project
)
end
end
end
app/services/ci/image_for_build_service.rb
deleted
100644 → 0
View file @
46252628
module
Ci
class
ImageForBuildService
def
execute
(
project
,
opts
)
ref
=
opts
[
:ref
]
sha
=
opts
[
:sha
]
||
ref_sha
(
project
,
ref
)
pipelines
=
project
.
pipelines
.
where
(
sha:
sha
)
image_name
=
image_for_status
(
pipelines
.
latest_status
(
ref
))
image_path
=
Rails
.
root
.
join
(
'public/ci'
,
image_name
)
OpenStruct
.
new
(
path:
image_path
,
name:
image_name
)
end
private
def
ref_sha
(
project
,
ref
)
project
.
commit
(
ref
).
try
(
:sha
)
if
ref
end
def
image_for_status
(
status
)
status
||=
'unknown'
'build-'
+
status
+
".svg"
end
end
end
config/routes/ci.rb
View file @
6fdbc229
...
...
@@ -5,11 +5,5 @@ namespace :ci do
resource
:lint
,
only:
[
:show
,
:create
]
resources
:projects
,
only:
[
:index
,
:show
]
do
member
do
get
:status
,
to:
'projects#badge'
end
end
root
to:
'projects#index'
root
to:
redirect
(
'/'
)
end
spec/controllers/ci/projects_controller_spec.rb
deleted
100644 → 0
View file @
46252628
require
'spec_helper'
describe
Ci
::
ProjectsController
do
let
(
:visibility
)
{
:public
}
let!
(
:project
)
{
create
(
:empty_project
,
visibility
,
ci_id:
1
)
}
let
(
:ci_id
)
{
project
.
ci_id
}
describe
'#index'
do
context
'user signed in'
do
before
do
sign_in
(
create
(
:user
))
get
(
:index
)
end
it
'redirects to /'
do
expect
(
response
).
to
redirect_to
(
root_path
)
end
end
context
'user not signed in'
do
before
{
get
(
:index
)
}
it
'redirects to sign in page'
do
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
end
end
end
##
# Specs for *deprecated* CI badge
#
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
before
{
get
(
:badge
,
id:
ci_id
)
}
context
'project has no ci_id reference'
do
let
(
:ci_id
)
{
123
}
it
'returns 404'
do
expect
(
response
.
status
).
to
eq
404
end
end
context
'project is public'
do
let
(
:visibility
)
{
:public
}
it_behaves_like
'badge provider'
end
context
'project is private'
do
let
(
:visibility
)
{
:private
}
it_behaves_like
'badge provider'
end
end
context
'user signed in'
do
let
(
:user
)
{
create
(
:user
)
}
before
{
sign_in
(
user
)
}
before
{
get
(
:badge
,
id:
ci_id
)
}
context
'private is internal'
do
let
(
:visibility
)
{
:internal
}
it_behaves_like
'badge provider'
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment