Browse Source

Fix soft validation unpend logs (#2881)

* Update status

* Add test

* Update test

---------

Co-authored-by: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
update-rails-admin-styling^2 v0.4.92
Manny Dinssa 1 week ago committed by GitHub
parent
commit
8a8903864d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      app/models/bulk_upload.rb
  2. 14
      spec/models/bulk_upload_spec.rb

1
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

14
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

Loading…
Cancel
Save