Commit db3c5a04 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Use merge_request_diff instead of doubles for testing pipelines for Merge Requests

parent aa8cb00b
......@@ -45,24 +45,24 @@
- if @commits_count.nonzero?
%ul.merge-request-tabs.nav-links.no-top.no-bottom
%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
%span.badge= @merge_request.mr_and_commit_notes.user.count
%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
%span.badge= @commits_count
- if @pipeline
%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
%span.badge
%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
%span.badge= @statuses.size
%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
%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)
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment