Fix: Added the backend validation for name (#3878)

- Added the backend validation for name
- Add message size constraint
This commit is contained in:
Tejaswini Chile
2022-02-03 03:51:17 +05:30
committed by GitHub
parent e99ea0b582
commit 8821106da9
10 changed files with 83 additions and 1 deletions

View File

@@ -28,6 +28,18 @@ RSpec.describe 'Public Inbox Contact Conversation Messages API', type: :request
expect(data['content']).to eq('hello')
end
it 'does not create the message' do
content = "#{'h' * 150 * 1000}a"
post "/public/api/v1/inboxes/#{api_channel.identifier}/contacts/#{contact_inbox.source_id}/conversations/#{conversation.display_id}/messages",
params: { content: content }
expect(response).to have_http_status(:unprocessable_entity)
json_response = JSON.parse(response.body)
expect(json_response['message']).to eq('Content is too long (maximum is 150000 characters)')
end
it 'creates attachment message in conversation' do
file = fixture_file_upload(Rails.root.join('spec/assets/avatar.png'), 'image/png')
post "/public/api/v1/inboxes/#{api_channel.identifier}/contacts/#{contact_inbox.source_id}/conversations/#{conversation.display_id}/messages",