Browse Source

CLDC-2699 Update values updated at when updating reason field (#1909)

* Update values updated at

* Update tests
pull/1911/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
077390bb5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/services/imports/lettings_logs_field_import_service.rb
  2. 10
      spec/services/imports/lettings_logs_field_import_service_spec.rb

2
app/services/imports/lettings_logs_field_import_service.rb

@ -194,7 +194,7 @@ module Imports
if reason == 20 && reasonother.blank?
@logger.info("lettings log #{record.id}'s reason is other but other reason is not provided, skipping update")
else
record.update!(reason:, reasonother:)
record.update!(reason:, reasonother:, values_updated_at: Time.zone.now)
@logger.info("lettings log #{record.id}'s reason value has been set to #{reason}")
@logger.info("lettings log #{record.id}'s reasonother value has been set to #{reasonother}") if record.reasonother.present?
end

10
spec/services/imports/lettings_logs_field_import_service_spec.rb

@ -481,7 +481,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
before do
Imports::LettingsLogsImportService.new(storage_service, logger).create_logs(fixture_directory)
lettings_log_file.rewind
lettings_log.update!(reason: nil)
lettings_log.update!(reason: nil, values_updated_at: nil)
lettings_log_xml.at_xpath("//xmlns:Q9a").content = "47"
end
@ -489,6 +489,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
expect(logger).to receive(:info).with(/lettings log \d+'s reason value has been set to 47/)
expect { import_service.send(:update_reason, lettings_log_xml) }
.to(change { lettings_log.reload.reason }.from(nil).to(47))
expect(lettings_log.values_updated_at).not_to be_nil
end
end
@ -498,7 +499,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
before do
Imports::LettingsLogsImportService.new(storage_service, logger).create_logs(fixture_directory)
lettings_log_file.rewind
lettings_log.update!(reason: 18)
lettings_log.update!(reason: 18, values_updated_at: nil)
lettings_log_xml.at_xpath("//xmlns:Q9a").content = "47"
end
@ -506,6 +507,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
expect(logger).to receive(:info).with(/lettings log \d+ has a value for reason, skipping update/)
expect { import_service.send(:update_reason, lettings_log_xml) }
.not_to(change { lettings_log.reload.reason })
expect(lettings_log.values_updated_at).to be_nil
end
end
@ -515,7 +517,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
before do
Imports::LettingsLogsImportService.new(storage_service, logger).create_logs(fixture_directory)
lettings_log_file.rewind
lettings_log.update!(reason: nil)
lettings_log.update!(reason: nil, values_updated_at: nil)
lettings_log_xml.at_xpath("//xmlns:Q9a").content = "20"
end
@ -529,6 +531,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
expect(logger).to receive(:info).with(/lettings log \d+'s reasonother value has been set to other/)
expect { import_service.send(:update_reason, lettings_log_xml) }
.to(change { lettings_log.reload.reason }.from(nil).to(20))
expect(lettings_log.values_updated_at).not_to be_nil
end
end
@ -537,6 +540,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
expect(logger).to receive(:info).with(/lettings log \d+'s reason is other but other reason is not provided, skipping update/)
expect { import_service.send(:update_reason, lettings_log_xml) }
.not_to(change { lettings_log.reload.reason })
expect(lettings_log.values_updated_at).to be_nil
end
end
end

Loading…
Cancel
Save