Browse Source

Add test and update text

pull/2883/head
Manny Dinssa 5 months ago
parent
commit
1c3b6efb55
  1. 4
      app/helpers/tag_helper.rb
  2. 4
      app/models/bulk_upload.rb
  3. 2
      app/services/bulk_upload/processor.rb
  4. 5
      spec/services/bulk_upload/processor_spec.rb

4
app/helpers/tag_helper.rb

@ -21,7 +21,7 @@ module TagHelper
processing: "Processing",
blank_template: "Blank template",
wrong_template: "Wrong template used",
invalid_upload: "Invalid upload",
processing_error: "Error processing CSV",
important_errors: "Errors on important questions in CSV",
critical_errors: "Critical errors in CSV",
potential_errors: "Potential errors in CSV",
@ -49,7 +49,7 @@ module TagHelper
processing: "yellow",
blank_template: "red",
wrong_template: "red",
invalid_upload: "red",
processing_error: "red",
important_errors: "red",
critical_errors: "red",
potential_errors: "red",

4
app/models/bulk_upload.rb

@ -1,7 +1,7 @@
class BulkUpload < ApplicationRecord
enum :log_type, { lettings: "lettings", sales: "sales" }
enum :rent_type_fix_status, { not_applied: "not_applied", applied: "applied", not_needed: "not_needed" }
enum :failure_reason, { blank_template: "blank_template", wrong_template: "wrong_template", invalid_upload: "invalid_upload" }
enum :failure_reason, { blank_template: "blank_template", wrong_template: "wrong_template", processing_error: "processing_error" }
belongs_to :user
@ -43,7 +43,7 @@ class BulkUpload < ApplicationRecord
return :processing if processing
return :blank_template if failure_reason == "blank_template"
return :wrong_template if failure_reason == "wrong_template"
return :invalid_upload if failure_reason == "invalid_upload"
return :processing_error if failure_reason == "processing_error"
if logs.visible.exists?
return :errors_fixed_in_service if completed? && bulk_upload_errors.any?

2
app/services/bulk_upload/processor.rb

@ -61,7 +61,7 @@ class BulkUpload::Processor
end
rescue StandardError => e
Sentry.capture_exception(e)
@bulk_upload.update!(failure_reason: "invalid_upload")
@bulk_upload.update!(failure_reason: "processing_error")
send_failure_mail
ensure
downloader.delete_local_file!

5
spec/services/bulk_upload/processor_spec.rb

@ -101,6 +101,11 @@ RSpec.describe BulkUpload::Processor do
allow(mock_validator).to receive(:call).and_raise(StandardError)
end
it "updates the failure_reason to invalid_upload" do
processor.call
expect(bulk_upload.reload.failure_reason).to eq("processing_error")
end
it "sends failure email" do
mail_double = instance_double("ActionMailer::MessageDelivery", deliver_later: nil)

Loading…
Cancel
Save