mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 02:32:29 +00:00
feat: Ability to delete platform app from super admin (#10966)
- Add the ability to delete platform app from super admin.
This commit is contained in:
@@ -485,7 +485,7 @@ Rails.application.routes.draw do
|
||||
resources :agent_bots, only: [:index, :new, :create, :show, :edit, :update] do
|
||||
delete :avatar, on: :member, action: :destroy_avatar
|
||||
end
|
||||
resources :platform_apps, only: [:index, :new, :create, :show, :edit, :update]
|
||||
resources :platform_apps, only: [:index, :new, :create, :show, :edit, :update, :destroy]
|
||||
resource :instance_status, only: [:show]
|
||||
|
||||
resource :settings, only: [:show] do
|
||||
|
||||
@@ -22,4 +22,27 @@ RSpec.describe 'Super Admin platform app API', type: :request do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE /super_admin/platform_apps/:id' do
|
||||
let!(:platform_app) { create(:platform_app) }
|
||||
let(:access_token) { platform_app.access_token }
|
||||
|
||||
context 'when it is an unauthenticated super admin' do
|
||||
it 'returns unauthorized' do
|
||||
delete "/super_admin/platform_apps/#{platform_app.id}", params: { _method: :delete }
|
||||
expect(response).to have_http_status(:redirect)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when it is an authenticated super admin' do
|
||||
it 'deletes the platform app' do
|
||||
sign_in(super_admin, scope: :super_admin)
|
||||
expect do
|
||||
delete "/super_admin/platform_apps/#{platform_app.id}", params: { _method: :delete }
|
||||
end.to change(PlatformApp, :count).by(-1)
|
||||
expect(response).to have_http_status(:redirect)
|
||||
expect(response).to redirect_to(super_admin_platform_apps_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user