Use merge_request_diff instead of doubles for testing pipelines for Merge Requests
This commit is contained in:
parent
aa8cb00b58
commit
db3c5a042d
|
@ -45,24 +45,24 @@
|
||||||
- if @commits_count.nonzero?
|
- if @commits_count.nonzero?
|
||||||
%ul.merge-request-tabs.nav-links.no-top.no-bottom
|
%ul.merge-request-tabs.nav-links.no-top.no-bottom
|
||||||
%li.notes-tab
|
%li.notes-tab
|
||||||
= link_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: {target: 'div#notes', action: 'notes', toggle: 'tab'} do
|
= link_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#notes', action: 'notes', toggle: 'tab' } do
|
||||||
Discussion
|
Discussion
|
||||||
%span.badge= @merge_request.mr_and_commit_notes.user.count
|
%span.badge= @merge_request.mr_and_commit_notes.user.count
|
||||||
%li.commits-tab
|
%li.commits-tab
|
||||||
= link_to commits_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: {target: 'div#commits', action: 'commits', toggle: 'tab'} do
|
= link_to commits_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#commits', action: 'commits', toggle: 'tab' } do
|
||||||
Commits
|
Commits
|
||||||
%span.badge= @commits_count
|
%span.badge= @commits_count
|
||||||
- if @pipeline
|
- if @pipeline
|
||||||
%li.pipelines-tab
|
%li.pipelines-tab
|
||||||
= link_to pipelines_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: {target: '#pipelines', action: 'pipelines', toggle: 'tab'} do
|
= link_to pipelines_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: '#pipelines', action: 'pipelines', toggle: 'tab' } do
|
||||||
Pipelines
|
Pipelines
|
||||||
%span.badge
|
%span.badge
|
||||||
%li.builds-tab
|
%li.builds-tab
|
||||||
= link_to builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: {target: '#builds', action: 'builds', toggle: 'tab'} do
|
= link_to builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: '#builds', action: 'builds', toggle: 'tab' } do
|
||||||
Builds
|
Builds
|
||||||
%span.badge= @statuses.size
|
%span.badge= @statuses.size
|
||||||
%li.diffs-tab
|
%li.diffs-tab
|
||||||
= link_to diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: {target: 'div#diffs', action: 'diffs', toggle: 'tab'} do
|
= link_to diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#diffs', action: 'diffs', toggle: 'tab' } do
|
||||||
Changes
|
Changes
|
||||||
%span.badge= @merge_request.diff_size
|
%span.badge= @merge_request.diff_size
|
||||||
|
|
||||||
|
|
|
@ -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)
|
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
|
||||||
end
|
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
|
page.within('.merge-request-tabs') do
|
||||||
click_link('Pipelines')
|
click_link('Pipelines')
|
||||||
end
|
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)
|
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'does not find a pipeline link' do
|
scenario 'user visits merge request page' do
|
||||||
page.within('.merge-request-tabs') do
|
page.within('.merge-request-tabs') do
|
||||||
expect(page).not_to have_link('Pipelines')
|
expect(page).not_to have_link('Pipelines')
|
||||||
end
|
end
|
||||||
|
|
|
@ -425,7 +425,7 @@ describe MergeRequest, models: true do
|
||||||
let(:commit2) { double('commit2', sha: 'sha3') }
|
let(:commit2) { double('commit2', sha: 'sha3') }
|
||||||
|
|
||||||
before do
|
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
|
end
|
||||||
|
|
||||||
it 'returns sha of commits' do
|
it 'returns sha of commits' do
|
||||||
|
@ -458,20 +458,15 @@ describe MergeRequest, models: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#all_pipelines' do
|
describe '#all_pipelines' do
|
||||||
let(:commit0) { double('commit0', sha: 'sha1') }
|
let!(:pipelines) do
|
||||||
let(:commit1) { double('commit1', sha: 'sha2') }
|
subject.merge_request_diff.commits.map do |commit|
|
||||||
let(:commit2) { double('commit2', sha: 'sha3') }
|
create(:ci_empty_pipeline, project: subject.source_project, sha: commit.id, ref: subject.source_branch)
|
||||||
let!(:pipeline) { create(:ci_empty_pipeline, project: subject.source_project, sha: 'sha1', ref: subject.source_branch) }
|
end
|
||||||
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])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns a pipelines from source projects' do
|
it 'returns a pipelines from source projects with proper ordering' do
|
||||||
expect(subject.all_pipelines).to eq([pipeline3, pipeline2, pipeline])
|
expect(subject.all_pipelines).not_to be_empty
|
||||||
|
expect(subject.all_pipelines).to eq(pipelines.reverse)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue