Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions app/models/form_document/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ def has_email_delivery?
end

def email_delivery_configuration
delivery_configurations.find do |delivery_configuration|
delivery_configuration["delivery_method"] == "email" && delivery_configuration["delivery_schedule"] == "immediate"
end
immediate_delivery_configuration("email")
end

def has_s3_delivery?
s3_delivery_configuration.present?
end

def s3_delivery_configuration
immediate_delivery_configuration("s3")
end

def daily_submission_batch_enabled?
Expand All @@ -77,4 +83,12 @@ def weekly_submission_batch_enabled?
delivery_configuration["delivery_schedule"] == "weekly"
end
end

private

def immediate_delivery_configuration(delivery_method)
delivery_configurations.find do |delivery_configuration|
delivery_configuration["delivery_method"] == delivery_method && delivery_configuration["delivery_schedule"] == "immediate"
end
end
end
13 changes: 11 additions & 2 deletions app/views/forms/_made_live_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,17 @@

<h3 class="govuk-heading-m"><%= t(".how_you_get_completed_forms.title") %></h3>

<h4 class="govuk-heading-s"><%= t('.how_you_get_completed_forms.submission_email') %></h4>
<p class="govuk-!-text-break-word"><%= form_document.submission_email %></p>
<% if form_document.has_email_delivery? %>
<h4 class="govuk-heading-s"><%= t('.how_you_get_completed_forms.submission_email') %></h4>
<p class="govuk-!-text-break-word"><%= form_document.submission_email %></p>
<% end %>

<% if form_document.has_s3_delivery? %>
<h4 class="govuk-heading-s"><%= t('.how_you_get_completed_forms.s3.heading') %></h4>
<p><%= t('.how_you_get_completed_forms.s3.configuration',
delivery_format: form_document.s3_delivery_configuration["formats"].sole.upcase,
bucket_name: form_document.s3_bucket_name) %></p>
<% end %>

<% if form_document.has_email_delivery? %>
<% formats = ["email", *form_document.email_delivery_configuration["formats"]].join("_") %>
Expand Down
7 changes: 5 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ en:
title: Daily and weekly CSVs
weekly_enabled: You are getting a weekly batch of completed forms.
csv_and_json: CSV and JSON
s3:
configuration: "%{delivery_format} files sent to %{bucket_name}"
heading: S3 bucket
submission_email: Email
submission_format:
email:
Expand Down Expand Up @@ -2246,8 +2249,8 @@ en:
s3_details:
summary_content_html: |
<p>You can get completed forms sent to an AWS S3 bucket instead of an email address.</p>
<p>To find out more about this option, including how to set it up, <a href="https://www.forms.service.gov.uk/processing-completed-form-submissions">read our guidance on processing completed form submissions</a>.</p>
<p>You still need to set an email address here to mark this task complete. When you switch to an S3 bucket, you’ll stop getting completed forms by email.</p>
<p>You still need to set an email address here to mark this task complete, even if you do not want to want to receive submissions by email over the long term.</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>You still need to set an email address here to mark this task complete, even if you do not want to want to receive submissions by email over the long term.</p>
<p>You still need to set an email address here to mark this task complete, even if you do not want to receive submissions by email over the long term.</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe something like this?

Suggested change
<p>You still need to set an email address here to mark this task complete, even if you do not want to want to receive submissions by email over the long term.</p>
<p>You still need to set an email address here to mark this task complete, even if you plan to get completed forms in an S3 bucket instead.</p>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good spot with the repetition, I didn't proof-read this.
In terms of the different content suggestion, what do you think @StephenGill?

<p>To find out how to set an S3 bucket, <a href="https://www.forms.service.gov.uk/processing-completed-form-submissions">read our guidance on processing completed form submissions</a>.</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>To find out how to set an S3 bucket, <a href="https://www.forms.service.gov.uk/processing-completed-form-submissions">read our guidance on processing completed form submissions</a>.</p>
<p>To find out how to set up an S3 bucket, <a href="https://www.forms.service.gov.uk/processing-completed-form-submissions">read our guidance on processing completed form submissions</a>.</p>

summary_text: Get completed forms sent to an AWS S3 bucket
share_preview:
body_html: |
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
DeliveryConfiguration.create(
delivery_method: :s3,
delivery_schedule: :immediate,
formats: [],
formats: %w[csv],
),
],
)
Expand Down
66 changes: 47 additions & 19 deletions spec/views/forms/_made_live_form.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,25 @@

