diff options
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/services/reset_project_cache_service.rb | 2 | ||||
-rw-r--r-- | db/migrate/20171222183504_add_jobs_cache_index_to_project.rb (renamed from db/migrate/20171222183504_add_cache_index_to_project.rb) | 2 | ||||
-rw-r--r-- | db/schema.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 8 | ||||
-rw-r--r-- | spec/services/reset_project_cache_service_spec.rb | 8 |
6 files changed, 13 insertions, 13 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index e4ca74f87f2..ff903a63c54 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -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 diff --git a/app/services/reset_project_cache_service.rb b/app/services/reset_project_cache_service.rb index 0886c6b8315..a162a6eedb9 100644 --- a/app/services/reset_project_cache_service.rb +++ b/app/services/reset_project_cache_service.rb @@ -1,5 +1,5 @@ class ResetProjectCacheService < BaseService def execute - @project.increment!(:cache_index) + @project.increment!(:jobs_cache_index) end end diff --git a/db/migrate/20171222183504_add_cache_index_to_project.rb b/db/migrate/20171222183504_add_jobs_cache_index_to_project.rb index e1d73db1ab0..58ac0177420 100644 --- a/db/migrate/20171222183504_add_cache_index_to_project.rb +++ b/db/migrate/20171222183504_add_jobs_cache_index_to_project.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index b7512f293a6..cd3f87062ab 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 96513281994..8cecaf16fdf 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -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]]) } diff --git a/spec/services/reset_project_cache_service_spec.rb b/spec/services/reset_project_cache_service_spec.rb index df969d08f39..de475d16586 100644 --- a/spec/services/reset_project_cache_service_spec.rb +++ b/spec/services/reset_project_cache_service_spec.rb @@ -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 |