diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 09:08:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 09:08:55 +0000 |
commit | be37a0ee5e3e3dbb967266248f0f46f14a9931e2 (patch) | |
tree | 8fd575a36933fb847a6f92ff76d9c1ad908a3f7b /spec | |
parent | 6305f1dc00870f6e0635e2e850538a00bbd00bda (diff) | |
download | gitlab-ce-be37a0ee5e3e3dbb967266248f0f46f14a9931e2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
6 files changed, 161 insertions, 10 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 diff --git a/spec/presenters/ci/pipeline_presenter_spec.rb b/spec/presenters/ci/pipeline_presenter_spec.rb index fd391478eb4..700d1f5cbb6 100644 --- a/spec/presenters/ci/pipeline_presenter_spec.rb +++ b/spec/presenters/ci/pipeline_presenter_spec.rb @@ -209,6 +209,15 @@ describe Ci::PipelinePresenter do "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_2)}\">#{mr_2.to_reference} #{mr_2.title}</a>, " \ "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_1)}\">#{mr_1.to_reference} #{mr_1.title}</a>") } + + context 'with a limit passed' do + subject { presenter.all_related_merge_request_text(limit: 1) } + + it { + is_expected.to eq("2 related merge requests: " \ + "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_2)}\">#{mr_2.to_reference} #{mr_2.title}</a>") + } + end end end diff --git a/spec/services/metrics/dashboard/default_embed_service_spec.rb b/spec/services/metrics/dashboard/default_embed_service_spec.rb index 741a9644905..1b88276368c 100644 --- a/spec/services/metrics/dashboard/default_embed_service_spec.rb +++ b/spec/services/metrics/dashboard/default_embed_service_spec.rb @@ -13,6 +13,26 @@ describe Metrics::Dashboard::DefaultEmbedService, :use_clean_rails_memory_store_ project.add_maintainer(user) end + describe '.valid_params?' do + let(:params) { { embedded: true } } + + subject { described_class.valid_params?(params) } + + it { is_expected.to be_truthy } + + context 'missing embedded' do + let(:params) { {} } + + it { is_expected.to be_falsey } + end + + context 'not embedded' do + let(:params) { { embedded: false } } + + it { is_expected.to be_falsey } + end + end + describe '#get_dashboard' do let(:service_params) { [project, user, { environment: environment }] } let(:service_call) { described_class.new(*service_params).get_dashboard } diff --git a/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb b/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb index c3993bf71ea..36ca6f882fa 100644 --- a/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb +++ b/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb @@ -13,7 +13,27 @@ describe Metrics::Dashboard::PodDashboardService, :use_clean_rails_memory_store_ project.add_maintainer(user) end - describe 'get_dashboard' do + describe '.valid_params?' do + let(:params) { { dashboard_path: described_class::DASHBOARD_PATH } } + + subject { described_class.valid_params?(params) } + + it { is_expected.to be_truthy } + + context 'missing dashboard_path' do + let(:params) { {} } + + it { is_expected.to be_falsey } + end + + context 'non-matching dashboard_path' do + let(:params) { { dashboard_path: 'path/to/bunk.yml' } } + + it { is_expected.to be_falsey } + end + end + + describe '#get_dashboard' do let(:dashboard_path) { described_class::DASHBOARD_PATH } let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] } let(:service_call) { described_class.new(*service_params).get_dashboard } diff --git a/spec/services/metrics/dashboard/project_dashboard_service_spec.rb b/spec/services/metrics/dashboard/project_dashboard_service_spec.rb index cba8ef2ec98..829e750d438 100644 --- a/spec/services/metrics/dashboard/project_dashboard_service_spec.rb +++ b/spec/services/metrics/dashboard/project_dashboard_service_spec.rb @@ -13,7 +13,7 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st project.add_maintainer(user) end - describe 'get_dashboard' do + describe '#get_dashboard' do let(:dashboard_path) { '.gitlab/dashboards/test.yml' } let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] } let(:service_call) { described_class.new(*service_params).get_dashboard } @@ -62,7 +62,7 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st end end - describe '::all_dashboard_paths' do + describe '.all_dashboard_paths' do let(:all_dashboards) { described_class.all_dashboard_paths(project) } context 'when there are no project dashboards' do @@ -87,4 +87,24 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st end end end + + describe '.valid_params?' do + let(:params) { { dashboard_path: '.gitlab/dashboard/test.yml' } } + + subject { described_class.valid_params?(params) } + + it { is_expected.to be_truthy } + + context 'missing dashboard_path' do + let(:params) { {} } + + it { is_expected.to be_falsey } + end + + context 'empty dashboard_path' do + let(:params) { { dashboard_path: '' } } + + it { is_expected.to be_falsey } + end + end end diff --git a/spec/services/metrics/dashboard/system_dashboard_service_spec.rb b/spec/services/metrics/dashboard/system_dashboard_service_spec.rb index cc9f711c611..1956f9b563b 100644 --- a/spec/services/metrics/dashboard/system_dashboard_service_spec.rb +++ b/spec/services/metrics/dashboard/system_dashboard_service_spec.rb @@ -13,7 +13,7 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto project.add_maintainer(user) end - describe 'get_dashboard' do + describe '#get_dashboard' do let(:dashboard_path) { described_class::DASHBOARD_PATH } let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] } let(:service_call) { described_class.new(*service_params).get_dashboard } @@ -30,7 +30,7 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto end end - describe '::all_dashboard_paths' do + describe '.all_dashboard_paths' do it 'returns the dashboard attributes' do all_dashboards = described_class.all_dashboard_paths(project) @@ -44,4 +44,24 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto ) end end + + describe '.valid_params?' do + let(:params) { { dashboard_path: described_class::DASHBOARD_PATH } } + + subject { described_class.valid_params?(params) } + + it { is_expected.to be_truthy } + + context 'missing dashboard_path' do + let(:params) { {} } + + it { is_expected.to be_falsey } + end + + context 'non-matching dashboard_path' do + let(:params) { { dashboard_path: 'path/to/bunk.yml' } } + + it { is_expected.to be_falsey } + end + end end |