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
Léo-Paul Géneau
gitlab-ce
Commits
dfd91389
Commit
dfd91389
authored
Aug 15, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature specs for test coverage badge
parent
b13e1d79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
spec/features/projects/badges/coverage_spec.rb
spec/features/projects/badges/coverage_spec.rb
+73
-0
No files found.
spec/features/projects/badges/coverage_spec.rb
0 → 100644
View file @
dfd91389
require
'spec_helper'
feature
'test coverage badge'
do
given!
(
:user
)
{
create
(
:user
)
}
given!
(
:project
)
{
create
(
:project
,
:private
)
}
given!
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
,
sha:
project
.
commit
.
id
)
end
context
'when user has access to view badge'
do
background
do
project
.
team
<<
[
user
,
:developer
]
login_as
(
user
)
end
scenario
'user requests coverage badge image for pipeline'
do
create_job
(
coverage:
100
,
name:
'test:1'
)
create_job
(
coverage:
90
,
name:
'test:2'
)
show_test_coverage_badge
expect_coverage_badge
(
'95%'
)
end
scenario
'user requests coverage badge for specific job'
do
create_job
(
coverage:
50
,
name:
'test:1'
)
create_job
(
coverage:
50
,
name:
'test:2'
)
create_job
(
coverage:
85
,
name:
'coverage'
)
show_test_coverage_badge
(
job:
'coverage'
)
expect_coverage_badge
(
'85%'
)
end
scenario
'user requests coverage badge for pipeline without coverage'
do
create_job
(
coverage:
nil
,
name:
'test'
)
show_test_coverage_badge
expect_coverage_badge
(
'unknown'
)
end
end
context
'when user does not have access to view badge'
do
background
{
login_as
(
user
)
}
scenario
'user requests test coverage badge image'
do
show_test_coverage_badge
expect
(
page
).
to
have_http_status
(
404
)
end
end
def
create_job
(
coverage
:,
name
:)
create
(
:ci_build
,
name:
name
,
coverage:
coverage
,
pipeline:
pipeline
)
end
def
show_test_coverage_badge
(
job:
nil
)
visit
coverage_namespace_project_badges_path
(
project
.
namespace
,
project
,
ref: :master
,
job:
job
,
format: :svg
)
end
def
expect_coverage_badge
(
coverage
)
svg
=
Nokogiri
::
XML
.
parse
(
page
.
body
)
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
include
(
'image/svg+xml'
)
expect
(
svg
.
at
(
%Q{text:contains("
#{
coverage
}
")}
)).
to
be_truthy
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