diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/views/layouts | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/views/layouts')
5 files changed, 87 insertions, 5 deletions
diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb index 15fdfaaaa65..6752bdc8337 100644 --- a/spec/views/layouts/_head.html.haml_spec.rb +++ b/spec/views/layouts/_head.html.haml_spec.rb @@ -92,7 +92,8 @@ RSpec.describe 'layouts/_head' do before do stub_config(extra: { matomo_url: matomo_host, - matomo_site_id: 12345 + matomo_site_id: 12345, + matomo_disable_cookies: false }) end @@ -101,6 +102,19 @@ RSpec.describe 'layouts/_head' do expect(rendered).to match(/<script.*>.*var u="\/\/#{matomo_host}\/".*<\/script>/m) expect(rendered).to match(%r(<noscript>.*<img src="//#{matomo_host}/matomo.php.*</noscript>)) + expect(rendered).not_to include('_paq.push(["disableCookies"])') + end + + context 'when matomo_disable_cookies is true' do + before do + stub_config(extra: { matomo_url: matomo_host, matomo_site_id: 12345, matomo_disable_cookies: true }) + end + + it 'disables cookies' do + render + + expect(rendered).to include('_paq.push(["disableCookies"])') + 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 01892e72c97..80342cbdb41 100644 --- a/spec/views/layouts/header/_new_dropdown.haml_spec.rb +++ b/spec/views/layouts/header/_new_dropdown.haml_spec.rb @@ -10,7 +10,7 @@ RSpec.describe 'layouts/header/_new_dropdown' do before do allow(Gitlab::Experimentation).to receive(:active?).and_return(true) allow(view).to receive(:experiment_tracking_category_and_group) - allow(view).to receive(:tracking_label).with(user) + allow(view).to receive(:tracking_label) end context 'with ability to invite members' do @@ -20,8 +20,8 @@ RSpec.describe 'layouts/header/_new_dropdown' do subject expect(view).to have_received(:experiment_tracking_category_and_group) - .with(:invite_members_new_dropdown, subject: user) - expect(view).to have_received(:tracking_label).with(user) + .with(:invite_members_new_dropdown) + expect(view).to have_received(:tracking_label) 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 c5b56b15431..e34d8b91b38 100644 --- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb @@ -48,7 +48,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do end describe 'Packages' do - let(:user) { create(:user) } + let_it_be(:user) { create(:user) } let_it_be(:package_menu_name) { 'Packages & Registries' } let_it_be(:package_entry_name) { 'Package Registry' } diff --git a/spec/views/layouts/nav/sidebar/_project_security_link.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project_security_link.html.haml_spec.rb new file mode 100644 index 00000000000..d3fb35bff6d --- /dev/null +++ b/spec/views/layouts/nav/sidebar/_project_security_link.html.haml_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'layouts/nav/sidebar/_project_security_link' do + let_it_be_with_reload(:project) { create(:project) } + context 'on security configuration' do + before do + assign(:project, project) + allow(controller).to receive(:controller_name).and_return('configuration') + allow(controller).to receive(:controller_path).and_return('projects/security/configuration') + allow(controller).to receive(:action_name).and_return('show') + allow(view).to receive(:any_project_nav_tab?).and_return(true) + allow(view).to receive(:project_nav_tab?).and_return(true) + end + + it 'activates Security & Compliance tab' do + render + + expect(rendered).to have_css('li.active', text: 'Security & Compliance') + end + + it 'activates Configuration sub tab' do + render + + expect(rendered).to have_css('.sidebar-sub-level-items > li.active', text: 'Configuration') + end + end +end diff --git a/spec/views/layouts/profile.html.haml_spec.rb b/spec/views/layouts/profile.html.haml_spec.rb new file mode 100644 index 00000000000..93f8a075209 --- /dev/null +++ b/spec/views/layouts/profile.html.haml_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'layouts/profile' do + let(:user) { create(:user) } + + before do + allow(view).to receive(:session).and_return({}) + allow(view).to receive(:current_user).and_return(user) + allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(user)) + allow(view).to receive(:experiment_enabled?).and_return(false) + allow(view).to receive(:enable_search_settings).and_call_original + end + + it 'calls enable_search_settings helper with a custom container class' do + render + expect(view).to have_received(:enable_search_settings) + .with({ locals: { container_class: 'gl-my-5' } }) + end + + context 'when search_settings_in_page feature flag is on' do + it 'displays the search settings entry point' do + render + expect(rendered).to include('js-search-settings-app') + end + end + + context 'when search_settings_in_page feature flag is off' do + before do + stub_feature_flags(search_settings_in_page: false) + end + + it 'does not display the search settings entry point' do + render + expect(rendered).not_to include('js-search-settings-app') + end + end +end |