don't raise validation error if the message is empty

This commit is contained in:
Alex Turchyn
2024-12-13 20:38:03 +02:00
committed by Pete Matsyburka
parent 15d06f4fb0
commit bb552d13d4
3 changed files with 34 additions and 2 deletions
+31
View File
@@ -89,6 +89,21 @@ describe 'Submission API', type: :request do
expect(response.parsed_body).to eq(JSON.parse(create_submission_body(submission).to_json))
end
it 'creates a submission when the message is empty' do
post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: {
template_id: templates[0].id,
send_email: true,
submitters: [{ role: 'First Party', email: 'john.doe@example.com' }],
message: {}
}.to_json
expect(response).to have_http_status(:ok)
submission = Submission.last
expect(response.parsed_body).to eq(JSON.parse(create_submission_body(submission).to_json))
end
it 'creates a submission when some submitter roles are not provided' do
post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: {
template_id: multiple_submitters_template.id,
@@ -168,6 +183,22 @@ describe 'Submission API', type: :request do
expect(response).to have_http_status(:unprocessable_entity)
expect(response.parsed_body).to eq({ 'error' => 'Defined more signing parties than in template' })
end
it 'returns an error if the message has no body value' do
post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: {
template_id: templates[0].id,
send_email: true,
submitters: [
{ role: 'First Party', email: 'john.doe@example.com' }
],
message: {
subject: 'Custom Email Subject'
}
}.to_json
expect(response).to have_http_status(:unprocessable_entity)
expect(response.parsed_body).to eq({ 'error' => 'body is required in `message`.' })
end
end
describe 'POST /api/submissions/emails' do