fix(email): allow larger email templates
This commit is contained in:
@@ -85,6 +85,20 @@ RSpec.describe 'Branded Email Layout API', type: :request do
|
||||
expect(response.parsed_body['branded_email_layout']).to eq(layout)
|
||||
end
|
||||
|
||||
it 'updates account-scoped branded email layouts up to 100 KiB' do
|
||||
account.enable_features!(:branded_email_templates)
|
||||
slot = '{{ content_for_layout }}'
|
||||
large_layout = "#{'a' * (100.kilobytes - slot.length)}#{slot}"
|
||||
|
||||
patch "/api/v1/accounts/#{account.id}/branded_email_layout",
|
||||
headers: admin.create_new_auth_token,
|
||||
params: { branded_email_layout: large_layout },
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(EmailTemplate.account_branded_layout_template_for(account).body.length).to eq(100.kilobytes)
|
||||
end
|
||||
|
||||
it 'clears account-scoped branded email layout when blank value is passed' do
|
||||
account.enable_features!(:branded_email_templates)
|
||||
create(:email_template, :layout, account: account, body: layout)
|
||||
|
||||
@@ -636,6 +636,22 @@ RSpec.describe 'Inboxes API', type: :request do
|
||||
expect(response.parsed_body['branded_email_layout']).to eq(layout)
|
||||
end
|
||||
|
||||
it 'rejects branded email layouts larger than 256 KiB' do
|
||||
account.enable_features!(:branded_email_templates)
|
||||
email_channel = create(:channel_email, account: account)
|
||||
email_inbox = create(:inbox, channel: email_channel, account: account)
|
||||
slot = '{{ content_for_layout }}'
|
||||
large_layout = "#{'a' * (EmailTemplate::MAX_BODY_LENGTH - slot.length + 1)}#{slot}"
|
||||
|
||||
patch "/api/v1/accounts/#{account.id}/inboxes/#{email_inbox.id}",
|
||||
headers: admin.create_new_auth_token,
|
||||
params: { branded_email_layout: large_layout },
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(response.parsed_body['error']).to include('is too long (maximum is 262144 characters)')
|
||||
end
|
||||
|
||||
it 'rolls back branded email layout when inbox update fails' do
|
||||
account.enable_features!(:branded_email_templates)
|
||||
email_channel = create(:channel_email, account: account)
|
||||
|
||||
Reference in New Issue
Block a user