Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-26 09:01:14 +0300
committerStan Hu <stanhu@gmail.com>2019-03-26 09:04:06 +0300
commit2d233dac4573f8d321464712333d4ff8bcb767af (patch)
treebf4bb89ac286216bc0db2a2ee7ca8f823819038e /spec/services/ci/destroy_pipeline_service_spec.rb
parent61b2f70fdcbc8dce7504c6599f57e2db703cc5ae (diff)
Clear pipeline status cache after destruction of pipeline
`project.pipeline_status.has_status?` is cached, which can lead to Error 500s in the UI if the this condition is used to check whether a pipeline exists for a commit. We now expire the cache to ensure that the information is consistent. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59453
Diffstat (limited to 'spec/services/ci/destroy_pipeline_service_spec.rb')
-rw-r--r--spec/services/ci/destroy_pipeline_service_spec.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/spec/services/ci/destroy_pipeline_service_spec.rb b/spec/services/ci/destroy_pipeline_service_spec.rb
index d896f990470..bff2b3179fb 100644
--- a/spec/services/ci/destroy_pipeline_service_spec.rb
+++ b/spec/services/ci/destroy_pipeline_service_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe ::Ci::DestroyPipelineService do
- let(:project) { create(:project) }
- let!(:pipeline) { create(:ci_pipeline, project: project) }
+ let(:project) { create(:project, :repository) }
+ let!(:pipeline) { create(:ci_pipeline, :success, project: project, sha: project.commit.id) }
subject { described_class.new(project, user).execute(pipeline) }
@@ -17,6 +17,17 @@ describe ::Ci::DestroyPipelineService do
expect { pipeline.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
+ it 'clears the cache', :use_clean_rails_memory_store_caching do
+ create(:commit_status, :success, pipeline: pipeline, ref: pipeline.ref)
+
+ expect(project.pipeline_status.has_status?).to be_truthy
+
+ subject
+
+ # Need to use find to avoid memoization
+ expect(Project.find(project.id).pipeline_status.has_status?).to be_falsey
+ end
+
it 'does not log an audit event' do
expect { subject }.not_to change { SecurityEvent.count }
end