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
86217866
Commit
86217866
authored
Jan 19, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings argument memoization in CI/CD stage
parent
73fcfb29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
app/models/ci/stage.rb
app/models/ci/stage.rb
+5
-1
spec/models/ci/stage_spec.rb
spec/models/ci/stage_spec.rb
+19
-5
No files found.
app/models/ci/stage.rb
View file @
86217866
...
@@ -46,7 +46,11 @@ module Ci
...
@@ -46,7 +46,11 @@ module Ci
end
end
def
has_warnings?
def
has_warnings?
@warnings
||=
statuses
.
latest
.
failed_but_allowed
.
any?
if
@warnings
.
nil?
statuses
.
latest
.
failed_but_allowed
.
any?
else
@warnings
end
end
end
end
end
end
end
spec/models/ci/stage_spec.rb
View file @
86217866
...
@@ -169,10 +169,22 @@ describe Ci::Stage, models: true do
...
@@ -169,10 +169,22 @@ describe Ci::Stage, models: true do
describe
'#has_warnings?'
do
describe
'#has_warnings?'
do
context
'when stage has warnings'
do
context
'when stage has warnings'
do
context
'when using memoized warnings flag'
do
context
'when using memoized warnings flag'
do
let
(
:stage
)
{
build
(
:ci_stage
,
warnings:
true
)
}
context
'when there are warnings'
do
let
(
:stage
)
{
build
(
:ci_stage
,
warnings:
true
)
}
it
'has warnings'
do
it
'has memoized warnings'
do
expect
(
stage
).
to
have_warnings
expect
(
stage
).
not_to
receive
(
:statuses
)
expect
(
stage
).
to
have_warnings
end
end
context
'when there are no warnings'
do
let
(
:stage
)
{
build
(
:ci_stage
,
warnings:
false
)
}
it
'has memoized warnings'
do
expect
(
stage
).
not_to
receive
(
:statuses
)
expect
(
stage
).
not_to
have_warnings
end
end
end
end
end
...
@@ -182,7 +194,8 @@ describe Ci::Stage, models: true do
...
@@ -182,7 +194,8 @@ describe Ci::Stage, models: true do
stage:
stage_name
,
pipeline:
pipeline
)
stage:
stage_name
,
pipeline:
pipeline
)
end
end
it
'has warnings'
do
it
'has warnings calculated from statuses'
do
expect
(
stage
).
to
receive
(
:statuses
).
and_call_original
expect
(
stage
).
to
have_warnings
expect
(
stage
).
to
have_warnings
end
end
end
end
...
@@ -194,7 +207,8 @@ describe Ci::Stage, models: true do
...
@@ -194,7 +207,8 @@ describe Ci::Stage, models: true do
pipeline:
pipeline
)
pipeline:
pipeline
)
end
end
it
'does not have warnings'
do
it
'does not have warnings calculated from statuses'
do
expect
(
stage
).
to
receive
(
:statuses
).
and_call_original
expect
(
stage
).
not_to
have_warnings
expect
(
stage
).
not_to
have_warnings
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