diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-04-09 15:41:55 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-04-10 15:57:00 +0300 |
commit | 4b30aec0aa9e52d3d7d4394f05a725d14e0c0db3 (patch) | |
tree | 7fc3713103151a70d08404fa0b48a49b25dfa026 /spec | |
parent | de36ca81d35992c265cd4fd09c774cb793dbd246 (diff) |
Allow `rake cache:clear` clearing pipeline status cache
* Use the correct key prefix
* Clear old cache keys
TODO:
At some point we could remove clearing old cache keys.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb | 2 | ||||
-rw-r--r-- | spec/tasks/cache/clear/redis_spec.rb | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb index 16704ff5e77..18658588a40 100644 --- a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb +++ b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do let!(:project) { create(:project, :repository) } let(:pipeline_status) { described_class.new(project) } - let(:cache_key) { "projects/#{project.id}/pipeline_status" } + let(:cache_key) { described_class.cache_key_for_project(project) } describe '.load_for_project' do it "loads the status" do diff --git a/spec/tasks/cache/clear/redis_spec.rb b/spec/tasks/cache/clear/redis_spec.rb new file mode 100644 index 00000000000..cca2b864e9b --- /dev/null +++ b/spec/tasks/cache/clear/redis_spec.rb @@ -0,0 +1,19 @@ +require 'rake_helper' + +describe 'clearing redis cache' do + before do + Rake.application.rake_require 'tasks/cache' + end + + describe 'clearing pipeline status cache' do + let(:pipeline_status) { create(:ci_pipeline).project.pipeline_status } + + before do + allow(pipeline_status).to receive(:loaded).and_return(nil) + end + + it 'clears pipeline status cache' do + expect { run_rake_task('cache:clear:redis') }.to change { pipeline_status.has_cache? } + end + end +end |