From fb3ed29c90cc6a31b1e8737f3ef0b98bc93e90e0 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Mon, 11 Apr 2022 14:06:44 +0530 Subject: [PATCH] chore: Add missing test cases in `conversations_controller_spec` (#4438) --- .../api/v1/widget/conversations/create.json.jbuilder | 1 + .../api/v1/widget/conversations_controller_spec.rb | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/api/v1/widget/conversations/create.json.jbuilder b/app/views/api/v1/widget/conversations/create.json.jbuilder index 2576af592..17585c2f8 100644 --- a/app/views/api/v1/widget/conversations/create.json.jbuilder +++ b/app/views/api/v1/widget/conversations/create.json.jbuilder @@ -7,4 +7,5 @@ json.messages do json.partial! 'api/v1/models/widget_message', resource: message end end +json.custom_attributes @conversation.custom_attributes json.contact @conversation.contact diff --git a/spec/controllers/api/v1/widget/conversations_controller_spec.rb b/spec/controllers/api/v1/widget/conversations_controller_spec.rb index 0d3edb0dd..88f41dea0 100644 --- a/spec/controllers/api/v1/widget/conversations_controller_spec.rb +++ b/spec/controllers/api/v1/widget/conversations_controller_spec.rb @@ -54,19 +54,22 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do website_token: web_widget.website_token, contact: { name: 'contact-name', - email: 'contact-email@chatwoot.com' + email: 'contact-email@chatwoot.com', + phone_number: '+919745313456' }, message: { content: 'This is a test message' - } + }, + custom_attributes: { order_id: '12345' } }, as: :json expect(response).to have_http_status(:success) json_response = JSON.parse(response.body) - expect(json_response['id']).not_to eq nil expect(json_response['contact']['email']).to eq 'contact-email@chatwoot.com' + expect(json_response['contact']['phone_number']).to eq '+919745313456' + expect(json_response['custom_attributes']['order_id']).to eq '12345' expect(json_response['messages'][0]['content']).to eq 'This is a test message' end end