mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 06:42:32 -05:00
subject only email message
This commit is contained in:
1 parent
f9669b0e16
commit
e316d2006f
4 files changed
+11
-10
No files matched your search
@@ -31,6 +31,8 @@ class EmailMessage < ApplicationRecord
|
||||
|
||||
attribute :uuid, :string, default: -> { SecureRandom.uuid }
|
||||
|
||||
normalizes :body, with: ->(value) { value.to_s }, apply_to_nil: true
|
||||
|
||||
before_validation :set_sha1, on: :create
|
||||
|
||||
def normalized_body
|
||||
|
||||
@@ -29,8 +29,6 @@ module Params
|
||||
in_path(params, :message) do |message_params|
|
||||
type(message_params, :subject, String)
|
||||
type(message_params, :body, String)
|
||||
|
||||
required(message_params, :body)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,8 +51,6 @@ module Params
|
||||
in_path(params, :message, skip_blank: true) do |message_params|
|
||||
type(message_params, :subject, String)
|
||||
type(message_params, :body, String)
|
||||
|
||||
required(message_params, :body)
|
||||
end
|
||||
|
||||
value_in(params, :order, %w[preserved random], allow_nil: true)
|
||||
@@ -119,8 +115,6 @@ module Params
|
||||
in_path(params, :message) do |message_params|
|
||||
type(message_params, :subject, String)
|
||||
type(message_params, :body, String)
|
||||
|
||||
required(message_params, :body)
|
||||
end
|
||||
|
||||
value_in(params, :order, %w[preserved random], allow_nil: true)
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ module Submitters
|
||||
def normalize_preferences(account, user, params)
|
||||
preferences = {}
|
||||
|
||||
message_params = params['message'].presence || params.slice('subject', 'body').presence
|
||||
message_params = (params['message'].presence || params.slice('subject', 'body')).compact_blank
|
||||
|
||||
if message_params.present?
|
||||
email_message = EmailMessages.find_or_create_for_account_user(account, user,
|
||||
|
||||
@@ -197,7 +197,7 @@ describe 'Submission API' do
|
||||
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
|
||||
it 'creates a submission when the message has only a subject' do
|
||||
post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: {
|
||||
template_id: templates[0].id,
|
||||
send_email: true,
|
||||
@@ -209,8 +209,13 @@ describe 'Submission API' do
|
||||
}
|
||||
}.to_json
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_content)
|
||||
expect(response.parsed_body).to eq({ 'error' => 'body is required in `message`.' })
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
||||
submission = Submission.last
|
||||
email_message = EmailMessage.last
|
||||
|
||||
expect(submission.submitters.first.preferences['email_message_uuid']).to eq(email_message.uuid)
|
||||
expect(email_message).to have_attributes(subject: 'Custom Email Subject', body: '')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user