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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-28 18:09:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-28 18:09:45 +0300
commitd62fd6e04c272d48dccde4033529ca97c27502f6 (patch)
treee3bbea524f4bccb92048fd8a52a42b757618b57b /spec/helpers
parentaaff41e10e8c03e545af9ba157e79f67686972a0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/application_settings_helper_spec.rb4
-rw-r--r--spec/helpers/nav_helper_spec.rb36
-rw-r--r--spec/helpers/sidebars_helper_spec.rb30
3 files changed, 46 insertions, 24 deletions
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb
index f924704ab54..9d591164547 100644
--- a/spec/helpers/application_settings_helper_spec.rb
+++ b/spec/helpers/application_settings_helper_spec.rb
@@ -74,6 +74,10 @@ RSpec.describe ApplicationSettingsHelper do
expect(helper.visible_attributes).to include(*params)
end
+ it 'contains :namespace_aggregation_schedule_lease_duration_in_seconds' do
+ expect(helper.visible_attributes).to include(:namespace_aggregation_schedule_lease_duration_in_seconds)
+ end
+
context 'when on SaaS', :saas do
it 'does not contain :deactivate_dormant_users' do
expect(helper.visible_attributes).not_to include(:deactivate_dormant_users)
diff --git a/spec/helpers/nav_helper_spec.rb b/spec/helpers/nav_helper_spec.rb
index 4a02b184522..4b83561b265 100644
--- a/spec/helpers/nav_helper_spec.rb
+++ b/spec/helpers/nav_helper_spec.rb
@@ -169,15 +169,39 @@ RSpec.describe NavHelper, feature_category: :navigation do
end
end
- context 'when nil is provided' do
- specify { expect(helper.show_super_sidebar?(nil)).to eq false }
+ shared_examples 'anonymous show_super_sidebar is supposed to' do
+ before do
+ stub_feature_flags(super_sidebar_logged_out: feature_flag)
+ end
+
+ context 'when super_sidebar_logged_out feature flag is disabled' do
+ let(:feature_flag) { false }
+
+ specify { expect(subject).to eq false }
+ end
+
+ context 'when super_sidebar_logged_out feature flag is enabled' do
+ let(:feature_flag) { true }
+
+ specify { expect(subject).to eq true }
+ end
end
- context 'when no user is signed-in' do
- specify do
- allow(helper).to receive(:current_user).and_return(nil)
+ context 'without a user' do
+ context 'with current_user (nil) as a default' do
+ before do
+ allow(helper).to receive(:current_user).and_return(nil)
+ end
+
+ subject { helper.show_super_sidebar? }
+
+ it_behaves_like 'anonymous show_super_sidebar is supposed to'
+ end
+
+ context 'with nil provided as an argument' do
+ subject { helper.show_super_sidebar?(nil) }
- expect(helper.show_super_sidebar?).to eq false
+ it_behaves_like 'anonymous show_super_sidebar is supposed to'
end
end
diff --git a/spec/helpers/sidebars_helper_spec.rb b/spec/helpers/sidebars_helper_spec.rb
index 8d8bbcd2737..1a81fec3a0b 100644
--- a/spec/helpers/sidebars_helper_spec.rb
+++ b/spec/helpers/sidebars_helper_spec.rb
@@ -91,10 +91,16 @@ 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,
@@ -128,25 +134,10 @@ 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,
shortcut_links: [
{
@@ -471,8 +462,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