diff --git a/app/controllers/bulk_upload_lettings_logs_controller.rb b/app/controllers/bulk_upload_lettings_logs_controller.rb index 4ab636e7a..465bbc5f6 100644 --- a/app/controllers/bulk_upload_lettings_logs_controller.rb +++ b/app/controllers/bulk_upload_lettings_logs_controller.rb @@ -47,7 +47,7 @@ private when "prepare-your-file" Forms::BulkUploadLettings::PrepareYourFile.new(form_params) when "guidance" - Forms::BulkUploadLettings::Guidance.new(form_params) + Forms::BulkUploadLettings::Guidance.new(form_params.merge(referrer: params[:referrer])) when "needstype" Forms::BulkUploadLettings::Needstype.new(form_params) when "upload-your-file" diff --git a/app/controllers/bulk_upload_sales_logs_controller.rb b/app/controllers/bulk_upload_sales_logs_controller.rb index 18f1e89c8..56bd1d4de 100644 --- a/app/controllers/bulk_upload_sales_logs_controller.rb +++ b/app/controllers/bulk_upload_sales_logs_controller.rb @@ -47,7 +47,7 @@ private when "prepare-your-file" Forms::BulkUploadSales::PrepareYourFile.new(form_params) when "guidance" - Forms::BulkUploadSales::Guidance.new(form_params) + Forms::BulkUploadSales::Guidance.new(form_params.merge(referrer: params[:referrer])) when "upload-your-file" Forms::BulkUploadSales::UploadYourFile.new(form_params.merge(current_user:)) when "checking-file" diff --git a/app/models/forms/bulk_upload_lettings/guidance.rb b/app/models/forms/bulk_upload_lettings/guidance.rb index 66683eb9b..b6cf5bf74 100644 --- a/app/models/forms/bulk_upload_lettings/guidance.rb +++ b/app/models/forms/bulk_upload_lettings/guidance.rb @@ -6,13 +6,21 @@ module Forms include Rails.application.routes.url_helpers attribute :year, :integer + attribute :referrer def view_path "bulk_upload_shared/guidance" end def back_path - bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: }) + case referrer + when "prepare-your-file" + bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: }) + when "home" + root_path + else + guidance_path + end end def lettings_legacy_template_path diff --git a/app/models/forms/bulk_upload_sales/guidance.rb b/app/models/forms/bulk_upload_sales/guidance.rb index 44987cd87..28ca6c3b5 100644 --- a/app/models/forms/bulk_upload_sales/guidance.rb +++ b/app/models/forms/bulk_upload_sales/guidance.rb @@ -6,13 +6,21 @@ module Forms include Rails.application.routes.url_helpers attribute :year, :integer + attribute :referrer def view_path "bulk_upload_shared/guidance" end def back_path - bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: }) + case referrer + when "prepare-your-file" + bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: }) + when "home" + root_path + else + guidance_path + end end def lettings_legacy_template_path diff --git a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb index 41564c7b2..21d19dba8 100644 --- a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb +++ b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb @@ -9,7 +9,7 @@ Upload lettings logs in bulk (<%= @form.year_combo %>)
<%= 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.
+<%= 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.
<%= 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.
+<%= 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.
<%= 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.
+<%= 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.
<%= 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.
+<%= 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.
<%= govuk_link_to "Guidance for submitting social housing lettings and sales data (CORE)", guidance_path %>
+<%= govuk_link_to "How to upload logs in bulk", bulk_upload_lettings_log_path(id: "guidance", form: { year: current_collection_start_year }, referrer: "home") %>
<% else %>There are 2 ways to create logs on CORE.
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.
-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 }) %>.
+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") %>.
Once you have created and completed a log, there is nothing more you need to do to submit the data.
<% end %> diff --git a/spec/models/forms/bulk_upload_lettings/guidance_spec.rb b/spec/models/forms/bulk_upload_lettings/guidance_spec.rb new file mode 100644 index 000000000..271ff8b27 --- /dev/null +++ b/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 diff --git a/spec/models/forms/bulk_upload_sales/guidance_spec.rb b/spec/models/forms/bulk_upload_sales/guidance_spec.rb new file mode 100644 index 000000000..6eacf6d0c --- /dev/null +++ b/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