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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
51d6fab3
Commit
51d6fab3
authored
Oct 28, 2020
by
drew cimino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use some doubles and let_it_be
parent
eb36de62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
20 deletions
+19
-20
spec/lib/gitlab/badge/coverage/report_spec.rb
spec/lib/gitlab/badge/coverage/report_spec.rb
+19
-20
No files found.
spec/lib/gitlab/badge/coverage/report_spec.rb
View file @
51d6fab3
...
...
@@ -3,11 +3,23 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Badge
::
Coverage
::
Report
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:job_name
)
{
nil
}
let
(
:project
)
{
double
(
'project'
)
}
let_it_be
(
:successful_pipeline
)
do
create
(
:ci_pipeline
,
:success
)
end
let
(
:badge
)
do
described_class
.
new
(
project
,
'master'
,
opts:
{
job:
job_name
})
described_class
.
new
(
project
,
'master'
,
opts:
{
job:
job_name
}).
tap
do
|
new_badge
|
allow
(
new_badge
).
to
receive
(
:pipeline
).
and_return
(
successful_pipeline
)
end
end
let
(
:job_name
)
{
nil
}
let
(
:builds
)
{
[]
}
before
do
allow
(
successful_pipeline
).
to
receive
(
:builds
).
and_return
(
Ci
::
Build
.
where
(
id:
builds
.
map
(
&
:id
)))
end
describe
'#entity'
do
...
...
@@ -47,15 +59,11 @@ RSpec.describe Gitlab::Badge::Coverage::Report do
end
context
'when latest successful pipeline exists'
do
before
do
create_pipeline
do
|
pipeline
|
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'first'
,
coverage:
40
)
let
(
:builds
)
do
[
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'first'
,
coverage:
40
)
,
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
coverage:
60
)
end
create_pipeline
do
|
pipeline
|
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
,
coverage:
10
)
end
]
end
context
'when particular job specified'
do
...
...
@@ -78,13 +86,4 @@ RSpec.describe Gitlab::Badge::Coverage::Report do
context
'pipeline does not exist'
do
it_behaves_like
'unknown coverage report'
end
def
create_pipeline
opts
=
{
project:
project
,
sha:
project
.
commit
.
id
,
ref:
'master'
}
create
(
:ci_pipeline
,
opts
).
tap
do
|
pipeline
|
yield
pipeline
::
Ci
::
ProcessPipelineService
.
new
(
pipeline
).
execute
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