Feature: Send attachments to widget user (#621)

This commit is contained in:
Nithin David Thomas
2020-03-22 15:54:36 +05:30
committed by GitHub
parent fe70843fae
commit f7e5f1fabf
16 changed files with 317 additions and 92 deletions

View File

@@ -44,6 +44,20 @@ RSpec.describe '/api/v1/widget/messages', type: :request do
json_response = JSON.parse(response.body)
expect(json_response['content']).to eq(message_params[:content])
end
it 'creates attachment message in conversation' do
file = fixture_file_upload(Rails.root.join('spec/assets/avatar.png'), 'image/png')
message_params = { content: 'hello world', timestamp: Time.current, attachment: { file: file } }
post api_v1_widget_messages_url,
params: { website_token: web_widget.website_token, message: message_params },
headers: { 'X-Auth-Token' => token }
expect(response).to have_http_status(:success)
json_response = JSON.parse(response.body)
expect(json_response['content']).to eq(message_params[:content])
expect(conversation.messages.last.attachment.file.present?).to eq(true)
end
end
end