-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AO3-6760 Check admin roles in UnsortedTagsController (#4903)
* AO3-6760 Check admin roles in UnsortedTagsController * Avoid index? permission
- Loading branch information
1 parent
a3602f8
commit b88553f
Showing
5 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe UnsortedTagsController do | ||
include LoginMacros | ||
include RedirectExpectationHelper | ||
|
||
describe "POST #mass_update" do | ||
context "when accessing as a guest" do | ||
before do | ||
post :mass_update | ||
end | ||
|
||
it "redirects with an error" do | ||
it_redirects_to_with_error( | ||
new_user_session_path, | ||
"Sorry, you don't have permission to access the page you were trying to reach. Please log in." | ||
) | ||
end | ||
end | ||
|
||
context "when logged in as a non-tag-wrangler user" do | ||
let(:user) { create(:user) } | ||
|
||
before do | ||
fake_login_known_user(user) | ||
post :mass_update | ||
end | ||
|
||
it "redirects with an error" do | ||
it_redirects_to_with_error( | ||
user_path(user), | ||
"Sorry, you don't have permission to access the page you were trying to reach." | ||
) | ||
end | ||
end | ||
|
||
context "when logged in as an admin with no roles" do | ||
before do | ||
fake_login_admin(create(:admin)) | ||
post :mass_update | ||
end | ||
|
||
it "redirects with an error" do | ||
it_redirects_to_with_error(root_path, "Sorry, only an authorized admin can access the page you were trying to reach.") | ||
end | ||
end | ||
|
||
(Admin::VALID_ROLES - %w[superadmin tag_wrangling]).each do |admin_role| | ||
context "when logged in as a #{admin_role} admin" do | ||
before do | ||
fake_login_admin(create(:admin, roles: [admin_role])) | ||
post :mass_update | ||
end | ||
|
||
it "redirects with an error" do | ||
it_redirects_to_with_error(root_path, "Sorry, only an authorized admin can access the page you were trying to reach.") | ||
end | ||
end | ||
end | ||
end | ||
end |