@ -71,8 +71,14 @@ RSpec.describe "bulk_update" do
let! ( :lettings_log ) { FactoryBot . create ( :lettings_log , :sh , scheme : schemes [ 0 ] , location : , values_updated_at : nil , owning_organisation : schemes [ 0 ] . owning_organisation ) }
let! ( :lettings_log ) { FactoryBot . create ( :lettings_log , :sh , scheme : schemes [ 0 ] , location : , values_updated_at : nil , owning_organisation : schemes [ 0 ] . owning_organisation ) }
let! ( :lettings_log_2 ) { FactoryBot . create ( :lettings_log , :sh , scheme : schemes [ 1 ] , location : location_2 , values_updated_at : nil , owning_organisation : schemes [ 1 ] . owning_organisation ) }
let! ( :lettings_log_2 ) { FactoryBot . create ( :lettings_log , :sh , scheme : schemes [ 1 ] , location : location_2 , values_updated_at : nil , owning_organisation : schemes [ 1 ] . owning_organisation ) }
let! ( :lettings_log_3 ) { FactoryBot . create ( :lettings_log , :sh , scheme : schemes [ 2 ] , location : location_3 , values_updated_at : nil , owning_organisation : schemes [ 2 ] . owning_organisation ) }
let! ( :lettings_log_3 ) { FactoryBot . create ( :lettings_log , :sh , scheme : schemes [ 2 ] , location : location_3 , values_updated_at : nil , owning_organisation : schemes [ 2 ] . owning_organisation ) }
let! ( :closed_collection_lettings_log ) { FactoryBot . create ( :lettings_log , :sh , scheme : schemes [ 0 ] , location : , values_updated_at : nil , owning_organisation : schemes [ 0 ] . owning_organisation ) }
let! ( :archived_closed_collection_lettings_log ) { FactoryBot . create ( :lettings_log , :sh , scheme : schemes [ 0 ] , location : , values_updated_at : nil , owning_organisation : schemes [ 0 ] . owning_organisation ) }
before do
before do
closed_collection_lettings_log . startdate = Time . zone . local ( 2022 , 4 , 1 )
closed_collection_lettings_log . save! ( validate : false )
archived_closed_collection_lettings_log . startdate = Time . zone . local ( 2021 , 4 , 1 )
archived_closed_collection_lettings_log . save! ( validate : false )
allow ( storage_service ) . to receive ( :get_file_io )
allow ( storage_service ) . to receive ( :get_file_io )
. with ( " original_schemes.csv " )
. with ( " original_schemes.csv " )
. and_return ( StringIO . new ( replace_entity_ids ( schemes [ 0 ] , schemes [ 1 ] , schemes [ 2 ] , File . open ( " ./spec/fixtures/files/original_schemes.csv " ) . read ) ) )
. and_return ( StringIO . new ( replace_entity_ids ( schemes [ 0 ] , schemes [ 1 ] , schemes [ 2 ] , File . open ( " ./spec/fixtures/files/original_schemes.csv " ) . read ) ) )
@ -174,6 +180,12 @@ RSpec.describe "bulk_update" do
lettings_log_3 . reload
lettings_log_3 . reload
expect ( lettings_log_3 . values_updated_at ) . to eq ( nil )
expect ( lettings_log_3 . values_updated_at ) . to eq ( nil )
closed_collection_lettings_log . reload
expect ( closed_collection_lettings_log . values_updated_at ) . not_to eq ( nil )
archived_closed_collection_lettings_log . reload
expect ( archived_closed_collection_lettings_log . values_updated_at ) . to eq ( nil )
end
end
it " logs the progress of the update " do
it " logs the progress of the update " do
@ -193,6 +205,7 @@ RSpec.describe "bulk_update" do
expect ( Rails . logger ) . to receive ( :info ) . with ( " Cannot update scheme S #{ schemes [ 0 ] . id } with created_at as it it not a permitted field " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Cannot update scheme S #{ schemes [ 0 ] . id } with created_at as it it not a permitted field " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Cannot update scheme S #{ schemes [ 0 ] . id } with active_dates as it it not a permitted field " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Cannot update scheme S #{ schemes [ 0 ] . id } with active_dates as it it not a permitted field " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Saved scheme S #{ schemes [ 0 ] . id } . " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Saved scheme S #{ schemes [ 0 ] . id } . " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Will not export log #{ archived_closed_collection_lettings_log . id } as it is before the exportable date " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " No changes to scheme S #{ schemes [ 1 ] . id } . " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " No changes to scheme S #{ schemes [ 1 ] . id } . " )
@ -245,6 +258,7 @@ RSpec.describe "bulk_update" do
expect ( Rails . logger ) . to receive ( :info ) . with ( " Cannot update scheme S #{ schemes [ 0 ] . id } with created_at as it it not a permitted field " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Cannot update scheme S #{ schemes [ 0 ] . id } with created_at as it it not a permitted field " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Cannot update scheme S #{ schemes [ 0 ] . id } with active_dates as it it not a permitted field " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Cannot update scheme S #{ schemes [ 0 ] . id } with active_dates as it it not a permitted field " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Saved scheme S #{ schemes [ 0 ] . id } . " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Saved scheme S #{ schemes [ 0 ] . id } . " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " Will not export log #{ archived_closed_collection_lettings_log . id } as it is before the exportable date " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " No changes to scheme S #{ schemes [ 1 ] . id } . " )
expect ( Rails . logger ) . to receive ( :info ) . with ( " No changes to scheme S #{ schemes [ 1 ] . id } . " )