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
771b9739
Commit
771b9739
authored
Dec 22, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Project.cache_index in Build#cache
parent
0a002e23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
app/models/ci/build.rb
app/models/ci/build.rb
+5
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+36
-0
No files found.
app/models/ci/build.rb
View file @
771b9739
...
...
@@ -461,7 +461,11 @@ module Ci
end
def
cache
[
options
[
:cache
]]
if
options
[
:cache
]
&&
project
.
cache_index
options
[
:cache
].
merge
(
key:
"
#{
options
[
:cache
][
:key
]
}
:
#{
project
.
cache_index
}
"
)
else
[
options
[
:cache
]]
end
end
def
credentials
...
...
spec/models/ci/build_spec.rb
View file @
771b9739
...
...
@@ -255,6 +255,42 @@ describe Ci::Build do
end
end
describe
'#cache'
do
let
(
:options
)
{
{
cache:
{
key:
"key"
,
paths:
[
"public"
],
policy:
"pull-push"
}
}
}
subject
{
build
.
cache
}
context
'when build has cache'
do
before
do
allow
(
build
).
to
receive
(
:options
).
and_return
(
options
)
end
context
'when project has cache_index'
do
before
do
allow_any_instance_of
(
Project
).
to
receive
(
:cache_index
).
and_return
(
1
)
end
it
{
is_expected
.
to
include
(
key:
"key:1"
)
}
end
context
'when project does not have cache_index'
do
before
do
allow_any_instance_of
(
Project
).
to
receive
(
:cache_index
).
and_return
(
nil
)
end
it
{
is_expected
.
to
eq
([
options
[
:cache
]])
}
end
end
context
'when build does not have cache'
do
before
do
allow
(
build
).
to
receive
(
:options
).
and_return
({})
end
it
{
is_expected
.
to
eq
([
nil
])
}
end
end
describe
'#depends_on_builds'
do
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'build'
,
stage_idx:
0
,
stage:
'build'
)
}
let!
(
:rspec_test
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'rspec'
,
stage_idx:
1
,
stage:
'test'
)
}
...
...
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