Commit 8cc14dd5 authored by Matija Čupić's avatar Matija Čupić

Rename Project#cache_index to jobs_cache_index

parent 7d7d289b
...@@ -461,8 +461,8 @@ module Ci ...@@ -461,8 +461,8 @@ module Ci
end end
def cache def cache
if options[:cache] && project.cache_index if options[:cache] && project.jobs_cache_index
options[:cache].merge(key: "#{options[:cache][:key]}:#{project.cache_index}") options[:cache].merge(key: "#{options[:cache][:key]}:#{project.jobs_cache_index}")
else else
[options[:cache]] [options[:cache]]
end end
......
class ResetProjectCacheService < BaseService class ResetProjectCacheService < BaseService
def execute def execute
@project.increment!(:cache_index) @project.increment!(:jobs_cache_index)
end end
end end
...@@ -8,6 +8,6 @@ class AddCacheIndexToProject < ActiveRecord::Migration ...@@ -8,6 +8,6 @@ class AddCacheIndexToProject < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
def change def change
add_column :projects, :cache_index, :integer add_column :projects, :jobs_cache_index, :integer
end end
end end
...@@ -1447,7 +1447,7 @@ ActiveRecord::Schema.define(version: 20171222183504) do ...@@ -1447,7 +1447,7 @@ ActiveRecord::Schema.define(version: 20171222183504) do
t.boolean "repository_read_only" t.boolean "repository_read_only"
t.boolean "merge_requests_ff_only_enabled", default: false t.boolean "merge_requests_ff_only_enabled", default: false
t.boolean "merge_requests_rebase_enabled", default: false, null: false t.boolean "merge_requests_rebase_enabled", default: false, null: false
t.integer "cache_index" t.integer "jobs_cache_index"
end end
add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree
......
...@@ -265,17 +265,17 @@ describe Ci::Build do ...@@ -265,17 +265,17 @@ describe Ci::Build do
allow(build).to receive(:options).and_return(options) allow(build).to receive(:options).and_return(options)
end end
context 'when project has cache_index' do context 'when project has jobs_cache_index' do
before 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 end
it { is_expected.to include(key: "key:1") } it { is_expected.to include(key: "key:1") }
end end
context 'when project does not have cache_index' do context 'when project does not have jobs_cache_index' do
before 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 end
it { is_expected.to eq([options[:cache]]) } it { is_expected.to eq([options[:cache]]) }
......
...@@ -8,21 +8,21 @@ describe ResetProjectCacheService do ...@@ -8,21 +8,21 @@ describe ResetProjectCacheService do
context 'when project cache_index is nil' do context 'when project cache_index is nil' do
before do before do
project.cache_index = nil project.jobs_cache_index = nil
end end
it 'sets project cache_index to one' do 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
end end
context 'when project cache_index is a numeric value' do context 'when project cache_index is a numeric value' do
before do before do
project.update_attributes(cache_index: 1) project.update_attributes(jobs_cache_index: 1)
end end
it 'increments project cache index' do 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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment