Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/views/layouts/application.html.haml_spec.rb')
-rw-r--r--spec/views/layouts/application.html.haml_spec.rb111
1 files changed, 64 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