diff --git a/app/helpers/collection_resources_helper.rb b/app/helpers/collection_resources_helper.rb
index e1fb6cf2b..ad2e8917b 100644
--- a/app/helpers/collection_resources_helper.rb
+++ b/app/helpers/collection_resources_helper.rb
@@ -1,5 +1,7 @@
module CollectionResourcesHelper
include CollectionTimeHelper
+ include GovukLinkHelper
+ include GovukVisuallyHiddenHelper
HUMAN_READABLE_CONTENT_TYPE = { "application/pdf": "PDF",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "Microsoft Excel",
@@ -66,4 +68,16 @@ module CollectionResourcesHelper
def file_exists_on_s3?(file)
CollectionResourcesService.new.file_exists_on_s3?(file)
end
+
+ def display_next_year_banner?
+ editable_collection_resource_years.include?(next_collection_start_year)
+ end
+
+ def next_year_banner_text(lettings_resources, sales_resources)
+ if lettings_resources[next_collection_start_year].map(&:download_filename).all? { |file| file_exists_on_s3?(file) } && sales_resources[next_collection_start_year].map(&:download_filename).all? { |file| file_exists_on_s3?(file) }
+ govuk_link_to "Release the #{text_year_range_format(next_collection_start_year)} collection resources to users", release_mandatory_collection_resources_path(year: next_collection_start_year), class: "govuk-link"
+ else
+ "Once you have uploaded all the required #{text_year_range_format(next_collection_start_year)} collection resources, you will be able to release them to users."
+ end
+ end
end
diff --git a/app/views/collection_resources/index.html.erb b/app/views/collection_resources/index.html.erb
index f6a999e59..f6785eb46 100644
--- a/app/views/collection_resources/index.html.erb
+++ b/app/views/collection_resources/index.html.erb
@@ -4,6 +4,14 @@
<%= govuk_back_link(href: :back) %>
<% end %>
+<% if display_next_year_banner? %>
+ <%= govuk_notification_banner(title_text: "Important") do %>
+
+ The <%= text_year_range_format(next_collection_start_year) %> collection resources are not yet available to users.
+
+ <%= next_year_banner_text(@mandatory_lettings_collection_resources_per_year, @mandatory_sales_collection_resources_per_year) %>
+ <% end %>
+<% end %>
<%= title %>
<% @mandatory_lettings_collection_resources_per_year.each do |year, mandatory_resources| %>
diff --git a/config/routes.rb b/config/routes.rb
index 3fa83458a..c8e1c40f5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -44,6 +44,7 @@ Rails.application.routes.draw do
get "/collection-resources/:log_type/:year/:resource_type/download", to: "collection_resources#download_mandatory_collection_resource", as: :download_mandatory_collection_resource
get "/collection-resources/:log_type/:year/:resource_type/edit", to: "collection_resources#edit", as: :edit_mandatory_collection_resource
patch "/collection-resources", to: "collection_resources#update", as: :update_mandatory_collection_resource
+ get "/collection-resources/:year/release", to: "collection_resources#release_mandatory_resources", as: :release_mandatory_collection_resources
resources :collection_resources, path: "/collection-resources" do
get "/download", to: "collection_resources#download_additional_collection_resource" # when we get to adding them
diff --git a/spec/helpers/collection_resources_helper_spec.rb b/spec/helpers/collection_resources_helper_spec.rb
index 31033d997..05eef5a45 100644
--- a/spec/helpers/collection_resources_helper_spec.rb
+++ b/spec/helpers/collection_resources_helper_spec.rb
@@ -163,4 +163,54 @@ RSpec.describe CollectionResourcesHelper do
])
end
end
+
+ describe "#display_next_year_banner?" do
+ context "when next year is not editable" do
+ before do
+ allow(FormHandler.instance).to receive(:in_edit_crossover_period?).and_return(true)
+ end
+
+ it "returns false" do
+ expect(display_next_year_banner?).to be_falsey
+ end
+ end
+
+ context "when next year is editable" do
+ before do
+ allow(FormHandler.instance).to receive(:in_edit_crossover_period?).and_return(false)
+ allow(Time.zone).to receive(:today).and_return(Time.zone.local(2025, 1, 1))
+ end
+
+ it "returns true" do
+ expect(display_next_year_banner?).to be_truthy
+ end
+ end
+ end
+
+ describe "#next_year_banner_text" do
+ let(:lettings_resources) { MandatoryCollectionResourcesService.generate_resources("lettings", [next_collection_start_year]) }
+ let(:sales_resources) { MandatoryCollectionResourcesService.generate_resources("sales", [next_collection_start_year]) }
+
+ context "when all the mandatory resources for next year are uploaded" do
+ before do
+ WebMock.stub_request(:head, /https:\/\/core-test-collection-resources\.s3\.amazonaws\.com/)
+ .to_return(status: 200, body: "", headers: { "Content-Length" => 292_864, "Content-Type" => "application/pdf" })
+ end
+
+ it "returns correct text" do
+ expect(next_year_banner_text(lettings_resources, sales_resources)).to match(/Release the 2025 to 2026 collection resources to users/)
+ end
+ end
+
+ context "when some of the mandatory resources for next year are not uploaded" do
+ before do
+ WebMock.stub_request(:head, /https:\/\/core-test-collection-resources\.s3\.amazonaws\.com/)
+ .to_return(status: 404, body: "", headers: { "Content-Length" => 292_864, "Content-Type" => "application/pdf" })
+ end
+
+ it "returns correct text" do
+ expect(next_year_banner_text(lettings_resources, sales_resources)).to eq("Once you have uploaded all the required 2025 to 2026 collection resources, you will be able to release them to users.")
+ end
+ end
+ end
end
diff --git a/spec/requests/collection_resources_controller_spec.rb b/spec/requests/collection_resources_controller_spec.rb
index 48a94ee7f..93b6755d6 100644
--- a/spec/requests/collection_resources_controller_spec.rb
+++ b/spec/requests/collection_resources_controller_spec.rb
@@ -108,6 +108,11 @@ RSpec.describe CollectionResourcesController, type: :request do
expect(page).to have_link("Change", href: edit_mandatory_collection_resource_path(year: 2025, log_type: "sales", resource_type: "bulk_upload_template"))
expect(page).to have_link("Change", href: edit_mandatory_collection_resource_path(year: 2025, log_type: "sales", resource_type: "bulk_upload_specification"))
end
+
+ it "displays next year banner" do
+ expect(page).to have_content("The 2025 to 2026 collection resources are not yet available to users.")
+ expect(page).to have_link("Release the 2025 to 2026 collection resources to users", href: release_mandatory_collection_resources_path(year: 2025))
+ end
end
context "when files are not on S3" do
@@ -136,6 +141,11 @@ RSpec.describe CollectionResourcesController, type: :request do
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2025, log_type: "sales", resource_type: "bulk_upload_template"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2025, log_type: "sales", resource_type: "bulk_upload_specification"))
end
+
+ it "displays next year banner" do
+ expect(page).to have_content("The 2025 to 2026 collection resources are not yet available to users.")
+ expect(page).to have_content("Once you have uploaded all the required 2025 to 2026 collection resources, you will be able to release them to users.")
+ end
end
end
end