summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2017-08-30 12:24:49 -0500
committerRubén Dávila <ruben@gitlab.com>2017-08-30 12:24:49 -0500
commitb9b0b37b3695d5925c3ba6cd90cdefcc3c67ba6e (patch)
tree48e37db043f5c5f487be6d992805aa60432dd3f7 /spec/controllers
parent6f03ddcdc3af1fbb840498a0e4765458079f0b0f (diff)
downloadgitlab-ce-b9b0b37b3695d5925c3ba6cd90cdefcc3c67ba6e.tar.gz
Add check for access to Namespace
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects_controller_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index c0e48046937..4459e227fb3 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -7,6 +7,38 @@ describe ProjectsController do
let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') }
+ describe 'GET new' do
+ context 'with an authenticated user' do
+ let(:group) { create(:group) }
+
+ before do
+ sign_in(user)
+ end
+
+ context 'when namespace_id param is present' do
+ context 'when user has access to the namespace' do
+ it 'renders the template' do
+ group.add_owner(user)
+
+ get :new, namespace_id: group.id
+
+ expect(response).to have_http_status(200)
+ expect(response).to render_template('new')
+ end
+ end
+
+ context 'when user does not have access to the namespace' do
+ it 'responds with status 404' do
+ get :new, namespace_id: group.id
+
+ expect(response).to have_http_status(404)
+ expect(response).not_to render_template('new')
+ end
+ end
+ end
+ end
+ end
+
describe 'GET index' do
context 'as a user' do
it 'redirects to root page' do