diff options
Diffstat (limited to 'spec/views')
28 files changed, 421 insertions, 104 deletions
diff --git a/spec/views/admin/sessions/new.html.haml_spec.rb b/spec/views/admin/sessions/new.html.haml_spec.rb index 97528b6e782..ac35bbef5b4 100644 --- a/spec/views/admin/sessions/new.html.haml_spec.rb +++ b/spec/views/admin/sessions/new.html.haml_spec.rb @@ -19,9 +19,9 @@ RSpec.describe 'admin/sessions/new.html.haml' do it 'shows enter password form' do render - expect(rendered).to have_selector('[data-qa-selector="sign_in_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).to have_selector('[data-testid="sign-in-tab"]') expect(rendered).to have_css('#login-pane.active') - expect(rendered).to have_selector('[data-qa-selector="password_field"]') # rubocop:disable QA/SelectorUsage + expect(rendered).to have_selector('[data-testid="password-field"]') end it 'warns authentication not possible if password not set' do @@ -60,7 +60,7 @@ RSpec.describe 'admin/sessions/new.html.haml' do it 'is shown when enabled' do render - expect(rendered).to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).to have_selector('[data-testid="ldap-tab"]') expect(rendered).to have_css('.login-box#ldapmain') expect(rendered).to have_field('LDAP Username') expect(rendered).not_to have_content('No authentication methods configured') @@ -71,7 +71,7 @@ RSpec.describe 'admin/sessions/new.html.haml' do render - expect(rendered).not_to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).not_to have_selector('[data-testid="ldap-tab"]') expect(rendered).not_to have_field('LDAP Username') expect(rendered).to have_content('No authentication methods configured') end diff --git a/spec/views/dashboard/projects/_blank_state_welcome.html.haml_spec.rb b/spec/views/dashboard/projects/_blank_state_welcome.html.haml_spec.rb index edec46ad0a3..6f6596caabb 100644 --- a/spec/views/dashboard/projects/_blank_state_welcome.html.haml_spec.rb +++ b/spec/views/dashboard/projects/_blank_state_welcome.html.haml_spec.rb @@ -3,15 +3,65 @@ require 'spec_helper' RSpec.describe 'dashboard/projects/_blank_state_welcome.html.haml' do - let_it_be(:user) { create(:user) } + context 'with regular user' do + context 'with project creation enabled' do + let_it_be(:user) { create(:user) } - before do - allow(view).to receive(:current_user).and_return(user) + before do + allow(view).to receive(:current_user).and_return(user) + end + + it 'has a doc_url' do + render + + expect(rendered).to have_link(href: Gitlab::Saas.doc_url) + end + + it "shows create project panel" do + render + + expect(rendered).to include(_('Create a project')) + end + end + + context 'with project creation disabled' do + let_it_be(:user_projects_limit) { create(:user, projects_limit: 0 ) } + + before do + allow(view).to receive(:current_user).and_return(user_projects_limit) + end + + it "doesn't show create project panel" do + render + + expect(rendered).not_to include(_('Create a project')) + end + + it 'shows an alert' do + render + + expect(rendered).to include(_("You see projects here when you're added to a group or project.")) + end + end end - it 'has a doc_url' do - render + context 'with external user' do + let_it_be(:external_user) { create(:user, :external) } + + before do + allow(view).to receive(:current_user).and_return(external_user) + end + + it "doesn't show create project panel" do + render + + expect(rendered).not_to include(_('Create a project')) + end + + it 'shows an alert' do + render - expect(rendered).to have_link(href: Gitlab::Saas.doc_url) + expect(rendered).to include(_("You see projects here when you're added to a group or project.")) + 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 c8e9aa15287..798c891e75c 100644 --- a/spec/views/devise/sessions/new.html.haml_spec.rb +++ b/spec/views/devise/sessions/new.html.haml_spec.rb @@ -55,7 +55,7 @@ RSpec.describe 'devise/sessions/new' do render expect(rendered).to have_selector('.new-session-tabs') - expect(rendered).to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).to have_selector('[data-testid="ldap-tab"]') expect(rendered).to have_field('LDAP Username') end @@ -65,7 +65,7 @@ RSpec.describe 'devise/sessions/new' do render expect(rendered).to have_content('No authentication methods configured') - expect(rendered).not_to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).not_to have_selector('[data-testid="ldap-tab"]') expect(rendered).not_to have_field('LDAP Username') 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 b0730e6fc54..ee9ccbf6ff5 100644 --- a/spec/views/devise/shared/_signup_box.html.haml_spec.rb +++ b/spec/views/devise/shared/_signup_box.html.haml_spec.rb @@ -7,13 +7,15 @@ RSpec.describe 'devise/shared/_signup_box' do let(:terms_path) { '_terms_path_' } let(:translation_com) do - s_("SignUp|By clicking %{button_text}, I agree that I have read and accepted "\ - "the GitLab %{link_start}Terms of Use and Privacy Policy%{link_end}") + s_("SignUp|By clicking %{button_text} or registering through a third party you "\ + "accept the GitLab%{link_start} Terms of Use and acknowledge the Privacy Policy "\ + "and Cookie Policy%{link_end}") end let(:translation_non_com) do - s_("SignUp|By clicking %{button_text}, I agree that I have read and accepted "\ - "the %{link_start}Terms of Use and Privacy Policy%{link_end}") + s_("SignUp|By clicking %{button_text} or registering through a third party you "\ + "accept the%{link_start} Terms of Use and acknowledge the Privacy Policy and "\ + "Cookie Policy%{link_end}") end before do diff --git a/spec/views/groups/new.html.haml_spec.rb b/spec/views/groups/new.html.haml_spec.rb index 8b12cc42a88..5c7378e8dc7 100644 --- a/spec/views/groups/new.html.haml_spec.rb +++ b/spec/views/groups/new.html.haml_spec.rb @@ -25,4 +25,15 @@ RSpec.describe 'groups/new.html.haml' do expect(rendered).not_to have_checked_field('Just me') end end + + context 'when a subgroup' do + let_it_be(:group) { create(:group, :nested) } + + it 'renders the visibility level section' do + expect(rendered).to have_content('Visibility level') + expect(rendered).to have_field('Private') + expect(rendered).to have_field('Internal') + expect(rendered).to have_field('Public') + end + end end diff --git a/spec/views/groups/observability.html.haml_spec.rb b/spec/views/groups/observability.html.haml_spec.rb new file mode 100644 index 00000000000..db280d5a2ba --- /dev/null +++ b/spec/views/groups/observability.html.haml_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'groups/observability/index' do + let_it_be(:iframe_url) { "foo.test" } + + before do + assign(:observability_iframe_src, iframe_url) + end + + it 'renders as expected' do + render + page = Capybara.string(rendered) + iframe = page.find('iframe#observability-ui-iframe') + expect(iframe['src']).to eq(iframe_url) + end +end diff --git a/spec/views/help/drawers.html.haml_spec.rb b/spec/views/help/drawers.html.haml_spec.rb new file mode 100644 index 00000000000..b250d00bb20 --- /dev/null +++ b/spec/views/help/drawers.html.haml_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'help/drawers' do + describe 'Markdown rendering' do + before do + allow(view).to receive(:get_markdown_without_frontmatter).and_return('[GitLab](https://about.gitlab.com/)') + assign(:clean_path, 'user/ssh') + end + + it 'renders Markdown' do + render + + expect(rendered).to have_link('GitLab', href: 'https://about.gitlab.com/') + end + end +end diff --git a/spec/views/help/instance_configuration.html.haml_spec.rb b/spec/views/help/instance_configuration.html.haml_spec.rb index fbf84a5d272..4461eadf1a3 100644 --- a/spec/views/help/instance_configuration.html.haml_spec.rb +++ b/spec/views/help/instance_configuration.html.haml_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'help/instance_configuration' do describe 'General Sections:' do - let(:instance_configuration) { build(:instance_configuration)} + let(:instance_configuration) { build(:instance_configuration) } let(:settings) { instance_configuration.settings } let(:ssh_settings) { settings[:ssh_algorithms_hashes] } diff --git a/spec/views/layouts/_header_search.html.haml_spec.rb b/spec/views/layouts/_header_search.html.haml_spec.rb index 3ab4ae6a483..3a21bb3a92c 100644 --- a/spec/views/layouts/_header_search.html.haml_spec.rb +++ b/spec/views/layouts/_header_search.html.haml_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'layouts/_header_search' do let(:scope) { nil } let(:ref) { nil } let(:code_search) { false } - let(:for_snippets) { false} + let(:for_snippets) { false } let(:header_search_context) do { diff --git a/spec/views/layouts/_published_experiments.html.haml_spec.rb b/spec/views/layouts/_published_experiments.html.haml_spec.rb index 84894554bd9..072e4f2074e 100644 --- a/spec/views/layouts/_published_experiments.html.haml_spec.rb +++ b/spec/views/layouts/_published_experiments.html.haml_spec.rb @@ -13,10 +13,10 @@ RSpec.describe 'layouts/_published_experiments', :experiment do test_variant: :variant_name ) - experiment(:test_control) { } + experiment(:test_control) {} experiment(:test_excluded) { |e| e.exclude! } - experiment(:test_candidate) { |e| e.candidate { } } - experiment(:test_variant) { |e| e.variant(:variant_name) { } } + experiment(:test_candidate) { |e| e.candidate {} } + experiment(:test_variant) { |e| e.variant(:variant_name) {} } experiment(:test_published_only).publish render diff --git a/spec/views/layouts/fullscreen.html.haml_spec.rb b/spec/views/layouts/fullscreen.html.haml_spec.rb index 0ae2c76ebcb..14b382bc238 100644 --- a/spec/views/layouts/fullscreen.html.haml_spec.rb +++ b/spec/views/layouts/fullscreen.html.haml_spec.rb @@ -9,5 +9,46 @@ RSpec.describe 'layouts/fullscreen' do allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(user)) end + it 'renders a flex container' do + render + + expect(rendered).to have_selector(".gl--flex-full.gl-h-full") + expect(rendered).to have_selector(".gl--flex-full.gl-w-full") + end + it_behaves_like 'a layout which reflects the application theme setting' + + describe 'sidebar' do + context 'when nav is set' do + before do + allow(view).to receive(:nav).and_return("admin") + render + end + + it 'renders the sidebar' do + expect(rendered).to render_template("layouts/nav/sidebar/_admin") + expect(rendered).to have_selector("aside.nav-sidebar") + end + + it 'adds the proper classes' do + expect(rendered).to have_selector(".layout-page.gl-mt-0\\!") + end + end + + describe 'when nav is not set' do + before do + allow(view).to receive(:nav).and_return(nil) + render + end + + it 'does not render the sidebar' do + expect(rendered).not_to render_template("layouts/nav/sidebar/_admin") + expect(rendered).not_to have_selector("aside.nav-sidebar") + end + + it 'not add classes' do + expect(rendered).not_to have_selector(".layout-page.gl-mt-0\\!") + end + end + 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 79c22871b44..17251049c57 100644 --- a/spec/views/layouts/header/_new_dropdown.haml_spec.rb +++ b/spec/views/layouts/header/_new_dropdown.haml_spec.rb @@ -166,7 +166,7 @@ RSpec.describe 'layouts/header/_new_dropdown' do let(:user) { create(:user, :external) } it 'is nil' do - # We have to us `view.render` because `render` causes issues + # We have to use `view.render` because `render` causes issues # https://github.com/rails/rails/issues/41320 expect(view.render("layouts/header/new_dropdown")).to be_nil end diff --git a/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb index 428e9cc8490..472a2f3cb34 100644 --- a/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb @@ -109,7 +109,7 @@ RSpec.describe 'layouts/nav/sidebar/_group' do end end - describe 'Packages & Registries' do + describe 'Packages and registries' do it 'has a link to the package registry page' do stub_config(packages: { enabled: true }) @@ -178,10 +178,10 @@ RSpec.describe 'layouts/nav/sidebar/_group' do expect(rendered).to have_link('Applications', href: group_settings_applications_path(group)) end - it 'has a link to the Package & Registries settings page' do + it 'has a link to the Package and registry settings page' do render - expect(rendered).to have_link('Packages & Registries', href: group_settings_packages_and_registries_path(group)) + expect(rendered).to have_link('Packages and registries', href: group_settings_packages_and_registries_path(group)) end end end 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 9ae3f814679..e7d9a8a4708 100644 --- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb @@ -70,8 +70,8 @@ RSpec.describe 'layouts/nav/sidebar/_project' do describe 'Learn GitLab' do it 'has a link to the learn GitLab' do allow(view).to receive(:learn_gitlab_enabled?).and_return(true) - allow_next_instance_of(LearnGitlab::Onboarding) do |onboarding| - expect(onboarding).to receive(:completed_percentage).and_return(20) + allow_next_instance_of(Onboarding::Completion) do |onboarding| + expect(onboarding).to receive(:percentage).and_return(20) end render @@ -559,7 +559,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do it 'top level navigation link is visible and points to package registry page' do render - expect(rendered).to have_link('Packages & Registries', href: project_packages_path(project)) + expect(rendered).to have_link('Packages and registries', href: project_packages_path(project)) end describe 'Packages Registry' do @@ -908,7 +908,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do end end - describe 'Packages & Registries' do + describe 'Packages and registries' do let(:packages_enabled) { false } before do @@ -919,20 +919,20 @@ RSpec.describe 'layouts/nav/sidebar/_project' do context 'when registry is enabled' do let(:registry_enabled) { true } - it 'has a link to the Packages & Registries settings' do + it 'has a link to the Package and registry settings' do render - expect(rendered).to have_link('Packages & Registries', href: project_settings_packages_and_registries_path(project)) + expect(rendered).to have_link('Packages and registries', href: project_settings_packages_and_registries_path(project)) end end context 'when registry is not enabled' do let(:registry_enabled) { false } - it 'does not have a link to the Packages & Registries settings' do + it 'does not have a link to the Package and registry settings' do render - expect(rendered).not_to have_link('Packages & Registries', href: project_settings_packages_and_registries_path(project)) + expect(rendered).not_to have_link('Packages and registries', href: project_settings_packages_and_registries_path(project)) end end @@ -940,10 +940,10 @@ RSpec.describe 'layouts/nav/sidebar/_project' do let(:registry_enabled) { false } let(:packages_enabled) { true } - it 'has a link to the Packages & Registries settings' do + it 'has a link to the Package and registry settings' do render - expect(rendered).to have_link('Packages & Registries', href: project_settings_packages_and_registries_path(project)) + expect(rendered).to have_link('Packages and registries', href: project_settings_packages_and_registries_path(project)) end end end diff --git a/spec/views/notify/approved_merge_request_email.html.haml_spec.rb b/spec/views/notify/approved_merge_request_email.html.haml_spec.rb new file mode 100644 index 00000000000..7d19e628eb8 --- /dev/null +++ b/spec/views/notify/approved_merge_request_email.html.haml_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'email_spec' + +RSpec.describe 'notify/approved_merge_request_email.html.haml' do + let(:user) { create(:user) } + let(:merge_request) { create(:merge_request) } + let(:group) { create(:group) } + let(:project) { create(:project, group: group) } + + before do + allow(view).to receive(:message) { instance_double(Mail::Message, subject: 'Subject') } + assign(:project, project) + assign(:approved_by, user) + assign(:merge_request, merge_request) + end + + it 'contains approval information' do + render + + expect(rendered).to have_content(merge_request.to_reference.to_s) + expect(rendered).to have_content("was approved by") + expect(rendered).to have_content(user.name.to_s) + end +end diff --git a/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb b/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb index c3cb0c83f35..d8299d637e1 100644 --- a/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb +++ b/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb @@ -30,7 +30,7 @@ RSpec.describe 'notify/autodevops_disabled_email.text.erb' do expect(rendered).to have_content("Auto DevOps pipeline was disabled for #{project.name}") expect(rendered).to match(/Pipeline ##{pipeline.id} .* triggered by #{pipeline.user.name}/) - expect(rendered).to have_content("Stage: #{build.stage}") + expect(rendered).to have_content("Stage: #{build.stage_name}") expect(rendered).to have_content("Name: #{build.name}") expect(rendered).not_to have_content("Trace:") end diff --git a/spec/views/notify/change_in_merge_request_draft_status_email.html.haml_spec.rb b/spec/views/notify/change_in_merge_request_draft_status_email.html.haml_spec.rb index 6d56145144f..deef13fec99 100644 --- a/spec/views/notify/change_in_merge_request_draft_status_email.html.haml_spec.rb +++ b/spec/views/notify/change_in_merge_request_draft_status_email.html.haml_spec.rb @@ -12,10 +12,25 @@ RSpec.describe 'notify/change_in_merge_request_draft_status_email.html.haml' do assign(:merge_request, merge_request) end + it 'shows user added draft status on email' do + merge_request.update!(title: merge_request.draft_title) + + render + + expect(merge_request.draft).to be_truthy + expect(rendered).to have_content("#{user.name} marked merge request #{merge_request.to_reference} as draft") + end + + it 'shows user removed draft status on email' do + render + + expect(merge_request.draft).to be_falsy + expect(rendered).to have_content("#{user.name} marked merge request #{merge_request.to_reference} as ready") + end + it 'renders the email correctly' do render - expect(rendered).to have_content("#{user.name} changed the draft status of merge request #{merge_request.to_reference}") expect(rendered).to have_link(user.name, href: user_url(user)) expect(rendered).to have_link(merge_request.to_reference, href: merge_request_link) end diff --git a/spec/views/notify/change_in_merge_request_draft_status_email.text.erb_spec.rb b/spec/views/notify/change_in_merge_request_draft_status_email.text.erb_spec.rb index a05c20fd8c4..3faba483516 100644 --- a/spec/views/notify/change_in_merge_request_draft_status_email.text.erb_spec.rb +++ b/spec/views/notify/change_in_merge_request_draft_status_email.text.erb_spec.rb @@ -12,9 +12,19 @@ RSpec.describe 'notify/change_in_merge_request_draft_status_email.text.erb' do it_behaves_like 'renders plain text email correctly' - it 'renders the email correctly' do + it 'shows user added draft status on email' do + merge_request.update!(title: merge_request.draft_title) + + render + + expect(merge_request.draft).to be_truthy + expect(rendered).to have_content("#{user.name} marked merge request #{merge_request.to_reference} as draft") + end + + it 'shows user removed draft status on email' do render - expect(rendered).to have_content("#{user.name} changed the draft status of merge request #{merge_request.to_reference}") + expect(merge_request.draft).to be_falsy + expect(rendered).to have_content("#{user.name} marked merge request #{merge_request.to_reference} as ready") 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 new file mode 100644 index 00000000000..43dfab87ac9 --- /dev/null +++ b/spec/views/notify/import_issues_csv_email.html.haml_spec.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +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(:parse_error_results) { { success: 0, parse_error: true } } + + before do + assign(:user, user) + assign(:project, project) + end + + context 'when no errors found while importing' do + before do + assign(:results, correct_results) + end + + it 'renders correctly' do + render + + expect(rendered).to have_link(project.full_name, href: project_url(project)) + expect(rendered).to have_content("3 issues imported") + expect(rendered).not_to have_content("Errors found on line") + expect(rendered).not_to have_content( + "Error parsing CSV file. Please make sure it has the correct format: \ +a delimited text file that uses a comma to separate values.") + end + end + + context 'when import errors reported' do + before do + assign(:results, errored_results) + end + + it 'renders correctly' do + render + + expect(rendered).to have_content("Errors found on lines: #{errored_results[:error_lines].join(", ")}. \ +Please check if these lines have an issue title.") + expect(rendered).not_to have_content("Error parsing CSV file. Please make sure it has the correct format: \ +a delimited text file that uses a comma to separate values.") + end + end + + context 'when parse error reported while importing' do + before do + assign(:results, parse_error_results) + end + + it 'renders with parse error' do + render + + expect(rendered).to have_content("Error parsing CSV file. \ +Please make sure it has the correct format: a delimited text file that uses a comma to separate values.") + end + end +end diff --git a/spec/views/profiles/keys/_form.html.haml_spec.rb b/spec/views/profiles/keys/_form.html.haml_spec.rb index c807512a11a..3c61afb21c5 100644 --- a/spec/views/profiles/keys/_form.html.haml_spec.rb +++ b/spec/views/profiles/keys/_form.html.haml_spec.rb @@ -33,9 +33,9 @@ RSpec.describe 'profiles/keys/_form.html.haml' do end it 'has the expires at field', :aggregate_failures do - expect(rendered).to have_field('Expiration date', type: 'date') + expect(rendered).to have_field('Expiration date', type: 'text') expect(page.find_field('Expiration date')['min']).to eq(l(1.day.from_now, format: "%Y-%m-%d")) - expect(rendered).to have_text('Key becomes invalid on this date') + expect(rendered).to have_text( s_('Profiles|Optional but recommended. If set, key becomes invalid on the specified date.')) end it 'has the validation warning', :aggregate_failures do diff --git a/spec/views/profiles/preferences/show.html.haml_spec.rb b/spec/views/profiles/preferences/show.html.haml_spec.rb index 2fe941b9f14..4e4499c3252 100644 --- a/spec/views/profiles/preferences/show.html.haml_spec.rb +++ b/spec/views/profiles/preferences/show.html.haml_spec.rb @@ -54,8 +54,8 @@ RSpec.describe 'profiles/preferences/show' do end it 'has helpful homepage setup guidance' do - expect(rendered).to have_field('Homepage content') - expect(rendered).to have_content('Choose what content you want to see on your homepage.') + expect(rendered).to have_field('Dashboard') + expect(rendered).to have_content('Choose what content you want to see by default on your dashboard.') end end diff --git a/spec/views/profiles/show.html.haml_spec.rb b/spec/views/profiles/show.html.haml_spec.rb index daa1d20e6b1..5751d47ee97 100644 --- a/spec/views/profiles/show.html.haml_spec.rb +++ b/spec/views/profiles/show.html.haml_spec.rb @@ -17,6 +17,11 @@ RSpec.describe 'profiles/show' do expect(rendered).to have_field('user_name', with: user.name) expect(rendered).to have_field('user_id', with: user.id) + + expectd_link = help_page_path('user/profile/index', anchor: 'change-the-email-displayed-on-your-commits') + expected_link_html = "<a href=\"#{expectd_link}\" target=\"_blank\" " \ + "rel=\"noopener noreferrer\">#{_('Learn more.')}</a>" + expect(rendered.include?(expected_link_html)).to eq(true) end end end diff --git a/spec/views/projects/edit.html.haml_spec.rb b/spec/views/projects/edit.html.haml_spec.rb index a85ddf7a005..2935e4395ba 100644 --- a/spec/views/projects/edit.html.haml_spec.rb +++ b/spec/views/projects/edit.html.haml_spec.rb @@ -28,62 +28,6 @@ RSpec.describe 'projects/edit' do end end - context 'merge suggestions settings' do - it 'displays a placeholder if none is set' do - render - - expect(rendered).to have_field('project[suggestion_commit_message]', placeholder: "Apply %{suggestions_count} suggestion(s) to %{files_count} file(s)") - end - - it 'displays the user entered value' do - project.update!(suggestion_commit_message: 'refactor: changed %{file_paths}') - - render - - expect(rendered).to have_field('project[suggestion_commit_message]', with: 'refactor: changed %{file_paths}') - end - end - - context 'merge commit template' do - it 'displays default template if none is set' do - render - - expect(rendered).to have_field('project[merge_commit_template_or_default]', with: <<~MSG.rstrip) - Merge branch '%{source_branch}' into '%{target_branch}' - - %{title} - - %{issues} - - See merge request %{reference} - MSG - end - - it 'displays the user entered value' do - project.update!(merge_commit_template: '%{title}') - - render - - expect(rendered).to have_field('project[merge_commit_template_or_default]', with: '%{title}') - end - end - - context 'squash template' do - it 'displays default template if none is set' do - render - - expect(rendered).to have_field('project[squash_commit_template_or_default]', with: '%{title}') - end - - it 'displays the user entered value' do - project.update!(squash_commit_template: '%{first_multiline_commit}') - - render - - expect(rendered).to have_field('project[squash_commit_template_or_default]', with: '%{first_multiline_commit}') - end - end - context 'forking' do before do assign(:project, project) diff --git a/spec/views/projects/imports/new.html.haml_spec.rb b/spec/views/projects/imports/new.html.haml_spec.rb index 7c171ee65b9..7f537022445 100644 --- a/spec/views/projects/imports/new.html.haml_spec.rb +++ b/spec/views/projects/imports/new.html.haml_spec.rb @@ -14,7 +14,7 @@ RSpec.describe "projects/imports/new.html.haml" do project.add_maintainer(user) end - it "escapes HTML in import errors" do + it "escapes HTML in import errors", :skip_html_escaped_tags_check do assign(:project, project) render diff --git a/spec/views/projects/settings/merge_requests/show.html.haml_spec.rb b/spec/views/projects/settings/merge_requests/show.html.haml_spec.rb new file mode 100644 index 00000000000..821f430eb10 --- /dev/null +++ b/spec/views/projects/settings/merge_requests/show.html.haml_spec.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/settings/merge_requests/show' do + include Devise::Test::ControllerHelpers + include ProjectForksHelper + + let(:project) { create(:project) } + let(:user) { create(:admin) } + + before do + assign(:project, project) + + allow(controller).to receive(:current_user).and_return(user) + allow(view).to receive_messages(current_user: user, + can?: true, + current_application_settings: Gitlab::CurrentSettings.current_application_settings) + end + + describe 'merge suggestions settings' do + it 'displays a placeholder if none is set' do + render + + placeholder = "Apply %{suggestions_count} suggestion(s) to %{files_count} file(s)" + + expect(rendered).to have_field('project[suggestion_commit_message]', placeholder: placeholder) + end + + it 'displays the user entered value' do + project.update!(suggestion_commit_message: 'refactor: changed %{file_paths}') + + render + + expect(rendered).to have_field('project[suggestion_commit_message]', with: 'refactor: changed %{file_paths}') + end + end + + describe 'merge commit template' do + it 'displays default template if none is set' do + render + + expect(rendered).to have_field('project[merge_commit_template_or_default]', with: <<~MSG.rstrip) + Merge branch '%{source_branch}' into '%{target_branch}' + + %{title} + + %{issues} + + See merge request %{reference} + MSG + end + + it 'displays the user entered value' do + project.update!(merge_commit_template: '%{title}') + + render + + expect(rendered).to have_field('project[merge_commit_template_or_default]', with: '%{title}') + end + end + + describe 'squash template' do + it 'displays default template if none is set' do + render + + expect(rendered).to have_field('project[squash_commit_template_or_default]', with: '%{title}') + end + + it 'displays the user entered value' do + project.update!(squash_commit_template: '%{first_multiline_commit}') + + render + + expect(rendered).to have_field('project[squash_commit_template_or_default]', with: '%{first_multiline_commit}') + end + end +end diff --git a/spec/views/projects/tags/index.html.haml_spec.rb b/spec/views/projects/tags/index.html.haml_spec.rb index aff233b697f..99db5d9e2a8 100644 --- a/spec/views/projects/tags/index.html.haml_spec.rb +++ b/spec/views/projects/tags/index.html.haml_spec.rb @@ -7,8 +7,8 @@ RSpec.describe 'projects/tags/index.html.haml' do let_it_be(:git_tag) { project.repository.tags.last } let_it_be(:release) do create(:release, project: project, - sha: git_tag.target_commit.sha, - tag: 'v1.1.0') + sha: git_tag.target_commit.sha, + tag: 'v1.1.0') end let(:pipeline) { create(:ci_pipeline, :success, project: project, ref: git_tag.name, sha: release.sha) } diff --git a/spec/views/shared/runners/_runner_details.html.haml_spec.rb b/spec/views/shared/runners/_runner_details.html.haml_spec.rb index cdf5ec563d0..978750c8435 100644 --- a/spec/views/shared/runners/_runner_details.html.haml_spec.rb +++ b/spec/views/shared/runners/_runner_details.html.haml_spec.rb @@ -113,14 +113,14 @@ RSpec.describe 'shared/runners/_runner_details.html.haml' do describe 'Tags value' do context 'when runner does not have tags' do it { is_expected.to have_content('Tags') } - it { is_expected.not_to have_selector('span.gl-badge.badge.badge-info')} + it { is_expected.not_to have_selector('span.gl-badge.badge.badge-info') } end context 'when runner have tags' do let(:runner) { create(:ci_runner, tag_list: %w(tag2 tag3 tag1)) } it { is_expected.to have_content('Tags tag1 tag2 tag3') } - it { is_expected.to have_selector('span.gl-badge.badge.badge-info')} + it { is_expected.to have_selector('span.gl-badge.badge.badge-info') } end end diff --git a/spec/views/shared/web_hooks/_web_hook_disabled_alert.html.haml_spec.rb b/spec/views/shared/web_hooks/_web_hook_disabled_alert.html.haml_spec.rb new file mode 100644 index 00000000000..22ed8bb262c --- /dev/null +++ b/spec/views/shared/web_hooks/_web_hook_disabled_alert.html.haml_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'shared/web_hooks/_web_hook_disabled_alert' do + let_it_be(:project) { create(:project) } + + let(:show_project_hook_failed_callout?) { false } + + def after_flash_content + view.content_for(:after_flash_content) + end + + before do + assign(:project, project) + allow(view).to receive(:show_project_hook_failed_callout?).and_return(show_project_hook_failed_callout?) + end + + context 'when show_project_hook_failed_callout? is true' do + let(:show_project_hook_failed_callout?) { true } + + it 'adds alert to `:after_flash_content`' do + render + + expect(after_flash_content).to have_content('Webhook disabled') + end + end + + context 'when show_project_hook_failed_callout? is false' do + it 'does not add alert to `:after_flash_content`' do + # We have to use `view.render` because `render` causes issues + # https://github.com/rails/rails/issues/41320 + view.render('shared/web_hooks/web_hook_disabled_alert') + + expect(after_flash_content).to be_nil + end + end +end |