Use merge_request_diff instead of doubles for testing pipelines for Merge Requests
This commit is contained in:
parent
aa8cb00b58
commit
db3c5a042d
|
@ -24,7 +24,7 @@ feature 'Pipelines for Merge Requests', feature: true, js: true do
|
|||
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
|
||||
end
|
||||
|
||||
scenario 'does click a pipeline tab and sees a list of pipelines' do
|
||||
scenario 'user visits merge request pipelines tab' do
|
||||
page.within('.merge-request-tabs') do
|
||||
click_link('Pipelines')
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ feature 'Pipelines for Merge Requests', feature: true, js: true do
|
|||
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
|
||||
end
|
||||
|
||||
scenario 'does not find a pipeline link' do
|
||||
scenario 'user visits merge request page' do
|
||||
page.within('.merge-request-tabs') do
|
||||
expect(page).not_to have_link('Pipelines')
|
||||
end
|
||||
|
|
|
@ -425,7 +425,7 @@ describe MergeRequest, models: true do
|
|||
let(:commit2) { double('commit2', sha: 'sha3') }
|
||||
|
||||
before do
|
||||
allow(subject).to receive(:commits).and_return([commit0, commit1, commit2])
|
||||
allow(subject.merge_request_diff).to receive(:commits).and_return([commit0, commit1, commit2])
|
||||
end
|
||||
|
||||
it 'returns sha of commits' do
|
||||
|
@ -458,20 +458,15 @@ describe MergeRequest, models: true do
|
|||
end
|
||||
|
||||
describe '#all_pipelines' do
|
||||
let(:commit0) { double('commit0', sha: 'sha1') }
|
||||
let(:commit1) { double('commit1', sha: 'sha2') }
|
||||
let(:commit2) { double('commit2', sha: 'sha3') }
|
||||
let!(:pipeline) { create(:ci_empty_pipeline, project: subject.source_project, sha: 'sha1', ref: subject.source_branch) }
|
||||
let!(:pipeline2) { create(:ci_empty_pipeline, project: subject.source_project, sha: 'sha1', ref: subject.source_branch) }
|
||||
let!(:pipeline3) { create(:ci_empty_pipeline, project: subject.source_project, sha: 'sha2', ref: subject.source_branch) }
|
||||
let!(:pipeline4) { create(:ci_empty_pipeline, project: subject.target_project, sha: 'sha1', ref: subject.target_branch) }
|
||||
|
||||
before do
|
||||
allow(subject).to receive(:commits).and_return([commit0, commit1, commit2])
|
||||
let!(:pipelines) do
|
||||
subject.merge_request_diff.commits.map do |commit|
|
||||
create(:ci_empty_pipeline, project: subject.source_project, sha: commit.id, ref: subject.source_branch)
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns a pipelines from source projects' do
|
||||
expect(subject.all_pipelines).to eq([pipeline3, pipeline2, pipeline])
|
||||
it 'returns a pipelines from source projects with proper ordering' do
|
||||
expect(subject.all_pipelines).not_to be_empty
|
||||
expect(subject.all_pipelines).to eq(pipelines.reverse)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue