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
8cc14dd5
Commit
8cc14dd5
authored
Jan 04, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Project#cache_index to jobs_cache_index
parent
7d7d289b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
13 deletions
+13
-13
app/models/ci/build.rb
app/models/ci/build.rb
+2
-2
app/services/reset_project_cache_service.rb
app/services/reset_project_cache_service.rb
+1
-1
db/migrate/20171222183504_add_jobs_cache_index_to_project.rb
db/migrate/20171222183504_add_jobs_cache_index_to_project.rb
+1
-1
db/schema.rb
db/schema.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+4
-4
spec/services/reset_project_cache_service_spec.rb
spec/services/reset_project_cache_service_spec.rb
+4
-4
No files found.
app/models/ci/build.rb
View file @
8cc14dd5
...
...
@@ -461,8 +461,8 @@ module Ci
end
def
cache
if
options
[
:cache
]
&&
project
.
cache_index
options
[
:cache
].
merge
(
key:
"
#{
options
[
:cache
][
:key
]
}
:
#{
project
.
cache_index
}
"
)
if
options
[
:cache
]
&&
project
.
jobs_
cache_index
options
[
:cache
].
merge
(
key:
"
#{
options
[
:cache
][
:key
]
}
:
#{
project
.
jobs_
cache_index
}
"
)
else
[
options
[
:cache
]]
end
...
...
app/services/reset_project_cache_service.rb
View file @
8cc14dd5
class
ResetProjectCacheService
<
BaseService
def
execute
@project
.
increment!
(
:cache_index
)
@project
.
increment!
(
:
jobs_
cache_index
)
end
end
db/migrate/20171222183504_add_cache_index_to_project.rb
→
db/migrate/20171222183504_add_
jobs_
cache_index_to_project.rb
View file @
8cc14dd5
...
...
@@ -8,6 +8,6 @@ class AddCacheIndexToProject < ActiveRecord::Migration
DOWNTIME
=
false
def
change
add_column
:projects
,
:cache_index
,
:integer
add_column
:projects
,
:
jobs_
cache_index
,
:integer
end
end
db/schema.rb
View file @
8cc14dd5
...
...
@@ -1447,7 +1447,7 @@ ActiveRecord::Schema.define(version: 20171222183504) do
t
.
boolean
"repository_read_only"
t
.
boolean
"merge_requests_ff_only_enabled"
,
default:
false
t
.
boolean
"merge_requests_rebase_enabled"
,
default:
false
,
null:
false
t
.
integer
"cache_index"
t
.
integer
"
jobs_
cache_index"
end
add_index
"projects"
,
[
"ci_id"
],
name:
"index_projects_on_ci_id"
,
using: :btree
...
...
spec/models/ci/build_spec.rb
View file @
8cc14dd5
...
...
@@ -265,17 +265,17 @@ describe Ci::Build do
allow
(
build
).
to
receive
(
:options
).
and_return
(
options
)
end
context
'when project has cache_index'
do
context
'when project has
jobs_
cache_index'
do
before
do
allow_any_instance_of
(
Project
).
to
receive
(
:cache_index
).
and_return
(
1
)
allow_any_instance_of
(
Project
).
to
receive
(
:
jobs_
cache_index
).
and_return
(
1
)
end
it
{
is_expected
.
to
include
(
key:
"key:1"
)
}
end
context
'when project does not have cache_index'
do
context
'when project does not have
jobs_
cache_index'
do
before
do
allow_any_instance_of
(
Project
).
to
receive
(
:cache_index
).
and_return
(
nil
)
allow_any_instance_of
(
Project
).
to
receive
(
:
jobs_
cache_index
).
and_return
(
nil
)
end
it
{
is_expected
.
to
eq
([
options
[
:cache
]])
}
...
...
spec/services/reset_project_cache_service_spec.rb
View file @
8cc14dd5
...
...
@@ -8,21 +8,21 @@ describe ResetProjectCacheService do
context
'when project cache_index is nil'
do
before
do
project
.
cache_index
=
nil
project
.
jobs_
cache_index
=
nil
end
it
'sets project cache_index to one'
do
expect
{
subject
}.
to
change
{
project
.
reload
.
cache_index
}.
from
(
nil
).
to
(
1
)
expect
{
subject
}.
to
change
{
project
.
reload
.
jobs_
cache_index
}.
from
(
nil
).
to
(
1
)
end
end
context
'when project cache_index is a numeric value'
do
before
do
project
.
update_attributes
(
cache_index:
1
)
project
.
update_attributes
(
jobs_
cache_index:
1
)
end
it
'increments project cache index'
do
expect
{
subject
}.
to
change
{
project
.
reload
.
cache_index
}.
by
(
1
)
expect
{
subject
}.
to
change
{
project
.
reload
.
jobs_
cache_index
}.
by
(
1
)
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