diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 15:19:03 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-20 15:19:03 +0000 |
commit | 14bd84b61276ef29b97d23642d698de769bacfd2 (patch) | |
tree | f9eba90140c1bd874211dea17750a0d422c04080 /spec/views | |
parent | 891c388697b2db0d8ee0c8358a9bdbf6dc56d581 (diff) | |
download | gitlab-ce-14bd84b61276ef29b97d23642d698de769bacfd2.tar.gz |
Add latest changes from gitlab-org/gitlab@15-10-stable-eev15.10.0-rc42
Diffstat (limited to 'spec/views')
21 files changed, 376 insertions, 60 deletions
diff --git a/spec/views/admin/application_settings/ci_cd.html.haml_spec.rb b/spec/views/admin/application_settings/ci_cd.html.haml_spec.rb index 5ef9399487f..d2a30f2c5c0 100644 --- a/spec/views/admin/application_settings/ci_cd.html.haml_spec.rb +++ b/spec/views/admin/application_settings/ci_cd.html.haml_spec.rb @@ -14,7 +14,7 @@ RSpec.describe 'admin/application_settings/ci_cd.html.haml' do allow(view).to receive(:current_user).and_return(user) end - describe 'CI CD Runner Registration' do + describe 'CI CD Runners' do it 'has the setting section' do render @@ -26,6 +26,9 @@ RSpec.describe 'admin/application_settings/ci_cd.html.haml' do expect(rendered).to have_content("Runner registration") expect(rendered).to have_content(s_("Runners|If both settings are disabled, new runners cannot be registered.")) + expect(rendered).to have_content( + s_("Runners|Fetch GitLab Runner release version data from GitLab.com") + ) end end end diff --git a/spec/views/admin/application_settings/network.html.haml_spec.rb b/spec/views/admin/application_settings/network.html.haml_spec.rb new file mode 100644 index 00000000000..3df55be92d5 --- /dev/null +++ b/spec/views/admin/application_settings/network.html.haml_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'admin/application_settings/network.html.haml', feature_category: :projects do + let_it_be(:admin) { build_stubbed(:admin) } + let_it_be(:application_setting) { build(:application_setting) } + + before do + assign(:application_setting, application_setting) + allow(view).to receive(:current_user) { admin } + end + + context 'for Projects API rate limit' do + it 'renders the `projects_api_rate_limit_unauthenticated` field' do + render + + expect(rendered).to have_field('application_setting_projects_api_rate_limit_unauthenticated') + end + + context 'when the feature flag `rate_limit_for_unauthenticated_projects_api_access` is turned off' do + before do + stub_feature_flags(rate_limit_for_unauthenticated_projects_api_access: false) + end + + it 'does not render the `projects_api_rate_limit_unauthenticated` field' do + render + + expect(rendered).not_to have_field('application_setting_projects_api_rate_limit_unauthenticated') + end + end + end +end diff --git a/spec/views/admin/sessions/two_factor.html.haml_spec.rb b/spec/views/admin/sessions/two_factor.html.haml_spec.rb index c7e0edbcd58..6503c08b84c 100644 --- a/spec/views/admin/sessions/two_factor.html.haml_spec.rb +++ b/spec/views/admin/sessions/two_factor.html.haml_spec.rb @@ -29,14 +29,10 @@ RSpec.describe 'admin/sessions/two_factor.html.haml' do end end - context 'user has u2f active' do - let(:user) { create(:admin, :two_factor_via_u2f) } + context 'user has WebAuthn active' do + let(:user) { create(:admin, :two_factor_via_webauthn) } - before do - stub_feature_flags(webauthn: false) - end - - it 'shows enter u2f form' do + it 'shows enter WebAuthn form' do render expect(rendered).to have_css('#js-login-2fa-device.btn') diff --git a/spec/views/devise/confirmations/almost_there.html.haml_spec.rb b/spec/views/devise/confirmations/almost_there.html.haml_spec.rb index c091efe9295..8e12fb5a17e 100644 --- a/spec/views/devise/confirmations/almost_there.html.haml_spec.rb +++ b/spec/views/devise/confirmations/almost_there.html.haml_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' RSpec.describe 'devise/confirmations/almost_there' do - describe 'confirmations text' do - subject { render(template: 'devise/confirmations/almost_there') } + subject { render(template: 'devise/confirmations/almost_there') } + describe 'confirmations text' do before do allow(view).to receive(:params).and_return(email: email) end @@ -34,4 +34,17 @@ RSpec.describe 'devise/confirmations/almost_there' do end end end + + describe 'register again prompt' do + specify do + subject + + expect(rendered).to have_content( + 'If the email address is incorrect, you can register again with a different email' + ) + expect(rendered).to have_link( + 'register again with a different email', href: new_user_registration_path + ) + end + end end diff --git a/spec/views/devise/sessions/new.html.haml_spec.rb b/spec/views/devise/sessions/new.html.haml_spec.rb index 798c891e75c..bad01ec2c3d 100644 --- a/spec/views/devise/sessions/new.html.haml_spec.rb +++ b/spec/views/devise/sessions/new.html.haml_spec.rb @@ -3,14 +3,13 @@ require 'spec_helper' RSpec.describe 'devise/sessions/new' do - describe 'marketing text' do + describe 'marketing text', :saas do subject { render(template: 'devise/sessions/new', layout: 'layouts/devise') } before do stub_devise disable_captcha stub_feature_flags(restyle_login_page: false) - allow(Gitlab).to receive(:com?).and_return(true) end it 'when flash is anything it renders marketing text' do diff --git a/spec/views/devise/shared/_error_messages.html.haml_spec.rb b/spec/views/devise/shared/_error_messages.html.haml_spec.rb new file mode 100644 index 00000000000..9f23b049caf --- /dev/null +++ b/spec/views/devise/shared/_error_messages.html.haml_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'devise/shared/_error_messages', feature_category: :system_access do + describe 'Error messages' do + let(:resource) do + instance_spy(User, errors: errors, class: User) + end + + before do + allow(view).to receive(:resource).and_return(resource) + end + + context 'with errors', :aggregate_failures do + let(:errors) { errors_stub(['Invalid name', 'Invalid password']) } + + it 'shows errors' do + render + + expect(rendered).to have_selector('#error_explanation') + expect(rendered).to have_content('Invalid name') + expect(rendered).to have_content('Invalid password') + end + end + + context 'without errors' do + let(:errors) { [] } + + it 'does not show errors' do + render + + expect(rendered).not_to have_selector('#error_explanation') + end + end + end + + def errors_stub(*messages) + ActiveModel::Errors.new(double).tap do |errors| + messages.each { |msg| errors.add(:base, msg) } + end + end +end diff --git a/spec/views/devise/shared/_signup_box.html.haml_spec.rb b/spec/views/devise/shared/_signup_box.html.haml_spec.rb index ee9ccbf6ff5..94a5871cb97 100644 --- a/spec/views/devise/shared/_signup_box.html.haml_spec.rb +++ b/spec/views/devise/shared/_signup_box.html.haml_spec.rb @@ -20,6 +20,7 @@ RSpec.describe 'devise/shared/_signup_box' do before do stub_devise + allow(view).to receive(:arkose_labs_enabled?).and_return(false) allow(view).to receive(:show_omniauth_providers).and_return(false) allow(view).to receive(:url).and_return('_url_') allow(view).to receive(:terms_path).and_return(terms_path) diff --git a/spec/views/events/event/_common.html.haml_spec.rb b/spec/views/events/event/_common.html.haml_spec.rb index 2160245fb63..cff1ec43a14 100644 --- a/spec/views/events/event/_common.html.haml_spec.rb +++ b/spec/views/events/event/_common.html.haml_spec.rb @@ -18,19 +18,6 @@ RSpec.describe 'events/event/_common.html.haml' do create(:event, :created, project: project, target: work_item, target_type: 'WorkItem', author: user) end - context 'when use_iid_in_work_items_path feature flag is disabled' do - before do - stub_feature_flags(use_iid_in_work_items_path: false) - render partial: 'events/event/common', locals: { event: event.present } - end - - it 'renders the correct url' do - expect(rendered).to have_link( - work_item.reference_link_text, href: "/#{project.full_path}/-/work_items/#{work_item.id}" - ) - end - end - it 'renders the correct url with iid' do expect(rendered).to have_link( work_item.reference_link_text, href: "/#{project.full_path}/-/work_items/#{work_item.iid}?iid_path=true" diff --git a/spec/views/groups/group_members/index.html.haml_spec.rb b/spec/views/groups/group_members/index.html.haml_spec.rb index 0b3b149238f..fdc6b09d32a 100644 --- a/spec/views/groups/group_members/index.html.haml_spec.rb +++ b/spec/views/groups/group_members/index.html.haml_spec.rb @@ -25,7 +25,6 @@ RSpec.describe 'groups/group_members/index', :aggregate_failures, feature_catego expect(rendered).to have_selector('.js-invite-group-trigger') expect(rendered).to have_selector('.js-invite-members-trigger') - expect(response).to render_template(partial: 'groups/_invite_members_modal') end end diff --git a/spec/views/layouts/group.html.haml_spec.rb b/spec/views/layouts/group.html.haml_spec.rb new file mode 100644 index 00000000000..0b8f735a1d6 --- /dev/null +++ b/spec/views/layouts/group.html.haml_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'layouts/group', feature_category: :subgroups do + let_it_be(:group) { create(:group) } # rubocop:todo RSpec/FactoryBot/AvoidCreate + let(:invite_member) { true } + + before do + allow(view).to receive(:can_admin_group_member?).and_return(invite_member) + assign(:group, group) + allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(build_stubbed(:user))) + end + + subject do + render + + rendered + end + + context 'with ability to invite members' do + it { is_expected.to have_selector('.js-invite-members-modal') } + end + + context 'without ability to invite members' do + let(:invite_member) { false } + + it { is_expected.not_to have_selector('.js-invite-members-modal') } + end +end diff --git a/spec/views/layouts/header/_new_dropdown.haml_spec.rb b/spec/views/layouts/header/_new_dropdown.haml_spec.rb index 178448022d1..2c5882fce3d 100644 --- a/spec/views/layouts/header/_new_dropdown.haml_spec.rb +++ b/spec/views/layouts/header/_new_dropdown.haml_spec.rb @@ -7,13 +7,13 @@ RSpec.describe 'layouts/header/_new_dropdown', feature_category: :navigation do shared_examples_for 'invite member selector' do context 'with ability to invite members' do - it { is_expected.to have_link('Invite members', href: href) } + it { is_expected.to have_selector('.js-invite-members-trigger') } end context 'without ability to invite members' do let(:invite_member) { false } - it { is_expected.not_to have_link('Invite members') } + it { is_expected.not_to have_selector('.js-invite-members-trigger') } end end @@ -159,6 +159,29 @@ RSpec.describe 'layouts/header/_new_dropdown', feature_category: :navigation do expect(rendered).to have_link('New snippet', href: new_snippet_path) end + context 'when partial exists in a menu item' do + it 'renders the menu item partial without rendering invite modal partial' do + view_model = { + title: '_title_', + menu_sections: [ + { + title: '_section_title_', + menu_items: [ + ::Gitlab::Nav::TopNavMenuItem + .build(id: '_id_', title: '_title_', partial: 'groups/invite_members_top_nav_link') + ] + } + ] + } + + allow(view).to receive(:new_dropdown_view_model).and_return(view_model) + + render + + expect(response).to render_template(partial: 'groups/_invite_members_top_nav_link') + end + end + context 'when the user is not allowed to do anything' do let(:user) { create(:user, :external) } # rubocop:disable RSpec/FactoryBot/AvoidCreate diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb index cddff276317..0df490f9b41 100644 --- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb @@ -106,11 +106,11 @@ RSpec.describe 'layouts/nav/sidebar/_project', feature_category: :navigation do end end - describe 'Contributors' do + describe 'Contributor statistics' do it 'has a link to the project contributors path' do render - expect(rendered).to have_link('Contributors', href: project_graph_path(project, current_ref, ref_type: 'heads')) + expect(rendered).to have_link('Contributor statistics', href: project_graph_path(project, current_ref, ref_type: 'heads')) end end @@ -122,11 +122,11 @@ RSpec.describe 'layouts/nav/sidebar/_project', feature_category: :navigation do end end - describe 'Compare' do + describe 'Compare revisions' do it 'has a link to the project compare path' do render - expect(rendered).to have_link('Compare', href: project_compare_index_path(project, from: project.repository.root_ref, to: current_ref)) + expect(rendered).to have_link('Compare revisions', href: project_compare_index_path(project, from: project.repository.root_ref, to: current_ref)) end end end @@ -310,7 +310,7 @@ RSpec.describe 'layouts/nav/sidebar/_project', feature_category: :navigation do it 'top level navigation link is not visible' do render - expect(rendered).not_to have_link('Security & Compliance') + expect(rendered).not_to have_link('Security and Compliance') end end @@ -322,11 +322,11 @@ RSpec.describe 'layouts/nav/sidebar/_project', feature_category: :navigation do end it 'top level navigation link is visible' do - expect(rendered).to have_link('Security & Compliance') + expect(rendered).to have_link('Security and Compliance') end it 'security configuration link is visible' do - expect(rendered).to have_link('Configuration', href: project_security_configuration_path(project)) + expect(rendered).to have_link('Security configuration', href: project_security_configuration_path(project)) end end end diff --git a/spec/views/layouts/project.html.haml_spec.rb b/spec/views/layouts/project.html.haml_spec.rb new file mode 100644 index 00000000000..588828f7bd6 --- /dev/null +++ b/spec/views/layouts/project.html.haml_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'layouts/project', feature_category: :projects do + let(:invite_member) { true } + + before do + allow(view).to receive(:can_admin_project_member?).and_return(invite_member) + assign(:project, build_stubbed(:project)) + allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(build_stubbed(:user))) + end + + subject do + render + + rendered + end + + context 'with ability to invite members' do + it { is_expected.to have_selector('.js-invite-members-modal') } + end + + context 'without ability to invite members' do + let(:invite_member) { false } + + it { is_expected.not_to have_selector('.js-invite-members-modal') } + end +end diff --git a/spec/views/notify/import_issues_csv_email.html.haml_spec.rb b/spec/views/notify/import_issues_csv_email.html.haml_spec.rb index 43dfab87ac9..c3d320a837b 100644 --- a/spec/views/notify/import_issues_csv_email.html.haml_spec.rb +++ b/spec/views/notify/import_issues_csv_email.html.haml_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'notify/import_issues_csv_email.html.haml' do let(:user) { create(:user) } let(:project) { create(:project) } - let(:correct_results) { { success: 3, valid_file: true } } - let(:errored_results) { { success: 3, error_lines: [5, 6, 7], valid_file: true } } + let(:correct_results) { { success: 3, parse_error: false } } + let(:errored_results) { { success: 3, error_lines: [5, 6, 7], parse_error: false } } let(:parse_error_results) { { success: 0, parse_error: true } } before do diff --git a/spec/views/notify/import_work_items_csv_email.html.haml_spec.rb b/spec/views/notify/import_work_items_csv_email.html.haml_spec.rb new file mode 100644 index 00000000000..989481fc2e6 --- /dev/null +++ b/spec/views/notify/import_work_items_csv_email.html.haml_spec.rb @@ -0,0 +1,133 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'notify/import_work_items_csv_email.html.haml', feature_category: :team_planning do + let_it_be(:user) { create(:user) } # rubocop:disable RSpec/FactoryBot/AvoidCreate + let_it_be(:project) { create(:project) } # rubocop:disable RSpec/FactoryBot/AvoidCreate + + let(:parse_error) { "Error parsing CSV file. Please make sure it has the correct format" } + + before do + assign(:user, user) + assign(:project, project) + assign(:results, results) + + render + end + + shared_examples_for 'no records created' do + specify do + expect(rendered).to have_content("No work items have been imported.") + expect(rendered).not_to have_content("work items successfully imported.") + end + end + + shared_examples_for 'work item records created' do + specify do + expect(rendered).not_to have_content("No work items have been imported.") + expect(rendered).to have_content("work items successfully imported.") + end + end + + shared_examples_for 'contains project link' do + specify do + expect(rendered).to have_link(project.full_name, href: project_url(project)) + end + end + + shared_examples_for 'contains parse error' do + specify do + expect(rendered).to have_content(parse_error) + end + end + + shared_examples_for 'does not contain parse error' do + specify do + expect(rendered).not_to have_content(parse_error) + end + end + + context 'when no errors found while importing' do + let(:results) { { success: 3, parse_error: false } } + + it 'renders correctly' do + expect(rendered).not_to have_content("Errors found on line") + end + + it_behaves_like 'contains project link' + it_behaves_like 'work item records created' + it_behaves_like 'does not contain parse error' + end + + context 'when import errors reported' do + let(:results) { { success: 3, error_lines: [5, 6, 7], parse_error: false } } + + it 'renders correctly' do + expect(rendered).to have_content("Errors found on lines: #{results[:error_lines].join(', ')}. \ +Please check that these lines have the following fields: title, type") + end + + it_behaves_like 'contains project link' + it_behaves_like 'work item records created' + it_behaves_like 'does not contain parse error' + end + + context 'when parse error reported while importing' do + let(:results) { { success: 0, parse_error: true } } + + it_behaves_like 'contains project link' + it_behaves_like 'no records created' + it_behaves_like 'contains parse error' + end + + context 'when work item type column contains blank entries' do + let(:results) { { success: 0, parse_error: false, type_errors: { blank: [4] } } } + + it 'renders with missing work item message' do + expect(rendered).to have_content("Work item type is empty") + end + + it_behaves_like 'contains project link' + it_behaves_like 'no records created' + it_behaves_like 'does not contain parse error' + end + + context 'when work item type column contains missing entries' do + let(:results) { { success: 0, parse_error: false, type_errors: { missing: [5] } } } + + it 'renders with missing work item message' do + expect(rendered).to have_content("Work item type cannot be found or is not supported.") + end + + it_behaves_like 'contains project link' + it_behaves_like 'no records created' + it_behaves_like 'does not contain parse error' + end + + context 'when work item type column contains disallowed entries' do + let(:results) { { success: 0, parse_error: false, type_errors: { disallowed: [6] } } } + + it 'renders with missing work item message' do + expect(rendered).to have_content("Work item type is not available.") + end + + it_behaves_like 'contains project link' + it_behaves_like 'no records created' + it_behaves_like 'does not contain parse error' + end + + context 'when CSV contains multiple kinds of work item type errors' do + let(:results) { { success: 0, parse_error: false, type_errors: { blank: [4], missing: [5], disallowed: [6] } } } + + it 'renders with missing work item message' do + expect(rendered).to have_content("Work item type is empty") + expect(rendered).to have_content("Work item type cannot be found or is not supported.") + expect(rendered).to have_content("Work item type is not available. Please check your license and permissions.") + end + + it_behaves_like 'contains project link' + it_behaves_like 'no records created' + it_behaves_like 'does not contain parse error' + end +end diff --git a/spec/views/profiles/keys/_key.html.haml_spec.rb b/spec/views/profiles/keys/_key.html.haml_spec.rb index 2ddbd3e6e14..d51bfd19c37 100644 --- a/spec/views/profiles/keys/_key.html.haml_spec.rb +++ b/spec/views/profiles/keys/_key.html.haml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'profiles/keys/_key.html.haml', feature_category: :authentication_and_authorization do +RSpec.describe 'profiles/keys/_key.html.haml', feature_category: :system_access do let_it_be(:user) { create(:user) } before do @@ -68,30 +68,21 @@ RSpec.describe 'profiles/keys/_key.html.haml', feature_category: :authentication end context 'displays the usage type' do - where(:usage_type, :usage_type_text, :displayed_buttons, :hidden_buttons, :revoke_ssh_signatures_ff) do + where(:usage_type, :usage_type_text, :displayed_buttons, :hidden_buttons) do [ - [:auth, 'Authentication', ['Remove'], ['Revoke'], true], - [:auth_and_signing, 'Authentication & Signing', %w[Remove Revoke], [], true], - [:signing, 'Signing', %w[Remove Revoke], [], true], - [:auth, 'Authentication', ['Remove'], ['Revoke'], false], - [:auth_and_signing, 'Authentication & Signing', %w[Remove], ['Revoke'], false], - [:signing, 'Signing', %w[Remove], ['Revoke'], false] + [:auth, 'Authentication', ['Remove'], ['Revoke']], + [:auth_and_signing, 'Authentication & Signing', %w[Remove Revoke], []], + [:signing, 'Signing', %w[Remove Revoke], []] ] end with_them do let(:key) { create(:key, user: user, usage_type: usage_type) } - it 'renders usage type text' do + it 'renders usage type text and remove/revoke buttons', :aggregate_failures do render expect(rendered).to have_text(usage_type_text) - end - - it 'renders remove/revoke buttons', :aggregate_failures do - stub_feature_flags(revoke_ssh_signatures: revoke_ssh_signatures_ff) - - render displayed_buttons.each do |button| expect(rendered).to have_text(button) diff --git a/spec/views/projects/edit.html.haml_spec.rb b/spec/views/projects/edit.html.haml_spec.rb index bf154b61609..aeb12abd240 100644 --- a/spec/views/projects/edit.html.haml_spec.rb +++ b/spec/views/projects/edit.html.haml_spec.rb @@ -101,4 +101,28 @@ RSpec.describe 'projects/edit' do it_behaves_like 'renders registration features prompt', :project_disabled_repository_size_limit end end + + describe 'pages menu entry callout' do + context 'with feature flag disabled' do + before do + stub_feature_flags(show_pages_in_deployments_menu: false) + end + + it 'does not show a callout' do + render + expect(rendered).not_to have_content('GitLab Pages has moved') + end + end + + context 'with feature flag enabled' do + before do + stub_feature_flags(show_pages_in_deployments_menu: true) + end + + it 'does show a callout' do + render + expect(rendered).to have_content('GitLab Pages has moved') + end + end + end end diff --git a/spec/views/projects/empty.html.haml_spec.rb b/spec/views/projects/empty.html.haml_spec.rb index 6077dda3c98..2b19b364365 100644 --- a/spec/views/projects/empty.html.haml_spec.rb +++ b/spec/views/projects/empty.html.haml_spec.rb @@ -73,9 +73,6 @@ RSpec.describe 'projects/empty' do expect(rendered).to have_content('Invite your team') expect(rendered).to have_content('Add members to this project and start collaborating with your team.') expect(rendered).to have_selector('.js-invite-members-trigger') - expect(rendered).to have_selector('.js-invite-members-modal') - expect(rendered).to have_selector('[data-label=invite_members_empty_project]') - expect(rendered).to have_selector('[data-event=click_button]') expect(rendered).to have_selector('[data-trigger-source=project-empty-page]') end @@ -87,7 +84,6 @@ RSpec.describe 'projects/empty' do expect(rendered).not_to have_content('Invite your team') expect(rendered).not_to have_selector('.js-invite-members-trigger') - expect(rendered).not_to have_selector('.js-invite-members-modal') end end end diff --git a/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb b/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb index 37c9908af1d..13ec7207ec9 100644 --- a/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb +++ b/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb @@ -22,7 +22,7 @@ RSpec.describe 'projects/pipeline_schedules/_pipeline_schedule' do let(:user) { maintainer } before do - allow(view).to receive(:can?).with(maintainer, :take_ownership_pipeline_schedule, pipeline_schedule).and_return(true) + allow(view).to receive(:can?).with(maintainer, :admin_pipeline_schedule, pipeline_schedule).and_return(true) end it 'non-owner can take ownership of pipeline' do @@ -36,7 +36,7 @@ RSpec.describe 'projects/pipeline_schedules/_pipeline_schedule' do let(:user) { owner } before do - allow(view).to receive(:can?).with(owner, :take_ownership_pipeline_schedule, pipeline_schedule).and_return(false) + allow(view).to receive(:can?).with(owner, :admin_pipeline_schedule, pipeline_schedule).and_return(false) end it 'owner cannot take ownership of pipeline' do diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb index b9c7da20d1a..81a11874886 100644 --- a/spec/views/projects/pipelines/show.html.haml_spec.rb +++ b/spec/views/projects/pipelines/show.html.haml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'projects/pipelines/show', feature_category: :pipeline_authoring do +RSpec.describe 'projects/pipelines/show', feature_category: :pipeline_composition do include Devise::Test::ControllerHelpers let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } @@ -13,6 +13,7 @@ RSpec.describe 'projects/pipelines/show', feature_category: :pipeline_authoring before do assign(:project, project) assign(:pipeline, presented_pipeline) + allow(view).to receive(:current_user) { user } end context 'when pipeline has errors' do @@ -32,6 +33,22 @@ RSpec.describe 'projects/pipelines/show', feature_category: :pipeline_authoring expect(rendered).not_to have_selector('#js-pipeline-tabs') end + + it 'renders the pipeline editor button with correct link for users who can view' do + project.add_developer(user) + + render + + expect(rendered).to have_link s_('Go to the pipeline editor'), + href: project_ci_pipeline_editor_path(project) + end + + it 'renders the pipeline editor button with correct link for users who can not view' do + render + + expect(rendered).not_to have_link s_('Go to the pipeline editor'), + href: project_ci_pipeline_editor_path(project) + end end context 'when pipeline is valid' do diff --git a/spec/views/projects/project_members/index.html.haml_spec.rb b/spec/views/projects/project_members/index.html.haml_spec.rb index 4c4cde01cca..2fcc5c6935b 100644 --- a/spec/views/projects/project_members/index.html.haml_spec.rb +++ b/spec/views/projects/project_members/index.html.haml_spec.rb @@ -28,7 +28,6 @@ RSpec.describe 'projects/project_members/index', :aggregate_failures, feature_ca expect(rendered).to have_selector('.js-invite-group-trigger') expect(rendered).to have_selector('.js-invite-members-trigger') expect(rendered).not_to have_content('Members can be added by project') - expect(response).to render_template(partial: 'projects/_invite_members_modal') end context 'when project is not allowed to share with group' do |