summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorVinnie Okada <vokada@mrvinn.com>2015-03-07 11:23:43 -0700
committerVinnie Okada <vokada@mrvinn.com>2015-03-08 16:10:05 -0600
commit285c5341855f8af6cbea5e964e3104a4698fa450 (patch)
treea73054190f441edcda4c33715c7822caeb7800ed /spec/requests
parentcacac147de2b317d02788c5da1cdc6010f00a340 (diff)
downloadgitlab-ce-285c5341855f8af6cbea5e964e3104a4698fa450.tar.gz
Allow admins to override restricted visibility
Allow admins to use restricted visibility levels when creating or updating projects.
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/projects_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 0b3a47e3273..98b31a6e0af 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -3,6 +3,7 @@ require 'spec_helper'
describe API::API, api: true do
include ApiHelpers
+ include Gitlab::CurrentSettings
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
@@ -202,6 +203,31 @@ describe API::API, api: true do
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
+
+ context 'when a visibility level is restricted' do
+ before do
+ @project = attributes_for(:project, { public: true })
+ allow_any_instance_of(ApplicationSetting).to(
+ receive(:restricted_visibility_levels).and_return([20])
+ )
+ end
+
+ it 'should not allow a non-admin to use a restricted visibility level' do
+ post api('/projects', user), @project
+ expect(response.status).to eq(400)
+ expect(json_response['message']['visibility_level'].first).to(
+ match('restricted by your GitLab administrator')
+ )
+ end
+
+ it 'should allow an admin to override restricted visibility settings' do
+ post api('/projects', admin), @project
+ expect(json_response['public']).to be_truthy
+ expect(json_response['visibility_level']).to(
+ eq(Gitlab::VisibilityLevel::PUBLIC)
+ )
+ end
+ end
end
describe 'POST /projects/user/:id' do