Browse Source

Do not display resources for a closed collection year

pull/1721/head
Kat 2 years ago
parent
commit
4ffe8edb26
  1. 4
      app/views/layouts/_collection_resources.html.erb
  2. 38
      spec/requests/organisations_controller_spec.rb

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

@ -2,6 +2,7 @@
<h2 class="govuk-heading-m">Collection resources</h2> <h2 class="govuk-heading-m">Collection resources</h2>
<p class="govuk-body-s">For lettings starting during 1 April 2023 to 31 March 2024 and sales completing during the same period, use the 2023/24 forms.</p> <p class="govuk-body-s">For lettings starting during 1 April 2023 to 31 March 2024 and sales completing during the same period, use the 2023/24 forms.</p>
<% if FormHandler.instance.lettings_form_for_start_year(2023) && FormHandler.instance.lettings_form_for_start_year(2023).edit_end_date > Time.zone.today %>
<h3 class="govuk-heading-s">Lettings 2023/24</h3> <h3 class="govuk-heading-s">Lettings 2023/24</h3>
<%= render DocumentListComponent.new(items: [ <%= render DocumentListComponent.new(items: [
{ {
@ -49,7 +50,9 @@
metadata: file_type_size_and_pages("bulk-upload-sales-specification-2023-24.xlsx"), metadata: file_type_size_and_pages("bulk-upload-sales-specification-2023-24.xlsx"),
}, },
]) %> ]) %>
<% end %>
<% if FormHandler.instance.lettings_form_for_start_year(2022) && FormHandler.instance.lettings_form_for_start_year(2022).edit_end_date > Time.zone.today %>
<h3 class="govuk-heading-s">Lettings 2022/23</h3> <h3 class="govuk-heading-s">Lettings 2022/23</h3>
<%= render DocumentListComponent.new(items: [ <%= render DocumentListComponent.new(items: [
{ {
@ -87,4 +90,5 @@
metadata: file_type_size_and_pages("bulk-upload-sales-template-2022-23.xlsx"), metadata: file_type_size_and_pages("bulk-upload-sales-template-2022-23.xlsx"),
}, },
]) %> ]) %>
<% end %>
</div> </div>

38
spec/requests/organisations_controller_spec.rb

@ -175,7 +175,9 @@ RSpec.describe OrganisationsController, type: :request do
describe "#show" do describe "#show" do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
let(:set_time) {}
before do before do
set_time
sign_in user sign_in user
get "/organisations/#{organisation.id}", headers:, params: {} get "/organisations/#{organisation.id}", headers:, params: {}
end end
@ -183,6 +185,42 @@ RSpec.describe OrganisationsController, type: :request do
it "redirects to details" do it "redirects to details" do
expect(response).to have_http_status(:redirect) expect(response).to have_http_status(:redirect)
end end
context "and 2022 collection window is open" do
let(:set_time) { allow(Time).to receive(:now).and_return(Time.zone.local(2023, 1, 1)) }
it "displays correct resources for 2022/23 and 2023/24 collection years" do
follow_redirect!
expect(page).to have_content("Lettings 2023/24")
expect(page).to have_content("Sales 2023/24")
expect(page).to have_content("Lettings 2022/23")
expect(page).to have_content("Sales 2022/23")
end
end
context "and 2022 collection window is closed for editing" do
let(:set_time) { allow(Time).to receive(:now).and_return(Time.zone.local(2024, 1, 1)) }
it "displays correct resources for 2022/23 and 2023/24 collection years" do
follow_redirect!
expect(page).to have_content("Lettings 2023/24")
expect(page).to have_content("Sales 2023/24")
expect(page).not_to have_content("Lettings 2022/23")
expect(page).not_to have_content("Sales 2022/23")
end
end
context "and 2023 collection window is closed for editing" do
let(:set_time) { allow(Time).to receive(:now).and_return(Time.zone.local(2025, 1, 1)) }
it "displays correct resources for 2022/23 and 2023/24 collection years" do
follow_redirect!
expect(page).not_to have_content("Lettings 2023/24")
expect(page).not_to have_content("Sales 2023/24")
expect(page).not_to have_content("Lettings 2022/23")
expect(page).not_to have_content("Sales 2022/23")
end
end
end end
context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do

Loading…
Cancel
Save