summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-12 06:09:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-12 06:09:11 +0000
commit22864cafe7a3509342c3c880881ade40ce06f752 (patch)
tree046ed99ce4f03562da8e616f6686cf39eb8b6c70 /spec
parent6011d000727a1fe72472f98a8f20a91dbb637733 (diff)
downloadgitlab-ce-22864cafe7a3509342c3c880881ade40ce06f752.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/admin/admin_search_settings_spec.rb27
-rw-r--r--spec/features/profiles/user_search_settings_spec.rb42
-rw-r--r--spec/requests/git_http_spec.rb16
-rw-r--r--spec/support/helpers/search_settings_helpers.rb5
-rw-r--r--spec/support/shared_examples/features/search_settings_shared_examples.rb42
5 files changed, 97 insertions, 35 deletions
diff --git a/spec/features/admin/admin_search_settings_spec.rb b/spec/features/admin/admin_search_settings_spec.rb
new file mode 100644
index 00000000000..a78d17a6651
--- /dev/null
+++ b/spec/features/admin/admin_search_settings_spec.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Admin searches application settings', :js do
+ let_it_be(:admin) { create(:admin) }
+ let_it_be(:application_settings) { create(:application_setting) }
+
+ before do
+ sign_in(admin)
+ gitlab_enable_admin_mode_sign_in(admin)
+ end
+
+ context 'in appearances page' do
+ before do
+ visit(admin_appearances_path)
+ end
+
+ it_behaves_like 'cannot search settings'
+ end
+
+ context 'in ci/cd settings page' do
+ let(:visit_path) { ci_cd_admin_application_settings_path }
+
+ it_behaves_like 'can search settings with feature flag check', 'Variables', 'Package Registry'
+ end
+end
diff --git a/spec/features/profiles/user_search_settings_spec.rb b/spec/features/profiles/user_search_settings_spec.rb
index 5f87af0478d..60df0d7532b 100644
--- a/spec/features/profiles/user_search_settings_spec.rb
+++ b/spec/features/profiles/user_search_settings_spec.rb
@@ -3,51 +3,23 @@
require 'spec_helper'
RSpec.describe 'User searches their settings', :js do
- let(:user) { create(:user) }
- let(:search_input_placeholder) { 'Search settings' }
+ let_it_be(:user) { create(:user) }
before do
sign_in(user)
end
- context 'when search_settings_in_page feature flag is on' do
- it 'allows searching in the user profile page' do
- search_term = 'Public Avatar'
- hidden_section_name = 'Main settings'
+ context 'in profile page' do
+ let(:visit_path) { profile_path }
- visit profile_path
- fill_in search_input_placeholder, with: search_term
-
- expect(page).to have_content(search_term)
- expect(page).not_to have_content(hidden_section_name)
- end
-
- it 'allows searching in the user applications page' do
- visit applications_profile_path
-
- expect(page.find_field(placeholder: search_input_placeholder)).not_to be_disabled
- end
-
- it 'allows searching in the user preferences page' do
- search_term = 'Syntax highlighting theme'
- hidden_section_name = 'Behavior'
-
- visit profile_preferences_path
- fill_in search_input_placeholder, with: search_term
-
- expect(page).to have_content(search_term)
- expect(page).not_to have_content(hidden_section_name)
- end
+ it_behaves_like 'can search settings with feature flag check', 'Public Avatar', 'Main settings'
end
- context 'when search_settings_in_page feature flag is off' do
+ context 'in preferences page' do
before do
- stub_feature_flags(search_settings_in_page: false)
- visit(profile_path)
+ visit profile_preferences_path
end
- it 'does not allow searching in the user settings pages' do
- expect(page).not_to have_content(search_input_placeholder)
- end
+ it_behaves_like 'can search settings', 'Syntax highlighting theme', 'Behavior'
end
end
diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb
index 1ee3e36be8b..a1e28c18769 100644
--- a/spec/requests/git_http_spec.rb
+++ b/spec/requests/git_http_spec.rb
@@ -382,6 +382,14 @@ RSpec.describe 'Git HTTP requests' do
end
end
end
+
+ context 'but the service parameter is missing' do
+ it 'rejects clones with 403 Forbidden' do
+ get("/#{path}/info/refs", headers: auth_env(*env.values_at(:user, :password), nil))
+
+ expect(response).to have_gitlab_http_status(:forbidden)
+ end
+ end
end
context 'and not a member of the team' do
@@ -409,6 +417,14 @@ RSpec.describe 'Git HTTP requests' do
it_behaves_like 'pushes are allowed'
end
+
+ context 'but the service parameter is missing' do
+ it 'rejects clones with 401 Unauthorized' do
+ get("/#{path}/info/refs")
+
+ expect(response).to have_gitlab_http_status(:unauthorized)
+ end
+ end
end
end
diff --git a/spec/support/helpers/search_settings_helpers.rb b/spec/support/helpers/search_settings_helpers.rb
new file mode 100644
index 00000000000..838f897bff5
--- /dev/null
+++ b/spec/support/helpers/search_settings_helpers.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+module SearchHelpers
+ self::INPUT_PLACEHOLDER = 'Search settings'
+end
diff --git a/spec/support/shared_examples/features/search_settings_shared_examples.rb b/spec/support/shared_examples/features/search_settings_shared_examples.rb
new file mode 100644
index 00000000000..6a507c4be56
--- /dev/null
+++ b/spec/support/shared_examples/features/search_settings_shared_examples.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'cannot search settings' do
+ it 'does note have search settings field' do
+ expect(page).not_to have_field(placeholder: SearchHelpers::INPUT_PLACEHOLDER)
+ end
+end
+
+RSpec.shared_examples 'can search settings' do |search_term, non_match_section|
+ it 'has search settings field' do
+ expect(page).to have_field(placeholder: SearchHelpers::INPUT_PLACEHOLDER)
+ end
+
+ it 'hides unmatching sections on search' do
+ expect(page).to have_content(non_match_section)
+
+ fill_in SearchHelpers::INPUT_PLACEHOLDER, with: search_term
+
+ expect(page).to have_content(search_term)
+ expect(page).not_to have_content(non_match_section)
+ end
+end
+
+RSpec.shared_examples 'can search settings with feature flag check' do |search_term, non_match_section|
+ let(:flag) { true }
+
+ before do
+ stub_feature_flags(search_settings_in_page: flag)
+
+ visit(visit_path)
+ end
+
+ context 'with feature flag on' do
+ it_behaves_like 'can search settings', search_term, non_match_section
+ end
+
+ context 'with feature flag off' do
+ let(:flag) { false }
+
+ it_behaves_like 'cannot search settings'
+ end
+end