* feat: update the paths in the spec files * feat: update hardcoded paths with path helpers * chore: update hardcoded paths to path helpers * chore: hardcode describe blocks * chore: oops * feat: update some more hardcoded to use link_to's * fix broken tests * chore: admin_articles path * chore: oops remove rails helper * feat: add starting / * chore: more pre slashes * chore: add pre slashes * chore: some small typos * fix: oops
57 lines
1.3 KiB
Ruby
57 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "/admin/advanced/tools", type: :request do
|
|
context "when the user is not an admin" do
|
|
let(:user) { create(:user) }
|
|
|
|
before do
|
|
sign_in user
|
|
end
|
|
|
|
it "blocks the request" do
|
|
expect do
|
|
get admin_tools_path
|
|
end.to raise_error(Pundit::NotAuthorizedError)
|
|
end
|
|
end
|
|
|
|
context "when the user is a super admin" do
|
|
let(:super_admin) { create(:user, :super_admin) }
|
|
|
|
before do
|
|
sign_in super_admin
|
|
get admin_tools_path
|
|
end
|
|
|
|
it "allows the request" do
|
|
expect(response).to have_http_status(:ok)
|
|
end
|
|
end
|
|
|
|
context "when the user is a single resource admin" do
|
|
let(:single_resource_admin) { create(:user, :single_resource_admin, resource: Tool) }
|
|
|
|
before do
|
|
sign_in single_resource_admin
|
|
get admin_tools_path
|
|
end
|
|
|
|
it "allows the request" do
|
|
expect(response).to have_http_status(:ok)
|
|
end
|
|
end
|
|
|
|
context "when the user is the wrong single resource admin" do
|
|
let(:single_resource_admin) { create(:user, :single_resource_admin, resource: Article) }
|
|
|
|
before do
|
|
sign_in single_resource_admin
|
|
end
|
|
|
|
it "blocks the request" do
|
|
expect do
|
|
get admin_tools_path
|
|
end.to raise_error(Pundit::NotAuthorizedError)
|
|
end
|
|
end
|
|
end
|