Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

test: cover bulk assignment account validation (#16105)

Sony Mathew5e507d49069d
diff --git a/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb b/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb
index 1d378ab6548..5def2cb7ab5 100644
--- a/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb
+++ b/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb
@@ -46,6 +46,30 @@ RSpec.describe 'Api::V1::Accounts::BulkActionsController', type: :request do
expect(response).to have_http_status(:unprocessable_entity)
end
+ it 'Rejects bulk assignment to an assignee outside the account' do
+ other_user = create(:user, account: create(:account))
+
+ expect do
+ post "/api/v1/accounts/#{account.id}/bulk_actions",
+ headers: agent.create_new_auth_token,
+ params: { type: 'Conversation', fields: { assignee_id: other_user.id }, ids: Conversation.first(2).pluck(:display_id) }
+ end.not_to have_enqueued_job(BulkActionsJob)
+
+ expect(response).to have_http_status(:unprocessable_entity)
+ end
+
+ it 'Rejects bulk assignment to a team outside the account' do
+ other_team = create(:team, account: create(:account))
+
+ expect do
+ post "/api/v1/accounts/#{account.id}/bulk_actions",
+ headers: agent.create_new_auth_token,
+ params: { type: 'Conversation', fields: { team_id: other_team.id }, ids: Conversation.first(2).pluck(:display_id) }
+ end.not_to have_enqueued_job(BulkActionsJob)
+
+ expect(response).to have_http_status(:unprocessable_entity)
+ end
+
it 'Bulk update conversation status' do
expect(Conversation.first.status).to eq('open')
expect(Conversation.last.status).to eq('open')