docbrown/spec/requests/admin/welcome_spec.rb
Josh Puetz 1c566e0ec4
[deploy] Move /internal to `/admin (#9639)
* First draft - all the big changes

* Changing some more references to 'internal'

* Relocate internal request tests to admin

* Relocate internal system tests to admin

* Fix trailing space

* Test fix

* Move queries from internal to admin

* Docs updates

* Rename internal stimuls controllers to admin (plus docs)

* Rename admin layout

* Fix routing after rebase

* Fixes for latest added admin interfaces

* Serviceworker ignore paths
2020-08-07 10:36:26 -04:00

57 lines
1.3 KiB
Ruby

require "rails_helper"
RSpec.describe "/admin/growth", 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/welcome"
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/welcome"
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: Welcome) }
before do
sign_in single_resource_admin
get "/admin/welcome"
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/welcome"
end.to raise_error(Pundit::NotAuthorizedError)
end
end
end