Created
June 19, 2018 13:35
-
-
Save cswalina/355949de225a3dfc9dfd0ccf5a853eba to your computer and use it in GitHub Desktop.
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
RailsAdmin.config do |config| | |
config.authorize_with do | |
redirect_to main_app.root_path, error: "You are not authorized." unless current_user.is_admin? | |
end | |
. | |
. | |
. | |
end | |
-------- | |
RSpec.describe "Rails Admin" do | |
describe "authentication" do | |
context "as an admin" do | |
it "allows access" do | |
sign_in create(:admin_user) | |
visit rails_admin.dashboard_path | |
expect(current_path).to eq rails_admin.dashboard_path | |
end | |
end | |
context "as a non-admin user" do | |
it "does not allow access" do | |
sign_in create(:user) | |
visit rails_admin.dashboard_path | |
expect(current_path).to eq root_path | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment