2016-08-18 12:24:27 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
feature 'Pages' do
|
2017-08-02 15:55:11 -04:00
|
|
|
given(:project) { create(:project) }
|
2016-08-18 12:24:27 -04:00
|
|
|
given(:user) { create(:user) }
|
|
|
|
given(:role) { :master }
|
|
|
|
|
|
|
|
background do
|
2016-08-23 09:47:22 -04:00
|
|
|
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
|
|
|
|
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_role(user, role)
|
2016-08-18 12:24:27 -04:00
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-08-18 12:24:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'no pages deployed' do
|
|
|
|
scenario 'does not see anything to destroy' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_pages_path(project)
|
2016-08-18 12:24:27 -04:00
|
|
|
|
|
|
|
expect(page).not_to have_link('Remove pages')
|
|
|
|
expect(page).not_to have_text('Only the project owner can remove pages')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user is the owner' do
|
|
|
|
background do
|
|
|
|
project.namespace.update(owner: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pages deployed' do
|
|
|
|
background do
|
|
|
|
allow_any_instance_of(Project).to receive(:pages_deployed?) { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'sees "Remove pages" link' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_pages_path(project)
|
2016-08-18 12:24:27 -04:00
|
|
|
|
|
|
|
expect(page).to have_link('Remove pages')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'no pages deployed'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the user is not the owner' do
|
|
|
|
context 'when pages deployed' do
|
|
|
|
background do
|
|
|
|
allow_any_instance_of(Project).to receive(:pages_deployed?) { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'sees "Only the project owner can remove pages" text' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_pages_path(project)
|
2016-08-18 12:24:27 -04:00
|
|
|
|
|
|
|
expect(page).to have_text('Only the project owner can remove pages')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'no pages deployed'
|
|
|
|
end
|
|
|
|
end
|