summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2017-04-07 10:56:35 +0200
committerBob Van Landuyt <bob@gitlab.com>2017-04-07 17:24:11 +0200
commit9eded57dd2b4d23e43b485c448abb92359e6933e (patch)
tree061e49c5482a919f3680d858994fae304cd4edbe
parent516a405eb277e088d3b4ae3cb6e64f0bd2d3aff0 (diff)
downloadgitlab-ce-bvl-fix-project-ci-status-cache.tar.gz
Use `Ci::ExpirePipelineCacheService` to set `ProjectPipelinestatus`bvl-fix-project-ci-status-cache
-rw-r--r--app/models/ci/pipeline.rb5
-rw-r--r--app/services/ci/expire_pipeline_cache_service.rb2
-rw-r--r--spec/models/ci/pipeline_spec.rb13
-rw-r--r--spec/services/ci/expire_pipeline_cache_service_spec.rb7
4 files changed, 10 insertions, 17 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index b8d77e62494..445247f1b41 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -98,7 +98,6 @@ module Ci
PipelineHooksWorker.perform_async(id)
Ci::ExpirePipelineCacheService.new(project, nil)
.execute(pipeline)
- refresh_project_build_status_cache
end
end
@@ -392,10 +391,6 @@ module Ci
.fabricate!
end
- def refresh_project_build_status_cache
- Gitlab::Cache::Ci::ProjectPipelineStatus.update_for_pipeline(self)
- end
-
private
def pipeline_data
diff --git a/app/services/ci/expire_pipeline_cache_service.rb b/app/services/ci/expire_pipeline_cache_service.rb
index c0e4a798f6a..91d9c1d2ba1 100644
--- a/app/services/ci/expire_pipeline_cache_service.rb
+++ b/app/services/ci/expire_pipeline_cache_service.rb
@@ -10,6 +10,8 @@ module Ci
store.touch(commit_pipelines_path) if pipeline.commit
store.touch(new_merge_request_pipelines_path)
merge_requests_pipelines_paths.each { |path| store.touch(path) }
+
+ Gitlab::Cache::Ci::ProjectPipelineStatus.update_for_pipeline(@pipeline)
end
private
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index b71fd794d4c..d7d6a75d38d 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -375,7 +375,7 @@ describe Ci::Pipeline, models: true do
end
end
- describe 'pipeline ETag caching' do
+ describe 'pipeline caching' do
it 'executes ExpirePipelinesCacheService' do
expect_any_instance_of(Ci::ExpirePipelineCacheService).to receive(:execute).with(pipeline)
@@ -1079,17 +1079,6 @@ describe Ci::Pipeline, models: true do
end
end
- describe 'update project cache when transitioning' do
- let(:pipeline) { create(:ci_pipeline, sha: '123456') }
-
- it 'updates the cached status' do
- expect(Gitlab::Cache::Ci::ProjectPipelineStatus).to receive(:update_for_pipeline).
- with(pipeline)
-
- pipeline.block
- end
- end
-
describe 'notifications when pipeline success or failed' do
let(:project) { create(:project, :repository) }
diff --git a/spec/services/ci/expire_pipeline_cache_service_spec.rb b/spec/services/ci/expire_pipeline_cache_service_spec.rb
index 3c735872c30..166c6dfc93e 100644
--- a/spec/services/ci/expire_pipeline_cache_service_spec.rb
+++ b/spec/services/ci/expire_pipeline_cache_service_spec.rb
@@ -16,5 +16,12 @@ describe Ci::ExpirePipelineCacheService, services: true do
subject.execute(pipeline)
end
+
+ it 'updates the cached status for a project' do
+ expect(Gitlab::Cache::Ci::ProjectPipelineStatus).to receive(:update_for_pipeline).
+ with(pipeline)
+
+ subject.execute(pipeline)
+ end
end
end