2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-06 11:05:50 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Admin::ProjectsController do
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:project) { create(:project, :public) }
|
2016-04-06 11:05:50 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(create(:admin))
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET /projects' do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
it 'retrieves the project for the given visibility level' do
|
2018-12-17 17:52:17 -05:00
|
|
|
get :index, params: { visibility_level: [Gitlab::VisibilityLevel::PUBLIC] }
|
2017-08-08 12:40:22 -04:00
|
|
|
|
2016-04-06 11:05:50 -04:00
|
|
|
expect(response.body).to match(project.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not retrieve the project' do
|
2018-12-17 17:52:17 -05:00
|
|
|
get :index, params: { visibility_level: [Gitlab::VisibilityLevel::INTERNAL] }
|
2017-08-08 12:40:22 -04:00
|
|
|
|
2016-05-23 19:37:59 -04:00
|
|
|
expect(response.body).not_to match(project.name)
|
2016-04-06 11:05:50 -04:00
|
|
|
end
|
2017-08-08 12:40:22 -04:00
|
|
|
|
|
|
|
it 'does not respond with projects pending deletion' do
|
|
|
|
pending_delete_project = create(:project, pending_delete: true)
|
|
|
|
|
|
|
|
get :index
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-08-08 12:40:22 -04:00
|
|
|
expect(response.body).not_to match(pending_delete_project.name)
|
|
|
|
expect(response.body).to match(project.name)
|
|
|
|
end
|
2018-03-18 18:13:17 -04:00
|
|
|
|
|
|
|
it 'does not have N+1 queries', :use_clean_rails_memory_store_caching, :request_store do
|
|
|
|
get :index
|
|
|
|
|
|
|
|
control_count = ActiveRecord::QueryRecorder.new { get :index }.count
|
|
|
|
|
|
|
|
create(:project)
|
|
|
|
|
|
|
|
expect { get :index }.not_to exceed_query_limit(control_count)
|
|
|
|
end
|
2016-04-06 11:05:50 -04:00
|
|
|
end
|
2018-10-01 22:50:48 -04:00
|
|
|
|
2019-03-18 20:01:49 -04:00
|
|
|
describe 'GET /projects.json' do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
get :index, format: :json
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to respond_with(:success) }
|
|
|
|
end
|
|
|
|
|
2018-10-01 22:50:48 -04:00
|
|
|
describe 'GET /projects/:id' do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
it 'renders show page' do
|
2018-12-17 17:52:17 -05:00
|
|
|
get :show, params: { namespace_id: project.namespace.path, id: project.path }
|
2018-10-01 22:50:48 -04:00
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(200)
|
|
|
|
expect(response.body).to match(project.name)
|
|
|
|
end
|
|
|
|
end
|
2016-04-06 11:05:50 -04:00
|
|
|
end
|