fix: Handle empty status in conversation controller (#8091)
Fixes CW-2644
This commit is contained in:
@@ -60,7 +60,7 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
|
|||||||
end
|
end
|
||||||
|
|
||||||
def toggle_status
|
def toggle_status
|
||||||
if params[:status]
|
if params[:status].present?
|
||||||
set_conversation_status
|
set_conversation_status
|
||||||
@status = @conversation.save!
|
@status = @conversation.save!
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -340,11 +340,12 @@ RSpec.describe 'Conversations API', type: :request do
|
|||||||
create(:inbox_member, user: agent, inbox: conversation.inbox)
|
create(:inbox_member, user: agent, inbox: conversation.inbox)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'toggles the conversation status' do
|
it 'toggles the conversation status if status is empty' do
|
||||||
expect(conversation.status).to eq('open')
|
expect(conversation.status).to eq('open')
|
||||||
|
|
||||||
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/toggle_status",
|
post "/api/v1/accounts/#{account.id}/conversations/#{conversation.display_id}/toggle_status",
|
||||||
headers: agent.create_new_auth_token,
|
headers: agent.create_new_auth_token,
|
||||||
|
params: { status: '' },
|
||||||
as: :json
|
as: :json
|
||||||
|
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
|
|||||||
Reference in New Issue
Block a user