Feature: Introduce Super Admins (#705)
* Feature: Introduce Super Admins - added new devise model for super user - added administrate gem - sample dashboards for users and accounts Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Super Admin access tokens API', type: :request do
|
||||
let(:super_admin) { create(:super_admin) }
|
||||
|
||||
describe 'GET /super_admin/access_tokens' do
|
||||
context 'when it is an unauthenticated super admin' do
|
||||
it 'returns unauthorized' do
|
||||
get '/super_admin/'
|
||||
expect(response).to have_http_status(:redirect)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an authenticated super admin' do
|
||||
it 'shows the list of access tokens' do
|
||||
sign_in super_admin
|
||||
get '/super_admin/access_tokens'
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response.body).to include('New access token')
|
||||
expect(response.body).to include(super_admin.access_token.token)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
26
spec/controllers/super_admin/accounts_controller_spec.rb
Normal file
26
spec/controllers/super_admin/accounts_controller_spec.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Super Admin accounts API', type: :request do
|
||||
let(:super_admin) { create(:super_admin) }
|
||||
|
||||
describe 'GET /super_admin/accounts' do
|
||||
context 'when it is an unauthenticated user' do
|
||||
it 'returns unauthorized' do
|
||||
get '/super_admin/accounts'
|
||||
expect(response).to have_http_status(:redirect)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an authenticated user' do
|
||||
let!(:account) { create(:account) }
|
||||
|
||||
it 'shows the list of accounts' do
|
||||
sign_in super_admin
|
||||
get '/super_admin/accounts'
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response.body).to include('New account')
|
||||
expect(response.body).to include(account.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
24
spec/controllers/super_admin/super_admins_controller_spec.rb
Normal file
24
spec/controllers/super_admin/super_admins_controller_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Super Admin super admins API', type: :request do
|
||||
let(:super_admin) { create(:super_admin) }
|
||||
|
||||
describe 'GET /super_admin/users' do
|
||||
context 'when it is an unauthenticated super admin' do
|
||||
it 'returns unauthorized' do
|
||||
get '/super_admin/super_admins'
|
||||
expect(response).to have_http_status(:redirect)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an authenticated super admin' do
|
||||
it 'shows the list of super admins' do
|
||||
sign_in super_admin
|
||||
get '/super_admin/super_admins'
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response.body).to include('New super admin')
|
||||
expect(response.body).to include(super_admin.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
26
spec/controllers/super_admin/users_controller_spec.rb
Normal file
26
spec/controllers/super_admin/users_controller_spec.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Super Admin Users API', type: :request do
|
||||
let(:super_admin) { create(:super_admin) }
|
||||
|
||||
describe 'GET /super_admin/users' do
|
||||
context 'when it is an unauthenticated super admin' do
|
||||
it 'returns unauthorized' do
|
||||
get '/super_admin/'
|
||||
expect(response).to have_http_status(:redirect)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an authenticated super admin' do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
it 'shows the list of users' do
|
||||
sign_in super_admin
|
||||
get '/super_admin'
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response.body).to include('New user')
|
||||
expect(response.body).to include(user.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user