Skip to content

Commit

Permalink
AO3-6709 Use single inbox_comment_policy for controlling access to in…
Browse files Browse the repository at this point in the history
…box page for admins
  • Loading branch information
nish-shai-scacap committed Sep 20, 2024
1 parent 41df81d commit edc89f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
7 changes: 0 additions & 7 deletions app/policies/dashboard_policy.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/users/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<li><%= span_if_current t(".pitch.collections", coll_number: @user.maintained_collections.count), user_collections_path(@user) %></li>
</ul>

<% if @user == current_user || policy(:dashboard).can_view_inbox_link? %>
<% if @user == current_user || policy(:inbox_comment).show? %>
<h4 class="landmark heading"><%= t(".landmark.catch") %></h4>
<ul class="navigation actions">
<li><%= span_if_current t(".catch.inbox", inbox_number: @user.unread_inbox_comments_count.to_s), user_inbox_path(@user) %></li>
Expand Down
14 changes: 7 additions & 7 deletions spec/controllers/inbox_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
end

context "when logged in as an admin" do
context "when admin does not have correct authorization" do
context "when admin has no role" do
context "when the admin does not have the correct authorization" do
context "when the admin has no role" do
let(:admin) { create(:admin, roles: []) }

before { fake_login_admin(admin) }
Expand All @@ -34,7 +34,7 @@
end

(Admin::VALID_ROLES - %w[superadmin policy_and_abuse]).each do |role|
context "when admin has #{role} role" do
context "when the admin has the #{role} role" do
let(:admin) { create(:admin, roles: [role]) }

before { fake_login_admin(admin) }
Expand All @@ -49,7 +49,7 @@
end

%w[superadmin policy_and_abuse].each do |role|
context "when admin is authorized with the #{role} role" do
context "when the admin is authorized with the #{role} role" do
let(:admin) { create(:admin, roles: [role]) }

before { fake_login_admin(admin) }
Expand Down Expand Up @@ -114,7 +114,7 @@
let(:inbox_comment) { create(:inbox_comment, user: user) }

it "excludes deleted comments" do
inbox_comment.feedback_comment.destroy
inbox_comment.feedback_comment.destroy!
get :show, params: { user_id: user.login }
expect(assigns(:inbox_total)).to eq(0)
expect(assigns(:unread)).to eq(0)
Expand Down Expand Up @@ -187,7 +187,7 @@
let(:inbox_comment) { create(:inbox_comment, user: user) }

it "excludes deleted comments" do
inbox_comment.feedback_comment.destroy
inbox_comment.feedback_comment.destroy!
get :show, params: { user_id: user.login }
expect(assigns(:inbox_total)).to eq(0)
expect(assigns(:unread)).to eq(0)
Expand Down Expand Up @@ -267,7 +267,7 @@
end
end

context "when logged in as the same user" do
context "when logged in as the comment receiver" do
before { fake_login_known_user(user) }

context "with no comments selected" do
Expand Down

0 comments on commit edc89f6

Please sign in to comment.