Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Site managers to remove page locks #2360

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/dashboard/_locked_pages.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<% end %>
</td>
<td>
<% if current_alchemy_user.id == page.locked_by %>
<% if (current_alchemy_user.id == page.locked_by) || can?(:manage, Alchemy::Site.current) %>
<%= form_tag(alchemy.unlock_admin_page_path(page, :redirect_to => alchemy.admin_dashboard_url)) do %>
<button class="icon_button small" title="<%= Alchemy.t(:explain_unlocking) %>">
<%= render_icon(:times, size: 'xs') %>
Expand Down
19 changes: 18 additions & 1 deletion spec/features/admin/dashboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"

RSpec.describe "Dashboard feature", type: :system do
let(:user) { create(:alchemy_dummy_user, :as_admin, name: "Joe User") }
let(:user) { create(:alchemy_dummy_user, :as_editor, name: "Joe Editor") }

before do
authorize_user(user)
Expand All @@ -27,6 +27,7 @@
expect(locked_pages_widget).to have_content "Currently locked pages"
expect(locked_pages_widget).to have_content a_page.name
expect(locked_pages_widget).to have_content "Me"
expect(locked_pages_widget).to have_css "button[title=\"#{Alchemy.t(:explain_unlocking)}\"]"
end
end

Expand All @@ -40,6 +41,22 @@
expect(locked_pages_widget).to have_content "Currently locked pages"
expect(locked_pages_widget).to have_content a_page.name
expect(locked_pages_widget).to have_content other_user.name
expect(locked_pages_widget).not_to have_css "button[title=\"#{Alchemy.t(:explain_unlocking)}\"]"
end
end

context "when logged in as admin" do
let(:user) { create(:alchemy_dummy_user, :as_admin, name: "Joe Editor") }
let(:other_user) { create(:alchemy_dummy_user, :as_admin) }

it "shows the name of the user who locked the page" do
a_page.lock_to!(other_user)
visit admin_dashboard_path
locked_pages_widget = all('div[@class="widget"]').first
expect(locked_pages_widget).to have_content "Currently locked pages"
expect(locked_pages_widget).to have_content a_page.name
expect(locked_pages_widget).to have_content other_user.name
expect(locked_pages_widget).to have_css "button[title=\"#{Alchemy.t(:explain_unlocking)}\"]"
end
end
end
Expand Down