You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
5 months ago
|
require "rails_helper"
|
||
|
|
||
|
RSpec.describe "RailsAdmin", type: :request do
|
||
|
let(:user) { create(:user) }
|
||
|
let(:support_user) { create(:user, :support) }
|
||
|
let(:page) { Capybara::Node::Simple.new(response.body) }
|
||
|
|
||
|
before do
|
||
|
allow(support_user).to receive(:need_two_factor_authentication?).and_return(false)
|
||
|
end
|
||
|
|
||
|
describe "GET /admin" do
|
||
|
context "when the user is not signed in" do
|
||
|
it "routes user to the sign in page" do
|
||
|
get rails_admin_path
|
||
|
follow_redirect!
|
||
|
expect(path).to eq("/account/sign-in")
|
||
|
expect(page).to have_content("Sign in to your account")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context "when the user is signed in as a non support user" do
|
||
|
before do
|
||
|
sign_in user
|
||
|
end
|
||
|
|
||
|
it "routes user to the home page" do
|
||
|
get rails_admin_path
|
||
|
follow_redirect!
|
||
|
expect(path).to eq("/")
|
||
|
expect(page).to have_content("Welcome back")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context "when the user is signed in as a support user" do
|
||
|
before do
|
||
|
sign_in support_user
|
||
|
end
|
||
|
|
||
|
it "routes user to the admin page" do
|
||
|
get rails_admin_path
|
||
|
expect(page).to have_content("Site Administration")
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|