2017-04-06 23:27:35 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::PagesController do
|
|
|
|
let(:user) { create(:user) }
|
2017-08-29 06:15:19 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2017-04-06 23:27:35 -04:00
|
|
|
|
|
|
|
let(:request_params) do
|
|
|
|
{
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
|
|
|
|
sign_in(user)
|
|
|
|
project.add_master(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET show' do
|
|
|
|
it 'returns 200 status' do
|
|
|
|
get :show, request_params
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-04-06 23:27:35 -04:00
|
|
|
end
|
2017-08-29 06:15:19 -04:00
|
|
|
|
|
|
|
context 'when the project is in a subgroup' do
|
|
|
|
let(:group) { create(:group, :nested) }
|
|
|
|
let(:project) { create(:project, namespace: group) }
|
|
|
|
|
|
|
|
it 'returns a 404 status code' do
|
|
|
|
get :show, request_params
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2017-08-29 06:15:19 -04:00
|
|
|
end
|
|
|
|
end
|
2017-04-06 23:27:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'DELETE destroy' do
|
|
|
|
it 'returns 302 status' do
|
|
|
|
delete :destroy, request_params
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(302)
|
2017-04-06 23:27:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'pages disabled' do
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config.pages).to receive(:enabled).and_return(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET show' do
|
|
|
|
it 'returns 404 status' do
|
|
|
|
get :show, request_params
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2017-04-06 23:27:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'DELETE destroy' do
|
|
|
|
it 'returns 404 status' do
|
|
|
|
delete :destroy, request_params
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2017-04-06 23:27:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|