Feature: Ability to switch between multiple accounts (#881)

* Feature: Ability to switch between multiple accounts

* Fix rubocop

* Fix assigned inboxes

* fix auth json

* Add account switcher in UI

* fix ordering on administrate

* Add switch accounts to sidebar

* add account id

* Fix schema.rb timestamp

* Revert "add account id"

This reverts commit 27570f50ef584cb9a5f69454f43f630b318c8807.

* Add a check for account

Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
Sojan Jose
2020-05-26 22:38:48 +05:30
committed by GitHub
parent b1aab228ae
commit b7a583b2c4
64 changed files with 441 additions and 212 deletions

View File

@@ -107,6 +107,7 @@ RSpec.describe 'Accounts API', type: :request do
describe 'GET /api/v1/accounts/{account.id}' do
let(:account) { create(:account) }
let(:agent) { create(:user, account: account, role: :agent) }
let(:user_without_access) { create(:user) }
let(:admin) { create(:user, account: account, role: :administrator) }
context 'when it is an unauthenticated user' do
@@ -119,9 +120,9 @@ RSpec.describe 'Accounts API', type: :request do
context 'when it is an unauthorized user' do
it 'returns unauthorized' do
get "/api/v1/accounts/#{account.id}",
headers: agent.create_new_auth_token
headers: user_without_access.create_new_auth_token
expect(response).to have_http_status(:unauthorized)
expect(response).to have_http_status(:not_found)
end
end
@@ -185,4 +186,29 @@ RSpec.describe 'Accounts API', type: :request do
end
end
end
describe 'POST /api/v1/accounts/{account.id}/update_active_at' do
let(:account) { create(:account) }
let(:agent) { create(:user, account: account, role: :agent) }
context 'when it is an unauthenticated user' do
it 'returns unauthorized' do
post "/api/v1/accounts/#{account.id}/update_active_at"
expect(response).to have_http_status(:unauthorized)
end
end
context 'when it is an authenticated user' do
it 'modifies an account' do
expect(agent.account_users.first.active_at).to eq(nil)
post "/api/v1/accounts/#{account.id}/update_active_at",
params: {},
headers: agent.create_new_auth_token,
as: :json
expect(response).to have_http_status(:success)
expect(agent.account_users.first.active_at).not_to eq(nil)
end
end
end
end