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/helpers/sidebars_helper_spec.rb')
-rw-r--r--spec/helpers/sidebars_helper_spec.rb60
1 files changed, 34 insertions, 26 deletions
diff --git a/spec/helpers/sidebars_helper_spec.rb b/spec/helpers/sidebars_helper_spec.rb
index 8d8bbcd2737..4109eb01caa 100644
--- a/spec/helpers/sidebars_helper_spec.rb
+++ b/spec/helpers/sidebars_helper_spec.rb
@@ -91,15 +91,21 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
allow(user).to receive(:pinned_nav_items).and_return({ panel_type => %w[foo bar], 'another_panel' => %w[baz] })
end
+ # Tests for logged-out sidebar context
+ it_behaves_like 'logged-out super-sidebar context'
+
+ # Tests for logged-in sidebar context below
+ it_behaves_like 'shared super sidebar context'
+ it { is_expected.to include({ is_logged_in: true }) }
+
it 'returns sidebar values from user', :use_clean_rails_memory_store_caching do
expect(subject).to include({
- current_context_header: nil,
- current_menu_items: nil,
+ is_logged_in: true,
name: user.name,
username: user.username,
avatar_url: user.avatar_url,
has_link_to_profile: helper.current_user_menu?(:profile),
- link_to_profile: user_url(user),
+ link_to_profile: user_path(user),
status: {
can_update: helper.can?(user, :update_user_status, user),
busy: user.status&.busy?,
@@ -128,26 +134,11 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
todos_dashboard_path: dashboard_todos_path,
projects_path: dashboard_projects_path,
groups_path: dashboard_groups_path,
- support_path: helper.support_url,
- display_whats_new: helper.display_whats_new?,
- whats_new_most_recent_release_items_count: helper.whats_new_most_recent_release_items_count,
- whats_new_version_digest: helper.whats_new_version_digest,
- show_version_check: helper.show_version_check?,
- gitlab_version: Gitlab.version_info,
- gitlab_version_check: helper.gitlab_version_check,
gitlab_com_but_not_canary: Gitlab.com_but_not_canary?,
gitlab_com_and_canary: Gitlab.com_and_canary?,
canary_toggle_com_url: Gitlab::Saas.canary_toggle_com_url,
- search: {
- search_path: search_path,
- issues_path: issues_dashboard_path,
- mr_path: merge_requests_dashboard_path,
- autocomplete_path: search_autocomplete_path,
- search_context: helper.header_search_context
- },
pinned_items: %w[foo bar],
- panel_type: panel_type,
- update_pins_url: pins_url,
+ update_pins_url: pins_path,
shortcut_links: [
{
title: _('Milestones'),
@@ -383,11 +374,17 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
describe 'context switcher persistent links' do
let_it_be(:public_link) do
[
- { title: s_('Navigation|Your work'), link: '/', icon: 'work' },
{ title: s_('Navigation|Explore'), link: '/explore', icon: 'compass' }
]
end
+ let_it_be(:public_links_for_user) do
+ [
+ { title: s_('Navigation|Your work'), link: '/', icon: 'work' },
+ *public_link
+ ]
+ end
+
let_it_be(:admin_area_link) do
{ title: s_('Navigation|Admin Area'), link: '/admin', icon: 'admin' }
end
@@ -405,12 +402,20 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
helper.super_sidebar_context(user, group: nil, project: nil, panel: panel, panel_type: panel_type)
end
- context 'when user is not an admin' do
- it 'returns only the public links' do
+ context 'when user is not logged in' do
+ let(:user) { nil }
+
+ it 'returns only the public links for an anonymous user' do
expect(subject[:context_switcher_links]).to eq(public_link)
end
end
+ context 'when user is not an admin' do
+ it 'returns only the public links for a user' do
+ expect(subject[:context_switcher_links]).to eq(public_links_for_user)
+ end
+ end
+
context 'when user is an admin' do
before do
allow(user).to receive(:admin?).and_return(true)
@@ -429,7 +434,7 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
it 'returns public links, admin area and leave admin mode links' do
expect(subject[:context_switcher_links]).to eq([
- *public_link,
+ *public_links_for_user,
admin_area_link,
leave_admin_mode_link
])
@@ -439,7 +444,7 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
context 'when admin mode is off' do
it 'returns public links and enter admin mode link' do
expect(subject[:context_switcher_links]).to eq([
- *public_link,
+ *public_links_for_user,
enter_admin_mode_link
])
end
@@ -453,7 +458,7 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
it 'returns public links and admin area link' do
expect(subject[:context_switcher_links]).to eq([
- *public_link,
+ *public_links_for_user,
admin_area_link
])
end
@@ -471,8 +476,11 @@ RSpec.describe SidebarsHelper, feature_category: :navigation do
end
describe 'when impersonating' do
+ before do
+ session[:impersonator_id] = 5
+ end
+
it 'sets is_impersonating to `true`' do
- expect(helper).to receive(:session).and_return({ impersonator_id: 1 })
expect(subject[:is_impersonating]).to be(true)
end
end