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
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-03-21 10:21:01 +0300
committerLin Jen-Shin <godfat@godfat.org>2017-03-21 12:18:55 +0300
commit50d73ce0ec7e33353b2d5c24eb92075d9add1b3a (patch)
tree72f9e560cc3d1388e4c558f8fb687008f6dc0500 /spec
parent9807ffaa48b15019e13364fa1152489770b549b8 (diff)
Merge branch 'sh-fix-admin-application-settings' into 'master'
Fix Error 500 when application settings are saved Closes #29674 and #29115 See merge request !10070
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin/application_settings_controller_spec.rb28
-rw-r--r--spec/features/admin/admin_settings_spec.rb7
-rw-r--r--spec/lib/gitlab/visibility_level_spec.rb21
3 files changed, 56 insertions, 0 deletions
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb
new file mode 100644
index 00000000000..84a1ce773a1
--- /dev/null
+++ b/spec/controllers/admin/application_settings_controller_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe Admin::ApplicationSettingsController do
+ include StubENV
+
+ let(:admin) { create(:admin) }
+
+ before do
+ sign_in(admin)
+ stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ end
+
+ describe 'PATCH #update' do
+ it 'updates the default_project_visibility for string value' do
+ patch :update, application_setting: { default_project_visibility: "20" }
+
+ expect(response).to redirect_to(admin_application_settings_path)
+ expect(ApplicationSetting.current.default_project_visibility).to eq Gitlab::VisibilityLevel::PUBLIC
+ end
+
+ it 'falls back to default with default_project_visibility setting is omitted' do
+ patch :update, application_setting: {}
+
+ expect(response).to redirect_to(admin_application_settings_path)
+ expect(ApplicationSetting.current.default_project_visibility).to eq Gitlab::VisibilityLevel::PRIVATE
+ end
+ end
+end
diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb
index b4095095887..03daab12c8f 100644
--- a/spec/features/admin/admin_settings_spec.rb
+++ b/spec/features/admin/admin_settings_spec.rb
@@ -9,6 +9,13 @@ feature 'Admin updates settings', feature: true do
visit admin_application_settings_path
end
+ scenario 'Change visibility settings' do
+ choose "application_setting_default_project_visibility_20"
+ click_button 'Save'
+
+ expect(page).to have_content "Application settings saved successfully"
+ end
+
scenario 'Change application settings' do
uncheck 'Gravatar enabled'
fill_in 'Home page URL', with: 'https://about.gitlab.com/'
diff --git a/spec/lib/gitlab/visibility_level_spec.rb b/spec/lib/gitlab/visibility_level_spec.rb
new file mode 100644
index 00000000000..3255c6f1ef7
--- /dev/null
+++ b/spec/lib/gitlab/visibility_level_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe Gitlab::VisibilityLevel, lib: true do
+ describe '.level_value' do
+ it 'converts "public" to integer value' do
+ expect(described_class.level_value('public')).to eq(Gitlab::VisibilityLevel::PUBLIC)
+ end
+
+ it 'converts string integer to integer value' do
+ expect(described_class.level_value('20')).to eq(20)
+ end
+
+ it 'defaults to PRIVATE when string value is not valid' do
+ expect(described_class.level_value('invalid')).to eq(Gitlab::VisibilityLevel::PRIVATE)
+ end
+
+ it 'defaults to PRIVATE when integer value is not valid' do
+ expect(described_class.level_value(100)).to eq(Gitlab::VisibilityLevel::PRIVATE)
+ end
+ end
+end