diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-08 09:10:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-08 09:10:23 +0300 |
commit | e433a55ab47846a9befaec027cfb426b0d30dda3 (patch) | |
tree | 852ab298680e256e5be102cce38aecfa72003510 /spec | |
parent | 5500dd34b9b489ee5c6609c8988bfe039f37e3e9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/views/layouts/application.html.haml_spec.rb | 111 | ||||
-rw-r--r-- | spec/views/layouts/header/_super_sidebar_logged_out.html.haml_spec.rb | 39 |
2 files changed, 103 insertions, 47 deletions
diff --git a/spec/views/layouts/application.html.haml_spec.rb b/spec/views/layouts/application.html.haml_spec.rb index a3613329984..825e295b73d 100644 --- a/spec/views/layouts/application.html.haml_spec.rb +++ b/spec/views/layouts/application.html.haml_spec.rb @@ -3,74 +3,91 @@ require 'spec_helper' RSpec.describe 'layouts/application' do - let(:user) { create(:user) } + context 'when user is signed in' do + let(:user) { create(:user) } - before do - allow(view).to receive(:current_user).and_return(user) - allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(user)) - end + before do + allow(view).to receive(:current_user).and_return(user) + allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(user)) + end - it_behaves_like 'a layout which reflects the application theme setting' - it_behaves_like 'a layout which reflects the preferred language' + it_behaves_like 'a layout which reflects the application theme setting' + it_behaves_like 'a layout which reflects the preferred language' - describe "visual review toolbar" do - context "ENV['REVIEW_APPS_ENABLED'] is set to true" do - before do - stub_env( - 'REVIEW_APPS_ENABLED' => true, - 'REVIEW_APPS_MERGE_REQUEST_IID' => '123' - ) + describe "visual review toolbar" do + context "ENV['REVIEW_APPS_ENABLED'] is set to true" do + before do + stub_env( + 'REVIEW_APPS_ENABLED' => true, + 'REVIEW_APPS_MERGE_REQUEST_IID' => '123' + ) + end + + it 'renders the visual review toolbar' do + render + + expect(rendered).to include('review-app-toolbar-script') + end end - it 'renders the visual review toolbar' do - render + context "ENV['REVIEW_APPS_ENABLED'] is set to false" do + before do + stub_env('REVIEW_APPS_ENABLED', false) + end - expect(rendered).to include('review-app-toolbar-script') + it 'does not render the visual review toolbar' do + render + + expect(rendered).not_to include('review-app-toolbar-script') + end end end - context "ENV['REVIEW_APPS_ENABLED'] is set to false" do - before do - stub_env('REVIEW_APPS_ENABLED', false) + context 'body data elements for pageview context' do + let(:body_data) do + { + body_data_page: 'projects:issues:show', + body_data_page_type_id: '1', + body_data_project_id: '2', + body_data_namespace_id: '3' + } end - it 'does not render the visual review toolbar' do + before do + allow(view).to receive(:body_data).and_return(body_data) render - - expect(rendered).not_to include('review-app-toolbar-script') end - end - end - context 'body data elements for pageview context' do - let(:body_data) do - { - body_data_page: 'projects:issues:show', - body_data_page_type_id: '1', - body_data_project_id: '2', - body_data_namespace_id: '3' - } - end + it 'includes the body element page' do + expect(rendered).to include('data-page="projects:issues:show"') + end - before do - allow(view).to receive(:body_data).and_return(body_data) - render - end + it 'includes the body element page_type_id' do + expect(rendered).to include('data-page-type-id="1"') + end - it 'includes the body element page' do - expect(rendered).to include('data-page="projects:issues:show"') - end + it 'includes the body element project_id' do + expect(rendered).to include('data-project-id="2"') + end - it 'includes the body element page_type_id' do - expect(rendered).to include('data-page-type-id="1"') + it 'includes the body element namespace_id' do + expect(rendered).to include('data-namespace-id="3"') + end end + end - it 'includes the body element project_id' do - expect(rendered).to include('data-project-id="2"') + context 'when user is not signed in' do + before do + allow(view).to receive(:current_user).and_return(nil) + allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(nil)) + Feature.enable(:super_sidebar_logged_out) end - it 'includes the body element namespace_id' do - expect(rendered).to include('data-namespace-id="3"') + it 'renders the new marketing header for logged-out users' do + allow(view).to receive(:render) + allow(view).to receive(:render).with({ template: "layouts/application" }, {}).and_call_original + render + expect(view).to have_received(:render).with({ partial: "layouts/header/super_sidebar_logged_out" }) end end end diff --git a/spec/views/layouts/header/_super_sidebar_logged_out.html.haml_spec.rb b/spec/views/layouts/header/_super_sidebar_logged_out.html.haml_spec.rb new file mode 100644 index 00000000000..89a03d72a90 --- /dev/null +++ b/spec/views/layouts/header/_super_sidebar_logged_out.html.haml_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'layouts/header/_super_sidebar_logged_out', feature_category: :navigation do + before do + allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(nil)) + Feature.enable(:super_sidebar_logged_out) + end + + context 'on gitlab.com' do + before do + allow(Gitlab).to receive(:com?).and_return(true) + render + end + + it 'renders marketing links' do + expect(rendered).to have_content('Why GitLab') + expect(rendered).to have_content('Pricing') + expect(rendered).to have_content('Contact Sales') + end + end + + context 'on self-managed' do + it 'does not render marketing links' do + render + expect(rendered).not_to have_content('Why GitLab') + expect(rendered).not_to have_content('Pricing') + expect(rendered).not_to have_content('Contact Sales') + end + end + + it 'renders links to Explore and Sign-in and Register' do + render + expect(rendered).to have_content('Explore') + expect(rendered).to have_content('Sign in') + expect(rendered).to have_content('Register') + end +end |