houdini/spec/requests/good_job_protection_spec.rb
Clarissa Lima Borges c5afb3e0b7 Set GoodJob dashboard up for super_admins
* Set GoodJob dashboard up for super_admins

Co-authored-by: Eric Schultz <eric@commitchange.com>
2021-02-24 11:25:07 -06:00

34 lines
907 B
Ruby

# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
require 'rails_helper'
# rubocop:disable RSpec/DescribeClass
describe 'GoodJob protection' do
let(:user) { create(:user) }
describe 'when it is a super_admin' do
it 'shows the good job dashboard' do
user.roles.create(name: 'super_admin')
sign_in user
get('/good_job')
expect(response).to have_http_status(:success)
end
end
describe 'when not logged in' do
it 'is redirected to log in page' do
get('/good_job')
expect(response).to have_http_status(:redirect)
end
end
describe 'when logged in but is not super_admin' do
it 'raises RoutingError' do
sign_in user
expect { get('/good_job') }.to raise_error(ActionController::RoutingError)
end
end
end
# rubocop:enable RSpec/DescribeClass