Commit a83ddb1b authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-owner-remove-pages-message' into 'master'

Only show the message if user is not the owner

Closes #323

See merge request !628
parents 13ae0aaf f5696945
- if can?(current_user, :remove_pages, @project) && @project.pages_deployed? - if @project.pages_deployed?
.panel.panel-default.panel.panel-danger - if can?(current_user, :remove_pages, @project)
.panel-heading Remove pages .panel.panel-default.panel.panel-danger
.errors-holder .panel-heading Remove pages
.panel-body .errors-holder
%p .panel-body
Removing the pages will prevent from exposing them to outside world. %p
.form-actions Removing the pages will prevent from exposing them to outside world.
= link_to 'Remove pages', namespace_project_pages_path(@project.namespace, @project), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove" .form-actions
- else = link_to 'Remove pages', namespace_project_pages_path(@project.namespace, @project), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove"
.nothing-here-block Only the project owner can remove pages - else
.nothing-here-block Only the project owner can remove pages
require 'spec_helper'
feature 'Pages', feature: true do
given(:project) { create(:empty_project) }
given(:user) { create(:user) }
given(:role) { :master }
background do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
project.team << [user, role]
login_as(user)
end
shared_examples 'no pages deployed' do
scenario 'does not see anything to destroy' do
visit namespace_project_pages_path(project.namespace, project)
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
visit namespace_project_pages_path(project.namespace, project)
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
visit namespace_project_pages_path(project.namespace, project)
expect(page).to have_text('Only the project owner can remove pages')
end
end
it_behaves_like 'no pages deployed'
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment