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:
Sojan Jose
2020-05-11 23:07:22 +05:30
committed by GitHub
parent 8859880e55
commit c74b5c21d7
37 changed files with 964 additions and 35 deletions

View File

@@ -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

View 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

View 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

View 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