gitlab-org--gitlab-foss/spec/controllers/projects/pages_controller_spec.rb
Zeger-Jan van de Weg 04cd47dd5a
Don't show references to Pages when not available
In this instance its subgroups, and given we can't deploy it, we
shouldn't allow it to be shown.

Fixes gitlab-org/gitlab-ce#34864
2017-08-31 09:27:42 +02:00

68 lines
1.4 KiB
Ruby

require 'spec_helper'
describe Projects::PagesController do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
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
expect(response).to have_http_status(200)
end
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
expect(response).to have_http_status(404)
end
end
end
describe 'DELETE destroy' do
it 'returns 302 status' do
delete :destroy, request_params
expect(response).to have_http_status(302)
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
expect(response).to have_http_status(404)
end
end
describe 'DELETE destroy' do
it 'returns 404 status' do
delete :destroy, request_params
expect(response).to have_http_status(404)
end
end
end
end