diff --git a/.rubocop.yml b/.rubocop.yml index 273b52581a..8755305441 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -177,6 +177,5 @@ RSpec/IndexedLet: FactoryBot/FactoryAssociationWithStrategy: Enabled: false - Capybara/ClickLinkOrButtonStyle: Enabled: false diff --git a/Gemfile.lock b/Gemfile.lock index e2762d5407..6fa74c0d08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -506,7 +506,7 @@ GEM rubocop (~> 1.41) rubocop-factory_bot (2.24.0) rubocop (~> 1.33) - rubocop-rails (2.20.2) + rubocop-rails (2.21.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -605,7 +605,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.8.2) - unicode-display_width (2.4.2) + unicode-display_width (2.5.0) uniform_notifier (1.16.0) version_gem (1.1.1) virtus (2.0.0) diff --git a/app/controllers/facilities_management/rm3830/admin/supplier_framework_data_controller.rb b/app/controllers/facilities_management/rm3830/admin/supplier_framework_data_controller.rb index 6cfe474884..19de53c569 100644 --- a/app/controllers/facilities_management/rm3830/admin/supplier_framework_data_controller.rb +++ b/app/controllers/facilities_management/rm3830/admin/supplier_framework_data_controller.rb @@ -3,7 +3,7 @@ module RM3830 module Admin class SupplierFrameworkDataController < FacilitiesManagement::Admin::FrameworkController def index - @fm_suppliers = SuppliersAdmin.all.order(:supplier_name).select(:supplier_id, :supplier_name, :lot_data).map do |supplier| + @fm_suppliers = SuppliersAdmin.order(:supplier_name).select(:supplier_id, :supplier_name, :lot_data).map do |supplier| { name: supplier.supplier_name, lot_numbers: supplier.lot_data.keys, supplier_id: supplier.supplier_id } end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 827d3ce101..a6aadb904a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -314,7 +314,7 @@ def contact_link(link_text) def accordion_region_items(region_codes, with_overseas: false) nuts1_regions = Nuts1Region.send(with_overseas ? :all_with_overseas : :all).to_h { |region| [region.code, { name: region.name, items: [] }] } - FacilitiesManagement::Region.all.each do |region| + FacilitiesManagement::Region.find_each do |region| region_group_code = region.code[..2] next unless nuts1_regions[region_group_code] diff --git a/app/models/concerns/static_record.rb b/app/models/concerns/static_record.rb index 192ce1069f..7bb3921c86 100644 --- a/app/models/concerns/static_record.rb +++ b/app/models/concerns/static_record.rb @@ -19,6 +19,12 @@ def all @all ||= [] end + delegate :first, :count, to: :all + + def find_each(&) + all.each(&) + end + def find_by(arg) all.find { |term| arg.all? { |k, v| term.public_send(k) == v } } end diff --git a/app/models/facilities_management/rm3830/procurement.rb b/app/models/facilities_management/rm3830/procurement.rb index 73366a65c4..6dc1908fbf 100644 --- a/app/models/facilities_management/rm3830/procurement.rb +++ b/app/models/facilities_management/rm3830/procurement.rb @@ -170,7 +170,7 @@ def unanswered_contract_date_questions? def copy_fm_rates_to_frozen ActiveRecord::Base.transaction do - Rate.all.find_each do |rate| + Rate.find_each do |rate| new_rate = FrozenRate.new new_rate.facilities_management_rm3830_procurement_id = id new_rate.code = rate.code diff --git a/app/models/facilities_management/rm3830/service.rb b/app/models/facilities_management/rm3830/service.rb index 43e00bc063..5f59cf2c34 100644 --- a/app/models/facilities_management/rm3830/service.rb +++ b/app/models/facilities_management/rm3830/service.rb @@ -41,7 +41,7 @@ def self.direct_award_services(procurement_id) return frozen_rate.where(direct_award: true).map(&:code) if frozen_rate.exists? - Rate.all.where(direct_award: true).map(&:code) unless frozen_rate.exists? + Rate.where(direct_award: true).map(&:code) unless frozen_rate.exists? end end diff --git a/app/models/facilities_management/rm3830/supplier_detail.rb b/app/models/facilities_management/rm3830/supplier_detail.rb index d685eddf41..225cb6c9c2 100644 --- a/app/models/facilities_management/rm3830/supplier_detail.rb +++ b/app/models/facilities_management/rm3830/supplier_detail.rb @@ -7,7 +7,7 @@ class SupplierDetail < ApplicationRecord # rubocop:enable Rails/HasManyOrHasOneDependent def self.selected_suppliers(for_lot, for_regions, for_services) - all.order(:supplier_name).select do |s| + order(:supplier_name).select do |s| s.lot_data[for_lot] && (for_regions - s.lot_data[for_lot]['regions']).empty? && (for_services - s.lot_data[for_lot]['services']).empty? end end diff --git a/app/services/facilities_management/rm3830/admin/procurement_csv_export.rb b/app/services/facilities_management/rm3830/admin/procurement_csv_export.rb index 92e52032b7..9585fd28b9 100644 --- a/app/services/facilities_management/rm3830/admin/procurement_csv_export.rb +++ b/app/services/facilities_management/rm3830/admin/procurement_csv_export.rb @@ -387,7 +387,7 @@ def self.spreadsheet_import_status(procurement) end def self.supplier_names - @supplier_names ||= SupplierDetail.all.select(:supplier_id, :supplier_name).pluck(:supplier_id, :supplier_name).to_h + @supplier_names ||= SupplierDetail.select(:supplier_id, :supplier_name).pluck(:supplier_id, :supplier_name).to_h end end end diff --git a/app/services/facilities_management/rm3830/admin/supplier_framework_data_spreadsheet.rb b/app/services/facilities_management/rm3830/admin/supplier_framework_data_spreadsheet.rb index da1a9a34ea..61499eecfd 100644 --- a/app/services/facilities_management/rm3830/admin/supplier_framework_data_spreadsheet.rb +++ b/app/services/facilities_management/rm3830/admin/supplier_framework_data_spreadsheet.rb @@ -57,7 +57,7 @@ def suppliers end def da_service_codes - @da_service_codes ||= Rate.all.where(direct_award: true).pluck(:code) + @da_service_codes ||= Rate.where(direct_award: true).pluck(:code) end def work_packages diff --git a/app/services/facilities_management/rm3830/spreadsheet_importer.rb b/app/services/facilities_management/rm3830/spreadsheet_importer.rb index b51f2dec78..424c9db3b2 100644 --- a/app/services/facilities_management/rm3830/spreadsheet_importer.rb +++ b/app/services/facilities_management/rm3830/spreadsheet_importer.rb @@ -479,7 +479,7 @@ def save_spreadsheet_data end def delete_existing_procurement_buildings_and_services - @procurement.procurement_buildings.where.not(id: nil).each(&:destroy) + @procurement.procurement_buildings.where.not(id: nil).find_each(&:destroy) end def save_building(building_hash) diff --git a/app/services/static_data_loader.rb b/app/services/static_data_loader.rb index f2ba6c36b8..227b6b75a0 100644 --- a/app/services/static_data_loader.rb +++ b/app/services/static_data_loader.rb @@ -16,7 +16,7 @@ def self.load_static_data(static_data_class) query = @queries[class_name.to_sym] static_data_class.load_db(query) rescue StandardError - call_rake static_data_class, class_name, query if static_data_class.all.count.zero? + call_rake static_data_class, class_name, query if static_data_class.count.zero? end end diff --git a/db/migrate/20190820101225_add_buildingid_to_facilities_management_buildings.rb b/db/migrate/20190820101225_add_buildingid_to_facilities_management_buildings.rb index 2cc0dc9b92..5db18eee1d 100644 --- a/db/migrate/20190820101225_add_buildingid_to_facilities_management_buildings.rb +++ b/db/migrate/20190820101225_add_buildingid_to_facilities_management_buildings.rb @@ -1,6 +1,8 @@ class AddBuildingidToFacilitiesManagementBuildings < ActiveRecord::Migration[5.2] + # rubocop:disable Rails/DangerousColumnNames def change add_column :facilities_management_buildings, :id, :uuid add_index :facilities_management_buildings, :id, unique: true end + # rubocop:enable Rails/DangerousColumnNames end diff --git a/db/migrate/20191031153244_change_procurement_building_service_primary_key.rb b/db/migrate/20191031153244_change_procurement_building_service_primary_key.rb index a2bded81ec..f0e37f0a8d 100644 --- a/db/migrate/20191031153244_change_procurement_building_service_primary_key.rb +++ b/db/migrate/20191031153244_change_procurement_building_service_primary_key.rb @@ -1,4 +1,5 @@ class ChangeProcurementBuildingServicePrimaryKey < ActiveRecord::Migration[5.2] + # rubocop:disable Rails/DangerousColumnNames def up add_column :facilities_management_procurement_building_services, :uuid, :uuid, default: 'gen_random_uuid()', null: false @@ -9,4 +10,5 @@ def up execute 'ALTER TABLE facilities_management_procurement_building_services ADD PRIMARY KEY (id);' end + # rubocop:enable Rails/DangerousColumnNames end diff --git a/db/migrate/20200430131751_update_building_types_in_the_db.rb b/db/migrate/20200430131751_update_building_types_in_the_db.rb index 4d5741983f..77e0215aa2 100644 --- a/db/migrate/20200430131751_update_building_types_in_the_db.rb +++ b/db/migrate/20200430131751_update_building_types_in_the_db.rb @@ -1,6 +1,6 @@ class UpdateBuildingTypesInTheDb < ActiveRecord::Migration[5.2] def up - FacilitiesManagement::Building.all.each do |building| + FacilitiesManagement::Building.find_each do |building| updated_building_type = BUILDING_TYPE_KEY[building.building_type&.to_sym] building.building_type = updated_building_type unless updated_building_type.nil? building.building_json[:'building-type'] = updated_building_type unless updated_building_type.nil? diff --git a/db/migrate/20200807080425_convert_nil_supplier_data_to_empty_array.rb b/db/migrate/20200807080425_convert_nil_supplier_data_to_empty_array.rb index 1930fdab31..64c043d799 100644 --- a/db/migrate/20200807080425_convert_nil_supplier_data_to_empty_array.rb +++ b/db/migrate/20200807080425_convert_nil_supplier_data_to_empty_array.rb @@ -4,7 +4,7 @@ class FMSupplier < ApplicationRecord end def self.up - FMSupplier.all.each do |supplier| + FMSupplier.find_each do |supplier| supplier.data['lots'].each do |lot| lot['services'] = [] if lot['services'].nil? end diff --git a/db/migrate/20200908110404_set_governing_law.rb b/db/migrate/20200908110404_set_governing_law.rb index b4feb765b4..e33c0b0384 100644 --- a/db/migrate/20200908110404_set_governing_law.rb +++ b/db/migrate/20200908110404_set_governing_law.rb @@ -2,11 +2,11 @@ class SetGoverningLaw < ActiveRecord::Migration[5.2] DEFAULT_LAW = 'english'.freeze def up - FacilitiesManagement::Procurement.direct_award.where(governing_law: nil).each do |procurement| + FacilitiesManagement::Procurement.direct_award.where(governing_law: nil).find_each do |procurement| procurement.update(governing_law: DEFAULT_LAW) end - FacilitiesManagement::Procurement.da_draft.where(governing_law: nil).each do |procurement| + FacilitiesManagement::Procurement.da_draft.where(governing_law: nil).find_each do |procurement| procurement.update(governing_law: DEFAULT_LAW) if %w[review_and_generate review sending sent].include?(procurement.da_journey_state) end end diff --git a/db/migrate/20201102142511_migrate_data_from_json_to_columns.rb b/db/migrate/20201102142511_migrate_data_from_json_to_columns.rb index 4c3732b9ee..6ba75eb85b 100644 --- a/db/migrate/20201102142511_migrate_data_from_json_to_columns.rb +++ b/db/migrate/20201102142511_migrate_data_from_json_to_columns.rb @@ -5,7 +5,7 @@ class FMSupplier < ApplicationRecord # rubocop:disable Metrics/AbcSize def up - FMSupplier.all.each do |supplier| + FMSupplier.find_each do |supplier| data = supplier.data supplier.contact_name = data['contact_name'] supplier.contact_email = data['contact_email'] @@ -29,7 +29,7 @@ def down add_index :fm_suppliers, ['data'], name: 'idxgin', using: :gin add_index :fm_suppliers, ['data'], name: 'idxginp', opclass: :jsonb_path_ops, using: :gin - FMSupplier.all.each do |supplier| + FMSupplier.find_each do |supplier| data = {} data['supplier_id'] = supplier.supplier_id data['contact_name'] = supplier.contact_name diff --git a/db/migrate/20201210141943_add_data_to_fm_suppliers.rb b/db/migrate/20201210141943_add_data_to_fm_suppliers.rb index 1d73e6592e..3d219de0f2 100644 --- a/db/migrate/20201210141943_add_data_to_fm_suppliers.rb +++ b/db/migrate/20201210141943_add_data_to_fm_suppliers.rb @@ -11,7 +11,7 @@ def up SupplierDetail.reset_column_information FMSupplier.reset_column_information - SupplierDetail.all.each do |supplier_detail| + SupplierDetail.find_each do |supplier_detail| contact_email = supplier_detail.contact_email fm_supplier = FMSupplier.find_by(contact_email:) next if fm_supplier.blank? diff --git a/db/migrate/20210113092431_link_user_accounts_to_supplier_details.rb b/db/migrate/20210113092431_link_user_accounts_to_supplier_details.rb index 2e485b83cf..09d059342e 100644 --- a/db/migrate/20210113092431_link_user_accounts_to_supplier_details.rb +++ b/db/migrate/20210113092431_link_user_accounts_to_supplier_details.rb @@ -10,7 +10,7 @@ class SupplierUser < ApplicationRecord def up SupplierDetail.reset_column_information - SupplierDetail.all.each do |supplier_detail| + SupplierDetail.find_each do |supplier_detail| next if supplier_detail.user_id.present? contact_email = supplier_detail.contact_email diff --git a/db/migrate/20210716112653_rename_unit_of_measure_table.rb b/db/migrate/20210716112653_rename_unit_of_measure_table.rb index 5f5b0f4cbe..1e268a1ba1 100644 --- a/db/migrate/20210716112653_rename_unit_of_measure_table.rb +++ b/db/migrate/20210716112653_rename_unit_of_measure_table.rb @@ -23,7 +23,7 @@ def up OldUnitOfMeasurement.reset_column_information NewUnitOfMeasurement.reset_column_information - OldUnitOfMeasurement.all.each do |row| + OldUnitOfMeasurement.find_each do |row| NewUnitOfMeasurement.create(row.attributes) end @@ -47,7 +47,7 @@ def down OldUnitOfMeasurement.reset_column_information NewUnitOfMeasurement.reset_column_information - NewUnitOfMeasurement.all.each do |row| + NewUnitOfMeasurement.find_each do |row| OldUnitOfMeasurement.create(row.attributes) end diff --git a/features/step_definitions/facilities_management/rm6232/admin_steps.rb b/features/step_definitions/facilities_management/rm6232/admin_steps.rb index 03429d19ff..3f475a4241 100644 --- a/features/step_definitions/facilities_management/rm6232/admin_steps.rb +++ b/features/step_definitions/facilities_management/rm6232/admin_steps.rb @@ -43,7 +43,9 @@ end Then('I deselect all checkboxes') do + # rubocop:disable Rails/FindEach admin_page.all('input[type="checkbox"][checked="checked"]').each(&:uncheck) + # rubocop:enable Rails/FindEach end Then('I select {string} for the lot status') do |option| diff --git a/lib/tasks/facilities_management/rm3830/procurements.rake b/lib/tasks/facilities_management/rm3830/procurements.rake index f950283391..3c12938c9e 100644 --- a/lib/tasks/facilities_management/rm3830/procurements.rake +++ b/lib/tasks/facilities_management/rm3830/procurements.rake @@ -6,7 +6,7 @@ namespace :procurements do FacilitiesManagement::RM3830::Procurement .includes(:procurement_suppliers) - .where(aasm_state: %w[results da_draft direct_award further_competition closed]).each do |procurement| + .where(aasm_state: %w[results da_draft direct_award further_competition closed]).find_each do |procurement| if procurement.procurement_suppliers.none? puts "Deleting procurement with ID #{procurement.id}" procurement.destroy diff --git a/spec/controllers/facilities_management/rm3830/procurements_controller_spec.rb b/spec/controllers/facilities_management/rm3830/procurements_controller_spec.rb index 9a4b5543d8..391016db7f 100644 --- a/spec/controllers/facilities_management/rm3830/procurements_controller_spec.rb +++ b/spec/controllers/facilities_management/rm3830/procurements_controller_spec.rb @@ -257,7 +257,7 @@ context 'when Save and continue is selected with no region codes' do it 'redirects to facilities_management_rm3830_procurement_path for the new record' do post :create, params: { facilities_management_rm3830_procurement: { contract_name: 'New procurement' } } - new_procurement = FacilitiesManagement::RM3830::Procurement.all.order(created_at: :asc).first + new_procurement = FacilitiesManagement::RM3830::Procurement.order(created_at: :asc).first expect(response).to redirect_to facilities_management_rm3830_procurement_path(new_procurement.id) end end @@ -265,7 +265,7 @@ context 'when Save and continue is selected with region codes' do it 'redirects to facilities_management_rm3830_procurement_path for the new record' do post :create, params: { facilities_management_rm3830_procurement: { contract_name: 'New procurement', region_codes: %w[UKC1 UKC2] } } - new_procurement = FacilitiesManagement::RM3830::Procurement.all.order(created_at: :asc).first + new_procurement = FacilitiesManagement::RM3830::Procurement.order(created_at: :asc).first expect(response).to redirect_to facilities_management_rm3830_procurement_path(new_procurement.id, what_happens_next: true) end end diff --git a/spec/models/facilities_management/rm3830/rate_spec.rb b/spec/models/facilities_management/rm3830/rate_spec.rb index e68dde5ebc..02fbb7a752 100644 --- a/spec/models/facilities_management/rm3830/rate_spec.rb +++ b/spec/models/facilities_management/rm3830/rate_spec.rb @@ -4,7 +4,7 @@ it 'contains data' do benchmark_rates = {} framework_rates = {} - described_class.all.each do |row| + described_class.find_each do |row| code = row['code'].remove('.') benchmark_rates[code] = row['benchmark'].to_f framework_rates[code] = row['framework'].to_f diff --git a/spec/models/static_record_spec.rb b/spec/models/static_record_spec.rb index 64d4fefb6c..406cbbc158 100644 --- a/spec/models/static_record_spec.rb +++ b/spec/models/static_record_spec.rb @@ -65,7 +65,7 @@ end it 'freezes individual records' do - expect { klass.all.first.name = 'NEW' } + expect { klass.first.name = 'NEW' } .to raise_exception(FrozenError) end diff --git a/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_0_spec.rb b/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_0_spec.rb index 8da3b4f743..56f892e30a 100644 --- a/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_0_spec.rb +++ b/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_0_spec.rb @@ -73,10 +73,10 @@ before do create(:facilities_management_rm3830_procurement_building_av_normal_building, procurement:, service_codes:) create(:facilities_management_rm3830_procurement_building_av_london_building, procurement:, service_codes:) - procurement.procurement_building_services.where(code: %w[C.2 C.5 G.1]).each { |pbs| pbs.update(service_standard: 'A') } - procurement.procurement_building_services.where(code: 'G.1').each { |pbs| pbs.update(no_of_building_occupants: volume) } - procurement.procurement_building_services.where(code: 'E.4').each { |pbs| pbs.update(no_of_appliances_for_testing: volume) } - procurement.procurement_building_services.where(code: 'C.5').each { |pbs| no_of_lifts.times { pbs.lifts.create(number_of_floors:) } } + procurement.procurement_building_services.where(code: %w[C.2 C.5 G.1]).find_each { |pbs| pbs.update(service_standard: 'A') } + procurement.procurement_building_services.where(code: 'G.1').find_each { |pbs| pbs.update(no_of_building_occupants: volume) } + procurement.procurement_building_services.where(code: 'E.4').find_each { |pbs| pbs.update(no_of_appliances_for_testing: volume) } + procurement.procurement_building_services.where(code: 'C.5').find_each { |pbs| no_of_lifts.times { pbs.lifts.create(number_of_floors:) } } end context 'and the lot is 1a' do diff --git a/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_1a_spec.rb b/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_1a_spec.rb index 49bb095c7b..46f4a4b494 100644 --- a/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_1a_spec.rb +++ b/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_1a_spec.rb @@ -253,11 +253,11 @@ before do create(:facilities_management_rm3830_procurement_building_av_normal_building, procurement:, service_codes:) create(:facilities_management_rm3830_procurement_building_av_london_building, procurement:, service_codes:) - procurement.procurement_building_services.where(code: 'C.1').each { |pbs| pbs.update(service_standard: 'A') } - procurement.procurement_building_services.where(code: 'G.1').each { |pbs| pbs.update(service_standard: 'A', no_of_building_occupants: 88000) } - procurement.procurement_building_services.where(code: 'I.1').each { |pbs| pbs.update(service_hours: 8736) } - procurement.procurement_building_services.where(code: 'K.2').each { |pbs| pbs.update(tones_to_be_collected_and_removed: 13000) } - procurement.procurement_building_services.where(code: 'H.4').each { |pbs| pbs.update(service_hours: 8736) } + procurement.procurement_building_services.where(code: 'C.1').find_each { |pbs| pbs.update(service_standard: 'A') } + procurement.procurement_building_services.where(code: 'G.1').find_each { |pbs| pbs.update(service_standard: 'A', no_of_building_occupants: 88000) } + procurement.procurement_building_services.where(code: 'I.1').find_each { |pbs| pbs.update(service_hours: 8736) } + procurement.procurement_building_services.where(code: 'K.2').find_each { |pbs| pbs.update(tones_to_be_collected_and_removed: 13000) } + procurement.procurement_building_services.where(code: 'H.4').find_each { |pbs| pbs.update(service_hours: 8736) } end context 'and the variance is just below -30%' do diff --git a/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_1b_spec.rb b/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_1b_spec.rb index dbc2f77a88..f2ced5ee98 100644 --- a/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_1b_spec.rb +++ b/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_1b_spec.rb @@ -156,10 +156,10 @@ before do create(:facilities_management_rm3830_procurement_building_av_normal_building, procurement:, service_codes:) create(:facilities_management_rm3830_procurement_building_av_london_building, procurement:, service_codes:) - procurement.procurement_building_services.where(code: 'C.1').each { |pbs| pbs.update(service_standard: 'A') } - procurement.procurement_building_services.where(code: 'G.1').each { |pbs| pbs.update(service_standard: 'A', no_of_building_occupants: 3400) } - procurement.procurement_building_services.where(code: 'I.1').each { |pbs| pbs.update(service_hours: 6240) } - procurement.procurement_building_services.where(code: 'K.2').each { |pbs| pbs.update(tones_to_be_collected_and_removed: 13000) } + procurement.procurement_building_services.where(code: 'C.1').find_each { |pbs| pbs.update(service_standard: 'A') } + procurement.procurement_building_services.where(code: 'G.1').find_each { |pbs| pbs.update(service_standard: 'A', no_of_building_occupants: 3400) } + procurement.procurement_building_services.where(code: 'I.1').find_each { |pbs| pbs.update(service_hours: 6240) } + procurement.procurement_building_services.where(code: 'K.2').find_each { |pbs| pbs.update(tones_to_be_collected_and_removed: 13000) } end context 'and the variance is just below -30%' do diff --git a/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_4_spec.rb b/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_4_spec.rb index 2ba50acf55..dfa4e0e9ad 100644 --- a/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_4_spec.rb +++ b/spec/services/facilities_management/rm3830/assessed_value_calculator_scenario_4_spec.rb @@ -112,10 +112,10 @@ before do create(:facilities_management_rm3830_procurement_building_av_normal_building, procurement:, service_codes:) create(:facilities_management_rm3830_procurement_building_av_london_building, procurement:, service_codes:) - procurement.procurement_building_services.where(code: %w[C.1 C.2 C.3]).each { |pbs| pbs.update(service_standard: 'A') } - procurement.procurement_building_services.where(code: 'G.1').each { |pbs| pbs.update(service_standard: 'A', no_of_building_occupants: no_of_building_occupants) } - procurement.procurement_building_services.where(code: 'I.1').each { |pbs| pbs.update(service_hours: 6240) } - procurement.procurement_building_services.where(code: %w[K.2 K.3]).each { |pbs| pbs.update(tones_to_be_collected_and_removed:) } + procurement.procurement_building_services.where(code: %w[C.1 C.2 C.3]).find_each { |pbs| pbs.update(service_standard: 'A') } + procurement.procurement_building_services.where(code: 'G.1').find_each { |pbs| pbs.update(service_standard: 'A', no_of_building_occupants: no_of_building_occupants) } + procurement.procurement_building_services.where(code: 'I.1').find_each { |pbs| pbs.update(service_hours: 6240) } + procurement.procurement_building_services.where(code: %w[K.2 K.3]).find_each { |pbs| pbs.update(tones_to_be_collected_and_removed:) } end context 'and the variance is just below 30%' do diff --git a/spec/services/static_data_loader_spec.rb b/spec/services/static_data_loader_spec.rb index 77a02f0cdc..393f4783a8 100644 --- a/spec/services/static_data_loader_spec.rb +++ b/spec/services/static_data_loader_spec.rb @@ -4,21 +4,21 @@ describe '.nuts1_codes_not_empty' do it 'there is at least one Nuts1 Region' do described_class.load_static_data(Nuts1Region) - expect(Nuts1Region.all.count.zero?).to be(false) + expect(Nuts1Region.count.zero?).to be(false) end end describe '.nuts2_codes_not_empty' do it 'there is at least 1 Nuts2 Regions' do described_class.load_static_data(Nuts2Region) - expect(Nuts2Region.all.count.zero?).to be(false) + expect(Nuts2Region.count.zero?).to be(false) end end describe '.nuts3_codes_not_empty' do it 'there is at least 1 Nuts3 Region' do described_class.load_static_data(Nuts3Region) - expect(Nuts3Region.all.count.zero?).to be(false) + expect(Nuts3Region.count.zero?).to be(false) end end end diff --git a/spec/support/facilities_management/admin/supplier_framework_data_helper.rb b/spec/support/facilities_management/admin/supplier_framework_data_helper.rb index e6fd99917a..d802f8825d 100644 --- a/spec/support/facilities_management/admin/supplier_framework_data_helper.rb +++ b/spec/support/facilities_management/admin/supplier_framework_data_helper.rb @@ -153,7 +153,7 @@ def add_other_sheet(sheet_name) end def da_service_codes - @da_service_codes ||= FacilitiesManagement::RM3830::Rate.all.where(direct_award: true).pluck(:code) + @da_service_codes ||= FacilitiesManagement::RM3830::Rate.where(direct_award: true).pluck(:code) end def work_packages