Browse Source

bulk upload resume handles upload again

bulk-upload-resume-v2
Phil Lee 2 years ago
parent
commit
6f66c29230
  1. 2
      app/controllers/bulk_upload_lettings_resume_controller.rb
  2. 14
      app/models/forms/bulk_upload_lettings_resume/fix_choice.rb
  3. 8
      spec/requests/bulk_upload_lettings_resume_controller_spec.rb

2
app/controllers/bulk_upload_lettings_resume_controller.rb

@ -26,7 +26,7 @@ class BulkUploadLettingsResumeController < ApplicationController
private
def form
@form ||= Forms::BulkUploadLettingsResume::FixChoice.new(form_params)
@form ||= Forms::BulkUploadLettingsResume::FixChoice.new(form_params.merge(bulk_upload: @bulk_upload))
end
def form_params

14
app/models/forms/bulk_upload_lettings_resume/fix_choice.rb

@ -5,6 +5,7 @@ module Forms
include ActiveModel::Attributes
include Rails.application.routes.url_helpers
attribute :bulk_upload
attribute :choice, :string
validates :choice, presence: true,
@ -20,6 +21,19 @@ module Forms
def view_path
"bulk_upload_lettings_resume/fix_choice"
end
def next_path
case choice
when "upload-again"
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors?
summary_bulk_upload_lettings_result_path(bulk_upload)
else
bulk_upload_lettings_result_path(bulk_upload)
end
else
raise "invalid choice"
end
end
end
end
end

8
spec/requests/bulk_upload_lettings_resume_controller_spec.rb

@ -40,5 +40,13 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do
expect(response.body).to include("You must select")
end
end
context "when upload again selected" do
it "sends them to relevant report" do
patch "/lettings-logs/bulk-upload-resume/#{bulk_upload.id}/fix-choice", params: { form: { choice: "upload-again" } }
expect(response).to redirect_to("/lettings-logs/bulk-upload-results/#{bulk_upload.id}")
end
end
end
end

Loading…
Cancel
Save