Browse Source

Update upload new mandatory resource page

pull/2683/head
Kat 2 years ago
parent
commit
084e9c81fc
  1. 2
      app/views/collection_resources/_collection_resource_summary_list.erb
  2. 5
      app/views/collection_resources/edit.html.erb
  3. 52
      spec/requests/collection_resources_controller_spec.rb

2
app/views/collection_resources/_collection_resource_summary_list.erb

@ -18,7 +18,7 @@
<% end %>
<% row.with_action(
text: "Upload",
href: "/",
href: edit_mandatory_collection_resource_path(year: resource.year, log_type: resource.log_type, resource_type: resource.resource_type),
) %>
<% end %>
<% end %>

5
app/views/collection_resources/edit.html.erb

@ -4,6 +4,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% resource_exists = file_exists_on_s3?(@collection_resource.download_filename) %>
<%= form_with model: @collection_resource, url: update_mandatory_collection_resource_path, method: :patch do |f| %>
<%= f.hidden_field :year %>
<%= f.hidden_field :log_type %>
@ -12,7 +13,7 @@
<%= f.govuk_error_summary %>
<span class="govuk-caption-l"><%= "#{@collection_resource.log_type.humanize} #{text_year_range_format(@collection_resource.year)}" %></span>
<h1 class="govuk-heading-l">Change the <%= @collection_resource.resource_type.humanize.downcase %></h1>
<h1 class="govuk-heading-l"><%= resource_exists ? "Change" : "Upload" %> the <%= @collection_resource.resource_type.humanize.downcase %></h1>
<p class="govuk-body">
This file will be available for all users to download.
@ -21,7 +22,7 @@
<%= f.govuk_file_field :file,
label: { text: "Upload file", size: "m" } %>
<%= f.govuk_submit "Save changes" %>
<%= f.govuk_submit resource_exists ? "Save changes" : "Upload" %>
<%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %>
<% end %>
</div>

52
spec/requests/collection_resources_controller_spec.rb

@ -122,6 +122,19 @@ RSpec.describe CollectionResourcesController, type: :request do
it "displays upload links" do
expect(page).to have_selector(:link_or_button, "Upload", count: 12)
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2024, log_type: "lettings", resource_type: "paper_form"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2024, log_type: "lettings", resource_type: "bulk_upload_template"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2024, log_type: "lettings", resource_type: "bulk_upload_specification"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2024, log_type: "sales", resource_type: "paper_form"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2024, log_type: "sales", resource_type: "bulk_upload_template"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2024, log_type: "sales", resource_type: "bulk_upload_specification"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2025, log_type: "lettings", resource_type: "paper_form"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2025, log_type: "lettings", resource_type: "bulk_upload_template"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2025, log_type: "lettings", resource_type: "bulk_upload_specification"))
expect(page).to have_link("Upload", href: edit_mandatory_collection_resource_path(year: 2025, log_type: "sales", resource_type: "paper_form"))
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
end
end
@ -243,16 +256,37 @@ RSpec.describe CollectionResourcesController, type: :request do
sign_in user
end
it "displays update collection resources page content" do
get edit_mandatory_collection_resource_path(year: 2024, log_type: "sales", resource_type: "bulk_upload_template")
context "and the file exists on S3" do
it "displays update collection resources page content" do
get edit_mandatory_collection_resource_path(year: 2024, log_type: "sales", resource_type: "bulk_upload_template")
expect(page).to have_content("Sales 2024 to 2025")
expect(page).to have_content("Change the bulk upload template")
expect(page).to have_content("This file will be available for all users to download.")
expect(page).to have_content("Upload file")
expect(page).to have_button("Save changes")
expect(page).to have_link("Back", href: collection_resources_path)
expect(page).to have_link("Cancel", href: collection_resources_path)
end
end
expect(page).to have_content("Sales 2024 to 2025")
expect(page).to have_content("Change the bulk upload template")
expect(page).to have_content("This file will be available for all users to download.")
expect(page).to have_content("Upload file")
expect(page).to have_button("Save changes")
expect(page).to have_link("Back", href: collection_resources_path)
expect(page).to have_link("Cancel", href: collection_resources_path)
context "and the file does not exist on S3" do
before do
WebMock.stub_request(:head, /https:\/\/core-test-collection-resources\.s3\.amazonaws\.com/)
.to_return(status: 404, body: "", headers: {})
end
it "displays upload collection resources page content" do
get edit_mandatory_collection_resource_path(year: 2024, log_type: "sales", resource_type: "bulk_upload_template")
expect(page).to have_content("Sales 2024 to 2025")
expect(page).to have_content("Upload the bulk upload template")
expect(page).to have_content("This file will be available for all users to download.")
expect(page).to have_content("Upload file")
expect(page).to have_button("Upload")
expect(page).to have_link("Back", href: collection_resources_path)
expect(page).to have_link("Cancel", href: collection_resources_path)
end
end
end
end

Loading…
Cancel
Save