Improve error message when does not match in completed form
This commit is contained in:
@@ -10,16 +10,17 @@ class SendSubmissionEmailController < ApplicationController
|
|||||||
SEND_DURATION = 30.minutes
|
SEND_DURATION = 30.minutes
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@submitter =
|
if params[:template_slug]
|
||||||
if params[:template_slug]
|
@submitter = Submitter.joins(submission: :template).find_by!(email: params[:email].to_s.downcase,
|
||||||
Submitter.joins(submission: :template).find_by!(email: params[:email].to_s.downcase,
|
template: { slug: params[:template_slug] })
|
||||||
template: { slug: params[:template_slug] })
|
elsif params[:submission_slug]
|
||||||
elsif params[:submission_slug]
|
@submitter = Submitter.joins(:submission).find_by(email: params[:email].to_s.downcase,
|
||||||
Submitter.joins(:submission).find_by!(email: params[:email].to_s.downcase,
|
submission: { slug: params[:submission_slug] })
|
||||||
submission: { slug: params[:submission_slug] })
|
|
||||||
else
|
return redirect_to submissions_preview_completed_path(params[:submission_slug], status: :error) unless @submitter
|
||||||
Submitter.find_by!(slug: params[:submitter_slug])
|
else
|
||||||
end
|
@submitter = Submitter.find_by!(slug: params[:submitter_slug])
|
||||||
|
end
|
||||||
|
|
||||||
RateLimit.call("send-email-#{@submitter.id}", limit: 2, ttl: 5.minutes)
|
RateLimit.call("send-email-#{@submitter.id}", limit: 2, ttl: 5.minutes)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class SubmissionsPreviewController < ApplicationController
|
class SubmissionsPreviewController < ApplicationController
|
||||||
|
around_action :with_browser_locale
|
||||||
skip_before_action :authenticate_user!
|
skip_before_action :authenticate_user!
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,11 @@
|
|||||||
<%= f.hidden_field :submission_slug, value: @submission.slug %>
|
<%= f.hidden_field :submission_slug, value: @submission.slug %>
|
||||||
<%= f.label :email, t('email'), class: 'label' %>
|
<%= f.label :email, t('email'), class: 'label' %>
|
||||||
<%= f.email_field :email, value: current_user&.email || params[:email], required: true, class: 'base-input', placeholder: t('send_copy_to_email') %>
|
<%= f.email_field :email, value: current_user&.email || params[:email], required: true, class: 'base-input', placeholder: t('send_copy_to_email') %>
|
||||||
|
<% if params[:status] == 'error' %>
|
||||||
|
<span class="label-text-alt text-red-400 mt-1">
|
||||||
|
<%= t('please_enter_your_email_address_associated_with_the_completed_submission') %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<toggle-submit dir="auto" class="form-control">
|
<toggle-submit dir="auto" class="form-control">
|
||||||
<%= f.button button_title(title: t('send_copy_to_email'), disabled_with: t('starting')), class: 'base-button' %>
|
<%= f.button button_title(title: t('send_copy_to_email'), disabled_with: t('starting')), class: 'base-button' %>
|
||||||
|
|||||||
@@ -744,6 +744,7 @@ en: &en
|
|||||||
two_months: 2 months
|
two_months: 2 months
|
||||||
three_months: 3 months
|
three_months: 3 months
|
||||||
eu_data_residency: EU data residency
|
eu_data_residency: EU data residency
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: Please enter your email address associated with the completed submission.
|
||||||
submission_sources:
|
submission_sources:
|
||||||
api: API
|
api: API
|
||||||
bulk: Bulk Send
|
bulk: Bulk Send
|
||||||
@@ -1555,6 +1556,7 @@ es: &es
|
|||||||
two_months: 2 meses
|
two_months: 2 meses
|
||||||
three_months: 3 meses
|
three_months: 3 meses
|
||||||
eu_data_residency: Datos alojados UE
|
eu_data_residency: Datos alojados UE
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: Por favor, introduce tu dirección de correo electrónico asociada con el envío completado.
|
||||||
submission_sources:
|
submission_sources:
|
||||||
api: API
|
api: API
|
||||||
bulk: Envío masivo
|
bulk: Envío masivo
|
||||||
@@ -2364,6 +2366,7 @@ it: &it
|
|||||||
two_months: 2 mesi
|
two_months: 2 mesi
|
||||||
three_months: 3 mesi
|
three_months: 3 mesi
|
||||||
eu_data_residency: "Dati nell'UE"
|
eu_data_residency: "Dati nell'UE"
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: "Inserisci il tuo indirizzo email associato all'invio completato."
|
||||||
submission_sources:
|
submission_sources:
|
||||||
api: API
|
api: API
|
||||||
bulk: Invio massivo
|
bulk: Invio massivo
|
||||||
@@ -3176,6 +3179,7 @@ fr: &fr
|
|||||||
two_months: 2 mois
|
two_months: 2 mois
|
||||||
three_months: 3 mois
|
three_months: 3 mois
|
||||||
eu_data_residency: "Données dans l'UE"
|
eu_data_residency: "Données dans l'UE"
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: "Veuillez saisir l'adresse e-mail associée à l'envoi complété."
|
||||||
submission_sources:
|
submission_sources:
|
||||||
api: API
|
api: API
|
||||||
bulk: Envoi en masse
|
bulk: Envoi en masse
|
||||||
@@ -3987,6 +3991,7 @@ pt: &pt
|
|||||||
two_months: 2 meses
|
two_months: 2 meses
|
||||||
three_months: 3 meses
|
three_months: 3 meses
|
||||||
eu_data_residency: Dados na UE
|
eu_data_residency: Dados na UE
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: Por favor, insira seu e-mail associado ao envio concluído.
|
||||||
submission_sources:
|
submission_sources:
|
||||||
api: API
|
api: API
|
||||||
bulk: Envio em massa
|
bulk: Envio em massa
|
||||||
@@ -4799,6 +4804,7 @@ de: &de
|
|||||||
two_months: 2 Monate
|
two_months: 2 Monate
|
||||||
three_months: 3 Monate
|
three_months: 3 Monate
|
||||||
eu_data_residency: EU-Datenspeicher
|
eu_data_residency: EU-Datenspeicher
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: Bitte gib deine E-Mail-Adresse ein, die mit der abgeschlossenen Übermittlung verknüpft ist.
|
||||||
submission_sources:
|
submission_sources:
|
||||||
api: API
|
api: API
|
||||||
bulk: Massenversand
|
bulk: Massenversand
|
||||||
@@ -4951,6 +4957,7 @@ pl:
|
|||||||
count_documents_signed_with_html: '<b>%{count}</b> dokumentów podpisanych za pomocą'
|
count_documents_signed_with_html: '<b>%{count}</b> dokumentów podpisanych za pomocą'
|
||||||
open_source_documents_software: 'oprogramowanie do dokumentów open source'
|
open_source_documents_software: 'oprogramowanie do dokumentów open source'
|
||||||
eu_data_residency: Dane w UE
|
eu_data_residency: Dane w UE
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: Wprowadź adres e-mail powiązany z ukończonym zgłoszeniem.
|
||||||
|
|
||||||
uk:
|
uk:
|
||||||
require_phone_2fa_to_open: Вимагати двофакторну автентифікацію через телефон для відкриття
|
require_phone_2fa_to_open: Вимагати двофакторну автентифікацію через телефон для відкриття
|
||||||
@@ -5019,6 +5026,7 @@ uk:
|
|||||||
count_documents_signed_with_html: '<b>%{count}</b> документів підписано за допомогою'
|
count_documents_signed_with_html: '<b>%{count}</b> документів підписано за допомогою'
|
||||||
open_source_documents_software: 'відкрите програмне забезпечення для документів'
|
open_source_documents_software: 'відкрите програмне забезпечення для документів'
|
||||||
eu_data_residency: 'Зберігання даних в ЄС'
|
eu_data_residency: 'Зберігання даних в ЄС'
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: "Введіть адресу електронної пошти, пов'язану із завершеним поданням."
|
||||||
|
|
||||||
cs:
|
cs:
|
||||||
require_phone_2fa_to_open: Vyžadovat otevření pomocí telefonního 2FA
|
require_phone_2fa_to_open: Vyžadovat otevření pomocí telefonního 2FA
|
||||||
@@ -5087,6 +5095,7 @@ cs:
|
|||||||
count_documents_signed_with_html: '<b>%{count}</b> dokumentů podepsáno pomocí'
|
count_documents_signed_with_html: '<b>%{count}</b> dokumentů podepsáno pomocí'
|
||||||
open_source_documents_software: 'open source software pro dokumenty'
|
open_source_documents_software: 'open source software pro dokumenty'
|
||||||
eu_data_residency: 'Uložení dat v EU'
|
eu_data_residency: 'Uložení dat v EU'
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: Zadejte e-mailovou adresu spojenou s dokončeným odesláním.
|
||||||
|
|
||||||
he:
|
he:
|
||||||
require_phone_2fa_to_open: דרוש אימות דו-שלבי באמצעות טלפון לפתיחה
|
require_phone_2fa_to_open: דרוש אימות דו-שלבי באמצעות טלפון לפתיחה
|
||||||
@@ -5155,6 +5164,7 @@ he:
|
|||||||
count_documents_signed_with_html: '<b>%{count}</b> מסמכים נחתמו באמצעות'
|
count_documents_signed_with_html: '<b>%{count}</b> מסמכים נחתמו באמצעות'
|
||||||
open_source_documents_software: 'תוכנה בקוד פתוח למסמכים'
|
open_source_documents_software: 'תוכנה בקוד פתוח למסמכים'
|
||||||
eu_data_residency: 'נתונים באיחוד האירופי '
|
eu_data_residency: 'נתונים באיחוד האירופי '
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: 'אנא הזן את כתובת הדוא"ל המשויכת למשלוח שהושלם.'
|
||||||
|
|
||||||
nl:
|
nl:
|
||||||
require_phone_2fa_to_open: Vereis telefoon 2FA om te openen
|
require_phone_2fa_to_open: Vereis telefoon 2FA om te openen
|
||||||
@@ -5223,6 +5233,7 @@ nl:
|
|||||||
count_documents_signed_with_html: '<b>%{count}</b> documenten ondertekend met'
|
count_documents_signed_with_html: '<b>%{count}</b> documenten ondertekend met'
|
||||||
open_source_documents_software: 'open source documenten software'
|
open_source_documents_software: 'open source documenten software'
|
||||||
eu_data_residency: Gegevens EU
|
eu_data_residency: Gegevens EU
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: Voer het e-mailadres in dat is gekoppeld aan de voltooide indiening.
|
||||||
|
|
||||||
ar:
|
ar:
|
||||||
require_phone_2fa_to_open: "تطلب فتح عبر تحقق الهاتف ذو العاملين"
|
require_phone_2fa_to_open: "تطلب فتح عبر تحقق الهاتف ذو العاملين"
|
||||||
@@ -5291,6 +5302,7 @@ ar:
|
|||||||
count_documents_signed_with_html: '<b>%{count}</b> مستندات تم توقيعها باستخدام'
|
count_documents_signed_with_html: '<b>%{count}</b> مستندات تم توقيعها باستخدام'
|
||||||
open_source_documents_software: 'برنامج مستندات مفتوح المصدر'
|
open_source_documents_software: 'برنامج مستندات مفتوح المصدر'
|
||||||
eu_data_residency: 'بيانات في الاتحاد الأوروبي'
|
eu_data_residency: 'بيانات في الاتحاد الأوروبي'
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: 'يرجى إدخال عنوان البريد الإلكتروني المرتبط بالإرسال المكتمل.'
|
||||||
|
|
||||||
ko:
|
ko:
|
||||||
require_phone_2fa_to_open: 휴대폰 2FA를 열 때 요구함
|
require_phone_2fa_to_open: 휴대폰 2FA를 열 때 요구함
|
||||||
@@ -5359,6 +5371,7 @@ ko:
|
|||||||
count_documents_signed_with_html: '<b>%{count}</b>개의 문서가 다음을 통해 서명됨'
|
count_documents_signed_with_html: '<b>%{count}</b>개의 문서가 다음을 통해 서명됨'
|
||||||
open_source_documents_software: '오픈소스 문서 소프트웨어'
|
open_source_documents_software: '오픈소스 문서 소프트웨어'
|
||||||
eu_data_residency: 'EU 데이터 보관'
|
eu_data_residency: 'EU 데이터 보관'
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: '완료된 제출과 연결된 이메일 주소를 입력하세요.'
|
||||||
|
|
||||||
ja:
|
ja:
|
||||||
require_phone_2fa_to_open: 電話による2段階認証が必要です
|
require_phone_2fa_to_open: 電話による2段階認証が必要です
|
||||||
@@ -5427,6 +5440,7 @@ ja:
|
|||||||
count_documents_signed_with_html: '<b>%{count}</b> 件のドキュメントが以下で署名されました'
|
count_documents_signed_with_html: '<b>%{count}</b> 件のドキュメントが以下で署名されました'
|
||||||
open_source_documents_software: 'オープンソースのドキュメントソフトウェア'
|
open_source_documents_software: 'オープンソースのドキュメントソフトウェア'
|
||||||
eu_data_residency: 'EU データ居住'
|
eu_data_residency: 'EU データ居住'
|
||||||
|
please_enter_your_email_address_associated_with_the_completed_submission: '完了した提出に関連付けられたメールアドレスを入力してください。'
|
||||||
|
|
||||||
en-US:
|
en-US:
|
||||||
<<: *en
|
<<: *en
|
||||||
|
|||||||
@@ -6,18 +6,54 @@ RSpec.describe 'Submission Preview' do
|
|||||||
let(:template) { create(:template, account:, author: user) }
|
let(:template) { create(:template, account:, author: user) }
|
||||||
|
|
||||||
context 'when not submitted' do
|
context 'when not submitted' do
|
||||||
let(:submission) { create(:submission, template:, created_by_user: user) }
|
let(:submission) { create(:submission, :with_submitters, template:, created_by_user: user) }
|
||||||
|
|
||||||
before do
|
context 'when user is signed in' do
|
||||||
template.submitters.map { |s| create(:submitter, submission:, uuid: s['uuid']) }
|
before do
|
||||||
|
sign_in(user)
|
||||||
|
|
||||||
sign_in(user)
|
visit submissions_preview_path(slug: submission.slug)
|
||||||
|
end
|
||||||
|
|
||||||
visit submissions_preview_path(slug: submission.slug)
|
it 'completes the form' do
|
||||||
|
expect(page).to have_content('Not completed')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'completes the form' do
|
context 'when user is not signed in' do
|
||||||
expect(page).to have_content('Not completed')
|
context 'when submission is not completed' do
|
||||||
|
before do
|
||||||
|
create(:encrypted_config, account:, key: EncryptedConfig::EMAIL_SMTP_KEY, value: '{}')
|
||||||
|
|
||||||
|
submission.submitters.each { |s| s.update(completed_at: 1.day.ago) }
|
||||||
|
|
||||||
|
visit submissions_preview_path(slug: submission.slug)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "sends a copy to the submitter's email" do
|
||||||
|
fill_in 'Email', with: submission.submitters.first.email
|
||||||
|
click_button 'Send copy to Email'
|
||||||
|
|
||||||
|
expect(page).to have_content('Email has been sent.')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows an error for an email not associated with the submission' do
|
||||||
|
fill_in 'Email', with: 'john.due@example.com'
|
||||||
|
click_button 'Send copy to Email'
|
||||||
|
|
||||||
|
expect(page).to have_content('Please enter your email address associated with the completed submission.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't display the email form if SMTP is not configured" do
|
||||||
|
submission.submitters.each { |s| s.update(completed_at: 1.day.ago) }
|
||||||
|
|
||||||
|
visit submissions_preview_path(slug: submission.slug)
|
||||||
|
|
||||||
|
expect(page).to have_content(template.name)
|
||||||
|
expect(page).not_to have_field('Email')
|
||||||
|
expect(page).not_to have_content('Send copy to Email')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user