diff --git a/app/services/imports/lettings_logs_field_import_service.rb b/app/services/imports/lettings_logs_field_import_service.rb index 68c3ba5f4..8b4124796 100644 --- a/app/services/imports/lettings_logs_field_import_service.rb +++ b/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 diff --git a/spec/services/imports/lettings_logs_field_import_service_spec.rb b/spec/services/imports/lettings_logs_field_import_service_spec.rb index 4bed2dc63..ac35169a5 100644 --- a/spec/services/imports/lettings_logs_field_import_service_spec.rb +++ b/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