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
a6d31300
Commit
a6d31300
authored
Mar 31, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap updating of cache after pipeline transition in class method
parent
47abf00b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
7 deletions
+21
-7
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-1
lib/gitlab/cache/ci/project_build_status.rb
lib/gitlab/cache/ci/project_build_status.rb
+4
-0
spec/lib/gitlab/cache/ci/project_build_status_spec.rb
spec/lib/gitlab/cache/ci/project_build_status_spec.rb
+14
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+2
-6
No files found.
app/models/ci/pipeline.rb
View file @
a6d31300
...
@@ -393,7 +393,7 @@ module Ci
...
@@ -393,7 +393,7 @@ module Ci
end
end
def
refresh_project_build_status_cache
def
refresh_project_build_status_cache
Gitlab
::
Cache
::
Ci
::
ProjectBuildStatus
.
new
(
project
,
sha:
sha
,
status:
status
).
store_in_cache_if_needed
Gitlab
::
Cache
::
Ci
::
ProjectBuildStatus
.
update_for_pipeline
(
self
)
end
end
private
private
...
...
lib/gitlab/cache/ci/project_build_status.rb
View file @
a6d31300
...
@@ -15,6 +15,10 @@ module Gitlab
...
@@ -15,6 +15,10 @@ module Gitlab
end
end
end
end
def
self
.
update_for_pipeline
(
pipeline
)
new
(
pipeline
.
project
,
sha:
pipeline
.
sha
,
status:
pipeline
.
status
).
store_in_cache_if_needed
end
def
initialize
(
project
,
sha:
nil
,
status:
nil
)
def
initialize
(
project
,
sha:
nil
,
status:
nil
)
@project
=
project
@project
=
project
@sha
=
sha
@sha
=
sha
...
...
spec/lib/gitlab/cache/ci/project_build_status_spec.rb
View file @
a6d31300
...
@@ -12,6 +12,20 @@ describe Gitlab::Cache::Ci::ProjectBuildStatus do
...
@@ -12,6 +12,20 @@ describe Gitlab::Cache::Ci::ProjectBuildStatus do
end
end
end
end
describe
'.update_for_pipeline'
do
it
'refreshes the cache if nescessary'
do
pipeline
=
build_stubbed
(
:ci_pipeline
,
sha:
'123456'
,
status:
'success'
)
fake_status
=
double
expect
(
described_class
).
to
receive
(
:new
).
with
(
pipeline
.
project
,
sha:
'123456'
,
status:
'success'
).
and_return
(
fake_status
)
expect
(
fake_status
).
to
receive
(
:store_in_cache_if_needed
)
described_class
.
update_for_pipeline
(
pipeline
)
end
end
describe
'#has_status?'
do
describe
'#has_status?'
do
it
"is false when the status wasn't loaded yet"
do
it
"is false when the status wasn't loaded yet"
do
expect
(
pipeline_status
.
has_status?
).
to
be_falsy
expect
(
pipeline_status
.
has_status?
).
to
be_falsy
...
...
spec/models/ci/pipeline_spec.rb
View file @
a6d31300
...
@@ -1083,12 +1083,8 @@ describe Ci::Pipeline, models: true do
...
@@ -1083,12 +1083,8 @@ describe Ci::Pipeline, models: true do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
'123456'
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
'123456'
)
}
it
'updates the cached status'
do
it
'updates the cached status'
do
fake_status
=
double
expect
(
Gitlab
::
Cache
::
Ci
::
ProjectBuildStatus
).
to
receive
(
:update_for_pipeline
).
expect
(
Gitlab
::
Cache
::
Ci
::
ProjectBuildStatus
).
to
receive
(
:new
).
with
(
pipeline
)
with
(
pipeline
.
project
,
sha:
'123456'
,
status:
'manual'
).
and_return
(
fake_status
)
expect
(
fake_status
).
to
receive
(
:store_in_cache_if_needed
)
pipeline
.
block
pipeline
.
block
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