Simplify specs and remove unnecessary attributes
This commit is contained in:
parent
14642e3c28
commit
956624688d
|
@ -1040,23 +1040,15 @@ describe Ci::Pipeline, models: true do
|
||||||
|
|
||||||
describe "#all_merge_requests" do
|
describe "#all_merge_requests" do
|
||||||
let(:project) { create(:empty_project) }
|
let(:project) { create(:empty_project) }
|
||||||
let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: 'a288a022a53a5a944fae87bcec6efc87b7061808') }
|
let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master') }
|
||||||
|
|
||||||
it "returns merge request if pipeline runs on `diff_head_sha`" do
|
it "returns all merge requests having the same source branch" do
|
||||||
merge_request = create(:merge_request, source_project: project, source_branch: pipeline.ref)
|
merge_request = create(:merge_request, source_project: project, source_branch: pipeline.ref)
|
||||||
allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { 'a288a022a53a5a944fae87bcec6efc87b7061808' }
|
|
||||||
|
|
||||||
expect(pipeline.all_merge_requests).to eq([merge_request])
|
expect(pipeline.all_merge_requests).to eq([merge_request])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns merge request if pipeline runs any commit of the `source_branch`" do
|
it "doesn't return merge requests having a different source branch" do
|
||||||
merge_request = create(:merge_request, source_project: project, source_branch: pipeline.ref)
|
|
||||||
allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { '97de212e80737a608d939f648d959671fb0a0142b' }
|
|
||||||
|
|
||||||
expect(pipeline.all_merge_requests).to eq([merge_request])
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't return merge request if pipeline runs on a different `source_branch`" do
|
|
||||||
create(:merge_request, source_project: project, source_branch: 'feature', target_branch: 'master')
|
create(:merge_request, source_project: project, source_branch: 'feature', target_branch: 'master')
|
||||||
|
|
||||||
expect(pipeline.all_merge_requests).to be_empty
|
expect(pipeline.all_merge_requests).to be_empty
|
||||||
|
|
|
@ -18,8 +18,7 @@ describe ExpirePipelineCacheWorker do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'invalidates Etag caching for merge request pipelines if pipeline runs on any commit of that source branch' do
|
it 'invalidates Etag caching for merge request pipelines if pipeline runs on any commit of that source branch' do
|
||||||
project = create(:project, :repository)
|
pipeline = create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master')
|
||||||
pipeline = create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: project.repository.commit('master^').id)
|
|
||||||
merge_request = create(:merge_request, source_project: project, source_branch: pipeline.ref)
|
merge_request = create(:merge_request, source_project: project, source_branch: pipeline.ref)
|
||||||
merge_request_pipelines_path = "/#{project.full_path}/merge_requests/#{merge_request.iid}/pipelines.json"
|
merge_request_pipelines_path = "/#{project.full_path}/merge_requests/#{merge_request.iid}/pipelines.json"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue