Browse Source

CLDC-3532: Make BU guidance back link depend on referrer (#2482)

* CLDC-3532: Make BU guidance back link depend on referrer

* Add tests for back_path

* Add guidance to homepage

* CLDC-3526: Update back_path

---------

Co-authored-by: Kat <katrina@kosiak.co.uk>
pull/2487/head
Rachael Booth 6 months ago committed by GitHub
parent
commit
356d652db1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/controllers/bulk_upload_lettings_logs_controller.rb
  2. 2
      app/controllers/bulk_upload_sales_logs_controller.rb
  3. 8
      app/models/forms/bulk_upload_lettings/guidance.rb
  4. 8
      app/models/forms/bulk_upload_sales/guidance.rb
  5. 2
      app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb
  6. 2
      app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb
  7. 2
      app/views/bulk_upload_sales_logs/forms/prepare_your_file_2023.html.erb
  8. 2
      app/views/bulk_upload_sales_logs/forms/prepare_your_file_2024.html.erb
  9. 1
      app/views/layouts/_collection_resources.html.erb
  10. 2
      app/views/start/guidance.html.erb
  11. 43
      spec/models/forms/bulk_upload_lettings/guidance_spec.rb
  12. 43
      spec/models/forms/bulk_upload_sales/guidance_spec.rb

2
app/controllers/bulk_upload_lettings_logs_controller.rb

@ -47,7 +47,7 @@ private
when "prepare-your-file" when "prepare-your-file"
Forms::BulkUploadLettings::PrepareYourFile.new(form_params) Forms::BulkUploadLettings::PrepareYourFile.new(form_params)
when "guidance" when "guidance"
Forms::BulkUploadLettings::Guidance.new(form_params) Forms::BulkUploadLettings::Guidance.new(form_params.merge(referrer: params[:referrer]))
when "needstype" when "needstype"
Forms::BulkUploadLettings::Needstype.new(form_params) Forms::BulkUploadLettings::Needstype.new(form_params)
when "upload-your-file" when "upload-your-file"

2
app/controllers/bulk_upload_sales_logs_controller.rb

@ -47,7 +47,7 @@ private
when "prepare-your-file" when "prepare-your-file"
Forms::BulkUploadSales::PrepareYourFile.new(form_params) Forms::BulkUploadSales::PrepareYourFile.new(form_params)
when "guidance" when "guidance"
Forms::BulkUploadSales::Guidance.new(form_params) Forms::BulkUploadSales::Guidance.new(form_params.merge(referrer: params[:referrer]))
when "upload-your-file" when "upload-your-file"
Forms::BulkUploadSales::UploadYourFile.new(form_params.merge(current_user:)) Forms::BulkUploadSales::UploadYourFile.new(form_params.merge(current_user:))
when "checking-file" when "checking-file"

8
app/models/forms/bulk_upload_lettings/guidance.rb

@ -6,13 +6,21 @@ module Forms
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
attribute :year, :integer attribute :year, :integer
attribute :referrer
def view_path def view_path
"bulk_upload_shared/guidance" "bulk_upload_shared/guidance"
end end
def back_path def back_path
case referrer
when "prepare-your-file"
bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: }) bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: })
when "home"
root_path
else
guidance_path
end
end end
def lettings_legacy_template_path def lettings_legacy_template_path

8
app/models/forms/bulk_upload_sales/guidance.rb

@ -6,13 +6,21 @@ module Forms
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
attribute :year, :integer attribute :year, :integer
attribute :referrer
def view_path def view_path
"bulk_upload_shared/guidance" "bulk_upload_shared/guidance"
end end
def back_path def back_path
case referrer
when "prepare-your-file"
bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: }) bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: })
when "home"
root_path
else
guidance_path
end
end end
def lettings_legacy_template_path def lettings_legacy_template_path

2
app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb

@ -9,7 +9,7 @@
<span class="govuk-caption-l">Upload lettings logs in bulk (<%= @form.year_combo %>)</span> <span class="govuk-caption-l">Upload lettings logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">Prepare your file</h1> <h1 class="govuk-heading-l">Prepare your file</h1>
<p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_lettings_log_path(id: "guidance", form: { year: @form.year }) %> before you start if you have not used bulk upload before.</p> <p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_lettings_log_path(id: "guidance", form: { year: @form.year }, referrer: "prepare-your-file") %> before you start if you have not used bulk upload before.</p>
<h2 class="govuk-heading-s">Download template</h2> <h2 class="govuk-heading-s">Download template</h2>

2
app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb

@ -9,7 +9,7 @@
<span class="govuk-caption-l">Upload lettings logs in bulk (<%= @form.year_combo %>)</span> <span class="govuk-caption-l">Upload lettings logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">Prepare your file</h1> <h1 class="govuk-heading-l">Prepare your file</h1>
<p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_lettings_log_path(id: "guidance", form: { year: @form.year }) %> before you start if you have not used bulk upload before.</p> <p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_lettings_log_path(id: "guidance", form: { year: @form.year }, referrer: "prepare-your-file") %> before you start if you have not used bulk upload before.</p>
<h2 class="govuk-heading-s">Download template</h2> <h2 class="govuk-heading-s">Download template</h2>

2
app/views/bulk_upload_sales_logs/forms/prepare_your_file_2023.html.erb

@ -9,7 +9,7 @@
<span class="govuk-caption-l">Upload sales logs in bulk (<%= @form.year_combo %>)</span> <span class="govuk-caption-l">Upload sales logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">Prepare your file</h1> <h1 class="govuk-heading-l">Prepare your file</h1>
<p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_sales_log_path(id: "guidance", form: { year: @form.year }) %> before you start if you have not used bulk upload before.</p> <p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_sales_log_path(id: "guidance", form: { year: @form.year }, referrer: "prepare-your-file") %> before you start if you have not used bulk upload before.</p>
<h2 class="govuk-heading-s">Download template</h2> <h2 class="govuk-heading-s">Download template</h2>

2
app/views/bulk_upload_sales_logs/forms/prepare_your_file_2024.html.erb

@ -9,7 +9,7 @@
<span class="govuk-caption-l">Upload sales logs in bulk (<%= @form.year_combo %>)</span> <span class="govuk-caption-l">Upload sales logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">Prepare your file</h1> <h1 class="govuk-heading-l">Prepare your file</h1>
<p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_sales_log_path(id: "guidance", form: { year: @form.year }) %> before you start if you have not used bulk upload before.</p> <p class="govuk-body govuk-!-margin-bottom-2"><%= govuk_link_to "Read the full guidance", bulk_upload_sales_log_path(id: "guidance", form: { year: @form.year }, referrer: "prepare-your-file") %> before you start if you have not used bulk upload before.</p>
<h2 class="govuk-heading-s">Download template</h2> <h2 class="govuk-heading-s">Download template</h2>

1
app/views/layouts/_collection_resources.html.erb

@ -1,6 +1,7 @@
<% if current_user %> <% if current_user %>
<h1 class="govuk-heading-l">Collection resources</h1> <h1 class="govuk-heading-l">Collection resources</h1>
<p class="govuk-body"><strong><%= govuk_link_to "Guidance for submitting social housing lettings and sales data (CORE)", guidance_path %></strong></p> <p class="govuk-body"><strong><%= govuk_link_to "Guidance for submitting social housing lettings and sales data (CORE)", guidance_path %></strong></p>
<p class="govuk-body"><strong><%= govuk_link_to "How to upload logs in bulk", bulk_upload_lettings_log_path(id: "guidance", form: { year: current_collection_start_year }, referrer: "home") %></strong></p>
<% else %> <% else %>
<h2 class="govuk-heading-m">Collection resources</h2> <h2 class="govuk-heading-m">Collection resources</h2>
<% end %> <% end %>

2
app/views/start/guidance.html.erb

@ -9,7 +9,7 @@
<%= accordion.with_section(heading_text: "How to create logs", expanded: true) do %> <%= accordion.with_section(heading_text: "How to create logs", expanded: true) do %>
<p class="govuk-body">There are 2 ways to create logs on CORE.</p> <p class="govuk-body">There are 2 ways to create logs on CORE.</p>
<p class="govuk-body">You can create logs one at a time by answering questions using the online form. Click the “Create a new log” button on the logs page to create logs this way.</p> <p class="govuk-body">You can create logs one at a time by answering questions using the online form. Click the “Create a new log” button on the logs page to create logs this way.</p>
<p class="govuk-body">You can also create many logs at once by uploading a CSV file. This might be faster than creating logs individually if your organisation has its own database and a way to export the data. Click the “Upload logs in bulk” button on the logs page to create logs this way. For more information, <%= govuk_link_to "read the full guidance on bulk upload", bulk_upload_lettings_log_path(id: "guidance", form: { year: current_collection_start_year }) %>.</p> <p class="govuk-body">You can also create many logs at once by uploading a CSV file. This might be faster than creating logs individually if your organisation has its own database and a way to export the data. Click the “Upload logs in bulk” button on the logs page to create logs this way. For more information, <%= govuk_link_to "read the full guidance on bulk upload", bulk_upload_lettings_log_path(id: "guidance", form: { year: current_collection_start_year }, referrer: "guidance") %>.</p>
<p class="govuk-body">Once you have created and completed a log, there is nothing more you need to do to submit the data.</p> <p class="govuk-body">Once you have created and completed a log, there is nothing more you need to do to submit the data.</p>
<% end %> <% end %>

43
spec/models/forms/bulk_upload_lettings/guidance_spec.rb

@ -0,0 +1,43 @@
require "rails_helper"
RSpec.describe Forms::BulkUploadLettings::Guidance do
include Rails.application.routes.url_helpers
subject(:bu_guidance) { described_class.new(year:, referrer:) }
let(:year) { 2024 }
describe "#back_path" do
context "when referrer is prepare-your-file" do
let(:referrer) { "prepare-your-file" }
it "returns the prepare your file path" do
expect(bu_guidance.back_path).to eq bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: })
end
end
context "when referrer is home" do
let(:referrer) { "home" }
it "returns the root path" do
expect(bu_guidance.back_path).to eq root_path
end
end
context "when referrer is guidance" do
let(:referrer) { "guidance" }
it "returns the main guidance page path" do
expect(bu_guidance.back_path).to eq guidance_path
end
end
context "when referrer is absent" do
let(:referrer) { nil }
it "returns the main guidance page path" do
expect(bu_guidance.back_path).to eq guidance_path
end
end
end
end

43
spec/models/forms/bulk_upload_sales/guidance_spec.rb

@ -0,0 +1,43 @@
require "rails_helper"
RSpec.describe Forms::BulkUploadSales::Guidance do
include Rails.application.routes.url_helpers
subject(:bu_guidance) { described_class.new(year:, referrer:) }
let(:year) { 2024 }
describe "#back_path" do
context "when referrer is prepare-your-file" do
let(:referrer) { "prepare-your-file" }
it "returns the prepare your file path" do
expect(bu_guidance.back_path).to eq bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: })
end
end
context "when referrer is home" do
let(:referrer) { "home" }
it "returns the root path" do
expect(bu_guidance.back_path).to eq root_path
end
end
context "when referrer is guidance" do
let(:referrer) { "guidance" }
it "returns the main guidance page path" do
expect(bu_guidance.back_path).to eq guidance_path
end
end
context "when referrer is absent" do
let(:referrer) { nil }
it "returns the main guidance page path" do
expect(bu_guidance.back_path).to eq guidance_path
end
end
end
end
Loading…
Cancel
Save