Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
80 lines
2.5 KiB
Ruby
80 lines
2.5 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe 'Super Admin accounts API', type: :request do
|
|
include ActiveJob::TestHelper
|
|
|
|
let!(:super_admin) { create(:super_admin) }
|
|
let!(:account) { create(:account) }
|
|
|
|
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
|
|
it 'shows the list of accounts' do
|
|
sign_in(super_admin, scope: :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
|
|
|
|
describe 'POST /super_admin/accounts/{account_id}/reset_cache' do
|
|
before do
|
|
create(:label, account: account)
|
|
create(:inbox, account: account)
|
|
create(:team, account: account)
|
|
end
|
|
|
|
context 'when it is an unauthenticated user' do
|
|
it 'returns unauthorized' do
|
|
post "/super_admin/accounts/#{account.id}/reset_cache"
|
|
expect(response).to have_http_status(:redirect)
|
|
end
|
|
end
|
|
|
|
context 'when it is an authenticated user' do
|
|
it 'shows the list of accounts' do
|
|
expect(account.cache_keys.keys).to contain_exactly(:inbox, :label, :team)
|
|
sign_in(super_admin, scope: :super_admin)
|
|
|
|
now_timestamp = Time.now.utc.to_i
|
|
post "/super_admin/accounts/#{account.id}/reset_cache"
|
|
expect(response).to have_http_status(:redirect)
|
|
expect(flash[:notice]).to eq('Cache keys cleared')
|
|
|
|
range = now_timestamp..(now_timestamp + 10)
|
|
expect(account.reload.cache_keys.values.all? { |v| range.cover?(v.to_i) }).to be(true)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe 'DELETE /super_admin/accounts/{account_id}' do
|
|
context 'when it is an unauthenticated user' do
|
|
it 'returns unauthorized' do
|
|
delete "/super_admin/accounts/#{account.id}"
|
|
expect(response).to have_http_status(:redirect)
|
|
end
|
|
end
|
|
|
|
context 'when it is an authenticated user' do
|
|
it 'Deletes the account' do
|
|
total_accounts = Account.count
|
|
sign_in(super_admin, scope: :super_admin)
|
|
|
|
perform_enqueued_jobs(only: DeleteObjectJob) do
|
|
delete "/super_admin/accounts/#{account.id}"
|
|
end
|
|
|
|
expect(Account.count).to eq(total_accounts - 1)
|
|
end
|
|
end
|
|
end
|
|
end
|