summaryrefslogtreecommitdiff
path: root/spec/features/projects/pipelines
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/projects/pipelines')
-rw-r--r--spec/features/projects/pipelines/pipeline_spec.rb72
1 files changed, 67 insertions, 5 deletions
diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb
index cb0acc55e06..5fe99c0ad1d 100644
--- a/spec/features/projects/pipelines/pipeline_spec.rb
+++ b/spec/features/projects/pipelines/pipeline_spec.rb
@@ -99,12 +99,74 @@ describe 'Pipeline', :js do
end
end
- it 'shows links to the related merge requests' do
- visit_pipeline
+ describe 'related merge requests' do
+ context 'when there are no related merge requests' do
+ it 'shows a "no related merge requests" message' do
+ visit_pipeline
+
+ within '.related-merge-request-info' do
+ expect(page).to have_content('No related merge requests found.')
+ end
+ end
+ end
+
+ context 'when there is one related merge request' do
+ before do
+ create(:merge_request,
+ source_project: project,
+ source_branch: pipeline.ref)
+ end
+
+ it 'shows a link to the merge request' do
+ visit_pipeline
+
+ within '.related-merge-requests' do
+ expect(page).to have_content('1 related merge request: ')
+ expect(page).to have_selector('.js-truncated-mr-list')
+ expect(page).to have_link('!1 My title 1')
+
+ expect(page).not_to have_selector('.js-full-mr-list')
+ expect(page).not_to have_selector('.text-expander')
+ end
+ end
+ end
+
+ context 'when there are two related merge requests' do
+ before do
+ create(:merge_request,
+ source_project: project,
+ source_branch: pipeline.ref,
+ target_branch: 'feature-1')
+
+ create(:merge_request,
+ source_project: project,
+ source_branch: pipeline.ref,
+ target_branch: 'feature-2')
+ end
- within '.related-merge-request-info' do
- pipeline.all_merge_requests.map do |merge_request|
- expect(page).to have_link(project_merge_request_path(project, merge_request))
+ it 'links to the most recent related merge request' do
+ visit_pipeline
+
+ within '.related-merge-requests' do
+ expect(page).to have_content('2 related merge requests: ')
+ expect(page).to have_link('!2 My title 3')
+ expect(page).to have_selector('.text-expander')
+ expect(page).to have_selector('.js-full-mr-list', visible: false)
+ end
+ end
+
+ it 'expands to show links to all related merge requests' do
+ visit_pipeline
+
+ within '.related-merge-requests' do
+ find('.text-expander').click
+
+ expect(page).to have_selector('.js-full-mr-list', visible: true)
+
+ pipeline.all_merge_requests.map do |merge_request|
+ expect(page).to have_link(href: project_merge_request_path(project, merge_request))
+ end
+ end
end
end
end