2017-04-04 15:38:16 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-04-18 19:26:56 +00:00
|
|
|
describe ExpirePipelineCacheWorker do
|
2017-04-04 15:38:16 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:empty_project) }
|
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
2017-04-18 19:26:56 +00:00
|
|
|
subject { described_class.new }
|
2017-04-04 15:38:16 +00:00
|
|
|
|
2017-04-18 19:26:56 +00:00
|
|
|
describe '#perform' do
|
2017-04-04 15:38:16 +00:00
|
|
|
it 'invalidate Etag caching for project pipelines path' do
|
2017-04-05 14:36:14 +00:00
|
|
|
pipelines_path = "/#{project.full_path}/pipelines.json"
|
|
|
|
new_mr_pipelines_path = "/#{project.full_path}/merge_requests/new.json"
|
2017-04-04 15:38:16 +00:00
|
|
|
|
2017-04-05 14:36:14 +00:00
|
|
|
expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(pipelines_path)
|
|
|
|
expect_any_instance_of(Gitlab::EtagCaching::Store).to receive(:touch).with(new_mr_pipelines_path)
|
2017-04-04 15:38:16 +00:00
|
|
|
|
2017-04-18 19:26:56 +00:00
|
|
|
subject.perform(pipeline.id)
|
2017-04-04 15:38:16 +00:00
|
|
|
end
|
2017-04-07 08:56:35 +00:00
|
|
|
|
|
|
|
it 'updates the cached status for a project' do
|
|
|
|
expect(Gitlab::Cache::Ci::ProjectPipelineStatus).to receive(:update_for_pipeline).
|
|
|
|
with(pipeline)
|
|
|
|
|
2017-04-18 19:26:56 +00:00
|
|
|
subject.perform(pipeline.id)
|
2017-04-07 08:56:35 +00:00
|
|
|
end
|
2017-04-04 15:38:16 +00:00
|
|
|
end
|
|
|
|
end
|