debian-mirror-gitlab/spec/controllers/admin/projects_controller_spec.rb
2019-05-18 00:54:41 +05:30

66 lines
1.6 KiB
Ruby

require 'spec_helper'
describe Admin::ProjectsController do
let!(:project) { create(:project, :public) }
before do
sign_in(create(:admin))
end
describe 'GET /projects' do
render_views
it 'retrieves the project for the given visibility level' do
get :index, params: { visibility_level: [Gitlab::VisibilityLevel::PUBLIC] }
expect(response.body).to match(project.name)
end
it 'does not retrieve the project' do
get :index, params: { visibility_level: [Gitlab::VisibilityLevel::INTERNAL] }
expect(response.body).not_to match(project.name)
end
it 'does not respond with projects pending deletion' do
pending_delete_project = create(:project, pending_delete: true)
get :index
expect(response).to have_gitlab_http_status(200)
expect(response.body).not_to match(pending_delete_project.name)
expect(response.body).to match(project.name)
end
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
end
describe 'GET /projects.json' do
render_views
before do
get :index, format: :json
end
it { is_expected.to respond_with(:success) }
end
describe 'GET /projects/:id' do
render_views
it 'renders show page' do
get :show, params: { namespace_id: project.namespace.path, id: project.path }
expect(response).to have_gitlab_http_status(200)
expect(response.body).to match(project.name)
end
end
end