diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index 2e0232dfe..3a3d41540 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -129,6 +129,7 @@ class BulkUpload < ApplicationRecord def unpend_and_confirm_soft_validations logs.find_each do |log| fields_to_confirm(log).each { |field| log[field] = 0 } + log.status = log.status_cache log.save! end end diff --git a/spec/models/bulk_upload_spec.rb b/spec/models/bulk_upload_spec.rb index db475709a..b07bef3c6 100644 --- a/spec/models/bulk_upload_spec.rb +++ b/spec/models/bulk_upload_spec.rb @@ -257,4 +257,18 @@ RSpec.describe BulkUpload, type: :model do end end end + + describe "#unpend_and_confirm_soft_validations" do + let(:bulk_upload) { create(:bulk_upload, :lettings) } + let(:log) { create(:lettings_log, :completed, bulk_upload:, status: "pending", status_cache: "in_progress", supcharg: 183.24) } + + it "resets the fields to confirm and updates the status to status_cache" do + expect(log.status).to eq("pending") + + bulk_upload.unpend_and_confirm_soft_validations + + log.reload + expect(log.status).to eq("completed") + end + end end