it "contains information about how you get completed forms" do
expect(rendered).to have_css("h3", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.title"))
expect(rendered).to have_xpath("//h3[text()='#{I18n.t('forms.made_live_form.how_you_get_completed_forms.title')}']/following-sibling::h4", text: "Email")
expect(rendered).to have_text(form_document.submission_email)
end

context "when the submission type is 'email'" do
context "when only email submissions are configured" do
let(:formats) { [] }
let(:form_metadata) do
create(:form, :live, delivery_configurations: [create(:delivery_configuration, :immediate_email, formats: formats)])
end

it "has a section for the submission email" do
expect(rendered).to have_xpath("//h3[text()='#{I18n.t('forms.made_live_form.how_you_get_completed_forms.title')}']/following-sibling::h4", text: "Email")
expect(rendered).to have_text(form_document.submission_email)
end

it "does not have a section for S3 buckets" do
expect(rendered).not_to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.s3.heading"))
end

context "when CSV submission is enabled" do
let(:form_metadata) do
create(:form, :live, delivery_configurations: [create(:delivery_configuration, :immediate_email, formats: %w[csv])])
end
let(:formats) { %w[csv] }

it "tells the user they have CSVs enabled" do
expect(rendered).to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.csv_and_json"))
Expand All @@ -153,9 +163,7 @@
end

context "when JSON submission is enabled" do
let(:form_metadata) do
create(:form, :live, delivery_configurations: [create(:delivery_configuration, :immediate_email, formats: %w[json])])
end
let(:formats) { %w[json] }

it "tells the user they have JSON submissions enabled" do
expect(rendered).to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.csv_and_json"))
Expand All @@ -164,38 +172,58 @@
end

context "when both CSV and JSON submissions are enabled" do
let(:form_metadata) do
create(:form, :live, delivery_configurations: [create(:delivery_configuration, :immediate_email, formats: %w[csv json])])
end
let(:formats) { %w[csv json] }

it "tells the user they have CSV and JSON submissions enabled" do
expect(rendered).to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.csv_and_json"))
expect(rendered).to include(I18n.t("forms.made_live_form.how_you_get_completed_forms.submission_format.email.email_csv_json_html"))
end
end

context "when CSV submission is not enabled" do
let(:form_metadata) do
create(:form, :live, delivery_configurations: [create(:delivery_configuration, :immediate_email, formats: [])])
end
context "when no email submission attachments are enabled" do
let(:formats) { [] }

it "tells the user they do not have CSVs enabled" do
it "tells the user they do not have CSV or JSON enabled" do
expect(rendered).to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.csv_and_json"))
expect(rendered).to include(I18n.t("forms.made_live_form.how_you_get_completed_forms.submission_format.email.email_html"))
end
end
end

context "when the submission type is 's3'" do
context "when only S3 delivery is configured" do
let(:form_metadata) do
create(:form, :live, delivery_configurations: [create(:delivery_configuration, :s3)])
create(:form, :live, :with_s3_configuration, delivery_configurations: [create(:delivery_configuration, :s3)])
end

it "includes a section for the S3 bucket" do
expect(rendered).to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.s3.heading"))
expect(rendered).to have_text(I18n.t("forms.made_live_form.how_you_get_completed_forms.s3.configuration",
delivery_format: "CSV", bucket_name: form_document.s3_bucket_name))
end

it "does not include a section for email submissions" do
expect(rendered).not_to have_text(form_document.submission_email)
end

it "does not include the CSV and JSON section" do
expect(rendered).not_to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.csv_and_json"))
end
end

context "when both email and s3 delivery are configured" do
let(:form_metadata) do
create(:form, :live, :with_s3_configuration, delivery_configurations: [
create(:delivery_configuration, :immediate_email),
create(:delivery_configuration, :s3),
])
end

it "includes sections for both email and S3" do
expect(rendered).to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.submission_email"))
expect(rendered).to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.s3.heading"))
end
end

it "has a section for daily and weekly CSVs" do
expect(rendered).to have_css("h4", text: I18n.t("forms.made_live_form.how_you_get_completed_forms.batch_submissions.title"))
end
Expand Down