diff --git a/config/environments/development.rb b/config/environments/development.rb
index 7e1890b02..f75643524 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -81,6 +81,8 @@ Rails.application.configure do
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
+ Faker::Config.locale = "en-GB"
+
# see https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
config.active_record.yaml_column_permitted_classes = [Time, BigDecimal]
diff --git a/config/environments/review.rb b/config/environments/review.rb
index f7438fdb6..471879b27 100644
--- a/config/environments/review.rb
+++ b/config/environments/review.rb
@@ -125,6 +125,8 @@ Rails.application.configure do
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
+ Faker::Config.locale = "en-GB"
+
# see https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
config.active_record.yaml_column_permitted_classes = [Time, BigDecimal]
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 9654b2b78..2f018be91 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,436 +1,175 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
-#
-# Examples:
-#
-# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
-# Character.create(name: 'Luke', movie: movies.first)
-# rubocop:disable Rails/Output
-def create_data_protection_confirmation(user)
- DataProtectionConfirmation.find_or_create_by!(
- organisation: user.organisation,
- confirmed: true,
- data_protection_officer: user,
- signed_at: Time.zone.local(2019, 1, 1),
- data_protection_officer_email: user.email,
- data_protection_officer_name: user.name,
- organisation_name: user.organisation.name,
- organisation_address: user.organisation.address_row,
- )
+def find_or_create_user(organisation, email, name, role)
+ case role
+ when :data_provider
+ FactoryBot.create(:user, :if_unique, :data_provider, organisation:, email:, name:, password: ENV["REVIEW_APP_USER_PASSWORD"])
+ when :data_coordinator
+ FactoryBot.create(:user, :if_unique, :data_coordinator, organisation:, email:, name:, password: ENV["REVIEW_APP_USER_PASSWORD"])
+ when :support
+ FactoryBot.create(:user, :if_unique, :support, organisation:, email:, name:, password: ENV["REVIEW_APP_USER_PASSWORD"])
+ end
end
unless Rails.env.test?
- stock_owner1 = Organisation.find_or_create_by!(
- name: "Stock Owner 1",
- address_line1: "2 Marsham Street",
- address_line2: "London",
- postcode: "SW1P 4DF",
- holds_own_stock: true,
- other_stock_owners: "None",
- managing_agents_label: "None",
- provider_type: "LA",
- )
- stock_owner2 = Organisation.find_or_create_by!(
- name: "Stock Owner 2",
- address_line1: "2 Marsham Street",
- address_line2: "London",
- postcode: "SW1P 4DF",
- holds_own_stock: true,
- other_stock_owners: "None",
- managing_agents_label: "None",
- provider_type: "LA",
- )
- managing_agent1 = Organisation.find_or_create_by!(
- name: "Managing Agent 1 (PRP)",
- address_line1: "2 Marsham Street",
- address_line2: "London",
- postcode: "SW1P 4DF",
- holds_own_stock: true,
- other_stock_owners: "None",
- managing_agents_label: "None",
- provider_type: "PRP",
- )
- managing_agent2 = Organisation.find_or_create_by!(
- name: "Managing Agent 2",
- address_line1: "2 Marsham Street",
- address_line2: "London",
- postcode: "SW1P 4DF",
- holds_own_stock: true,
- other_stock_owners: "None",
- managing_agents_label: "None",
- provider_type: "LA",
- )
+ if LocalAuthority.count.zero?
+ la_path = "config/local_authorities_data/initial_local_authorities.csv"
+ service = Imports::LocalAuthoritiesService.new(path: la_path)
+ service.call
+ end
- org = Organisation.find_or_create_by!(
- name: "MHCLG",
- address_line1: "2 Marsham Street",
- address_line2: "London",
- postcode: "SW1P 4DF",
- holds_own_stock: true,
- other_stock_owners: "None",
- managing_agents_label: "None",
- provider_type: "LA",
- ) do
- info = "Seeded MHCLG Organisation"
- if Rails.env.development?
- pp info
- else
- Rails.logger.info info
+ if LaRentRange.count.zero?
+ Dir.glob("config/rent_range_data/*.csv").each do |path|
+ start_year = File.basename(path, ".csv")
+ service = Imports::RentRangesService.new(start_year:, path:)
+ service.call
end
end
- standalone_owns_stock = Organisation.find_or_create_by!(
- name: "Standalone Owns Stock 1 Ltd",
- address_line1: "2 Marsham Street",
- address_line2: "London",
- postcode: "SW1P 4DF",
- holds_own_stock: true,
- other_stock_owners: "None",
- managing_agents_label: "None",
- provider_type: "LA",
- )
+ if LaSaleRange.count.zero?
+ Dir.glob("config/sale_range_data/*.csv").each do |path|
+ start_year = File.basename(path, ".csv")
+ service = Imports::SaleRangesService.new(start_year:, path:)
+ service.call
+ end
+ end
+
+ first_run = Organisation.count.zero?
+
+ all_rent_periods = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
- standalone_no_stock = Organisation.find_or_create_by!(
- name: "Standalone No Stock 1 Ltd",
+ mhclg = FactoryBot.create(
+ :organisation,
+ :if_unique,
+ name: "MHCLG",
address_line1: "2 Marsham Street",
address_line2: "London",
postcode: "SW1P 4DF",
- holds_own_stock: false,
+ holds_own_stock: true,
other_stock_owners: "None",
managing_agents_label: "None",
provider_type: "LA",
- )
-
- User.find_or_create_by!(
- name: "Provider Owns Stock",
- email: "provider.owner1@example.com",
- organisation: standalone_owns_stock,
- role: "data_provider",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
- end
-
- User.find_or_create_by!(
- name: "Coordinator Owns Stock",
- email: "coordinator.owner1@example.com",
- organisation: standalone_owns_stock,
- role: "data_coordinator",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
- end
-
- User.find_or_create_by!(
- name: "Provider No Stock",
- email: "provider.nostock@example.com",
- organisation: standalone_no_stock,
- role: "data_provider",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
- end
-
- User.find_or_create_by!(
- name: "Coordinator No Stock",
- email: "coordinator.nostock@example.com",
- organisation: standalone_no_stock,
- role: "data_coordinator",
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- end
-
- User.find_or_create_by!(
- name: "Stock owner 1",
- email: "stock_owner1_dpo@example.com",
- organisation: stock_owner1,
- role: "data_coordinator",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
- end
-
- User.find_or_create_by!(
- name: "Stock owner 2",
- email: "stock_owner2_dpo@example.com",
- organisation: stock_owner2,
- role: "data_coordinator",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
- end
-
- User.find_or_create_by!(
- name: "Managing agent 1",
- email: "managing_agent1_dpo@example.com",
- organisation: managing_agent1,
- role: "data_coordinator",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
- end
-
- User.find_or_create_by!(
- name: "Managing agent 2",
- email: "managing_agent2_dpo@example.com",
- organisation: managing_agent2,
- role: "data_coordinator",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
- end
-
- OrganisationRelationship.find_or_create_by!(
- parent_organisation: stock_owner1,
- child_organisation: org,
- )
- OrganisationRelationship.find_or_create_by!(
- parent_organisation: stock_owner2,
- child_organisation: org,
- )
- OrganisationRelationship.find_or_create_by!(
- parent_organisation: org,
- child_organisation: managing_agent1,
- )
- OrganisationRelationship.find_or_create_by!(
- parent_organisation: org,
- child_organisation: managing_agent2,
+ housing_registration_no: nil,
+ rent_periods: all_rent_periods,
)
if Rails.env.development? || Rails.env.review?
- User.find_or_create_by!(
- name: "Provider",
- email: "provider@example.com",
- organisation: org,
- role: "data_provider",
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- end
+ stock_owner1 = FactoryBot.create(:organisation, :if_unique, :la, :holds_own_stock, name: "Stock Owner 1", rent_periods: all_rent_periods)
+ stock_owner2 = FactoryBot.create(:organisation, :if_unique, :la, :holds_own_stock, name: "Stock Owner 2", rent_periods: all_rent_periods.sample(5))
+ managing_agent1 = FactoryBot.create(:organisation, :if_unique, :prp, :holds_own_stock, name: "Managing Agent 1 (PRP)", rent_periods: all_rent_periods)
+ managing_agent2 = FactoryBot.create(:organisation, :if_unique, :la, :holds_own_stock, name: "Managing Agent 2", rent_periods: all_rent_periods.sample(5))
+ standalone_owns_stock = FactoryBot.create(:organisation, :if_unique, :la, :holds_own_stock, name: "Standalone Owns Stock 1 Ltd", rent_periods: all_rent_periods)
+ standalone_no_stock = FactoryBot.create(:organisation, :if_unique, :la, :does_not_own_stock, name: "Standalone No Stock 1 Ltd", rent_periods: all_rent_periods)
+
+ other_orgs = FactoryBot.create_list(:organisation, 5, :prp, rent_periods: all_rent_periods.sample(3)) if first_run
+
+ OrganisationRelationship.find_or_create_by!(
+ parent_organisation: stock_owner1,
+ child_organisation: mhclg,
+ )
+ OrganisationRelationship.find_or_create_by!(
+ parent_organisation: stock_owner2,
+ child_organisation: mhclg,
+ )
+ OrganisationRelationship.find_or_create_by!(
+ parent_organisation: mhclg,
+ child_organisation: managing_agent1,
+ )
+ OrganisationRelationship.find_or_create_by!(
+ parent_organisation: mhclg,
+ child_organisation: managing_agent2,
+ )
- User.find_or_create_by!(
- name: "Coordinator",
- email: "coordinator@example.com",
- organisation: org,
- role: "data_coordinator",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- user.is_dpo = true
- create_data_protection_confirmation(user)
- end
+ provider = find_or_create_user(mhclg, "provider@example.com", "Provider", :data_provider)
+ coordinator = find_or_create_user(mhclg, "coordinator@example.com", "Coordinator", :data_coordinator)
+ support = find_or_create_user(mhclg, "support@example.com", "Support", :support)
- support_user = User.find_or_create_by!(
- name: "Support",
- email: "support@example.com",
- organisation: org,
- role: "support",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
- end
+ stock_owner1_user = find_or_create_user(stock_owner1, "stock_owner1_dpo@example.com", "Stock owner 1", :data_coordinator)
+ stock_owner2_user = find_or_create_user(stock_owner2, "stock_owner2_dpo@example.com", "Stock owner 2", :data_coordinator)
- pp "Seeded dummy users"
- end
+ managing_agent1_user = find_or_create_user(managing_agent1, "managing_agent1_dpo@example.com", "Managing agent 1", :data_coordinator)
+ managing_agent2_user = find_or_create_user(managing_agent2, "managing_agent2_dpo@example.com", "Managing agent 2", :data_coordinator)
- if (Rails.env.development? || Rails.env.review?) && SalesLog.count.zero?
- SalesLog.find_or_create_by!(
- assigned_to: support_user,
- owning_organisation: org,
- managing_organisation: org,
- saledate: Time.zone.today,
- purchid: "1",
- ownershipsch: 1,
- type: 2,
- jointpur: 1,
- jointmore: 1,
- )
+ provider_owner1 = find_or_create_user(standalone_owns_stock, "provider.owner1@example.com", "Provider Owns Stock", :data_provider)
+ coordinator_owner1 = find_or_create_user(standalone_owns_stock, "coordinator.owner1@example.com", "Coordinator Owns Stock", :data_coordinator)
- SalesLog.find_or_create_by!(
- assigned_to: support_user,
- owning_organisation: org,
- managing_organisation: org,
- saledate: Time.zone.today,
- purchid: "1",
- ownershipsch: 2,
- type: 9,
- jointpur: 1,
- jointmore: 1,
- )
+ find_or_create_user(standalone_no_stock, "provider.nostock@example.com", "Provider No Stock", :data_provider)
+ find_or_create_user(standalone_no_stock, "coordinator.nostock@example.com", "Coordinator No Stock", :data_coordinator)
- SalesLog.find_or_create_by!(
- assigned_to: support_user,
- owning_organisation: org,
- managing_organisation: org,
- saledate: Time.zone.today,
- purchid: "1",
- ownershipsch: 3,
- type: 10,
- companybuy: 1,
- )
+ if Scheme.count.zero?
+ beulahside = FactoryBot.create(:scheme, service_name: "Beulahside Care", owning_organisation: mhclg)
+ abdullah = FactoryBot.create(:scheme, service_name: "Abdullahview Point", owning_organisation: mhclg)
- pp "Seeded a sales log of each type"
- end
+ FactoryBot.create(:location, scheme: beulahside, name: "Rectory Road", postcode: "CU193AA", location_code: "E09000033", location_admin_district: "Westminster", type_of_unit: 4, mobility_type: "N")
+ FactoryBot.create(:location, scheme: beulahside, name: "Smithy Lane", postcode: "DM25ODC", location_code: "E09000033", location_admin_district: "Westminster", type_of_unit: 1, mobility_type: "W")
+ FactoryBot.create(:location, scheme: abdullah, name: "Smithy Lane", postcode: "YX130WP", location_code: "E09000033", location_admin_district: "Westminster", type_of_unit: 2, mobility_type: "W")
- if Rails.env.development? || Rails.env.review?
- dummy_org = Organisation.find_or_create_by!(
- name: "FooBar LTD",
- address_line1: "Higher Kingston",
- address_line2: "Yeovil",
- postcode: "BA21 4AT",
- holds_own_stock: true,
- other_stock_owners: "None",
- managing_agents_label: "None",
- provider_type: "LA",
- )
+ mhclg_scheme = FactoryBot.create(:scheme, :created_now, owning_organisation: mhclg)
+ stock_owner_scheme = FactoryBot.create(:scheme, owning_organisation: stock_owner1)
- pp "Seeded dummy FooBar LTD organisation"
+ other_schemes = first_run ? other_orgs.sample(3).map { |org| FactoryBot.create(:scheme, owning_organisation: org) } : []
- User.find_or_create_by!(
- name: "Dummy user",
- email: "dummy_org@example.com",
- organisation: dummy_org,
- role: "data_provider",
- is_dpo: true,
- ) do |user|
- user.password = ENV["REVIEW_APP_USER_PASSWORD"]
- user.confirmed_at = Time.zone.now
- create_data_protection_confirmation(user)
+ [mhclg_scheme, stock_owner_scheme, *other_schemes].each do |scheme|
+ FactoryBot.create(:location, scheme:)
+ end
+ [beulahside, mhclg_scheme, *other_schemes].each do |scheme|
+ FactoryBot.create_list(:location, 3, scheme:)
+ end
end
- end
- if (Rails.env.development? || Rails.env.review?) && Scheme.count.zero?
- scheme1 = Scheme.create!(
- service_name: "Beulahside Care",
- sensitive: 0,
- registered_under_care_act: 1,
- support_type: 2,
- scheme_type: 4,
- intended_stay: "M",
- primary_client_group: "O",
- has_other_client_group: 1,
- secondary_client_group: "H",
- owning_organisation: org,
- arrangement_type: "D",
- confirmed: true,
- created_at: Time.zone.now,
- )
+ other_org_users = first_run ? other_orgs.map { |org| org.users.first } : []
+ users_with_logs = [provider, coordinator, support, stock_owner1_user, stock_owner2_user, managing_agent1_user, managing_agent2_user, provider_owner1, coordinator_owner1, *other_org_users]
- scheme2 = Scheme.create!(
- service_name: "Abdullahview Point",
- sensitive: 0,
- registered_under_care_act: 1,
- support_type: 2,
- scheme_type: 5,
- intended_stay: "S",
- primary_client_group: "D",
- secondary_client_group: "E",
- has_other_client_group: 1,
- owning_organisation: org,
- arrangement_type: "D",
- confirmed: true,
- created_at: Time.zone.now,
- )
+ if SalesLog.count.zero?
+ users_with_logs.each do |user|
+ FactoryBot.create(:sales_log, :shared_ownership_setup_complete, assigned_to: user)
+ FactoryBot.create(:sales_log, :discounted_ownership_setup_complete, assigned_to: user)
+ FactoryBot.create(:sales_log, :outright_sale_setup_complete, assigned_to: user) if Time.zone.today < Time.zone.local(2025, 4, 1)
+ FactoryBot.create(:sales_log, :completed, assigned_to: user)
+ FactoryBot.create_list(:sales_log, 2, :completed, :ignore_validation_errors, saledate: Time.zone.today - 1.year, assigned_to: user)
- Scheme.create!(
- service_name: "Caspermouth Center",
- sensitive: 1,
- registered_under_care_act: 1,
- support_type: 4,
- scheme_type: 7,
- intended_stay: "X",
- primary_client_group: "G",
- has_other_client_group: 1,
- secondary_client_group: "R",
- owning_organisation: dummy_org,
- arrangement_type: "D",
- confirmed: true,
- created_at: Time.zone.now,
- )
+ next unless FeatureToggle.allow_future_form_use?
- Location.create!(
- scheme: scheme1,
- location_code: "E09000033",
- location_admin_district: "Westminster",
- postcode: "CU193AA",
- name: "Rectory Road",
- type_of_unit: 4,
- units: 1,
- mobility_type: "N",
- )
+ FactoryBot.create(:sales_log, :shared_ownership_setup_complete, saledate: Time.zone.today + 1.year, assigned_to: user)
+ FactoryBot.create(:sales_log, :discounted_ownership_setup_complete, saledate: Time.zone.today + 1.year, assigned_to: user)
+ FactoryBot.create(:sales_log, :completed, saledate: Time.zone.today + 1.year, assigned_to: user)
+ end
- Location.create!(
- scheme: scheme1,
- location_code: "E09000033",
- location_admin_district: "Westminster",
- postcode: "DM250DC",
- name: "Smithy Lane",
- type_of_unit: 1,
- units: 1,
- mobility_type: "W",
- )
-
- Location.create!(
- scheme: scheme2,
- location_code: "E09000033",
- location_admin_district: "Westminster",
- postcode: "YX130WP",
- name: "Smithy Lane",
- type_of_unit: 2,
- units: 1,
- mobility_type: "W",
- )
- pp "Seeded dummy schemes"
- end
-
- if LocalAuthority.count.zero?
- la_path = "config/local_authorities_data/initial_local_authorities.csv"
- service = Imports::LocalAuthoritiesService.new(path: la_path)
- service.call
- end
-
- if (Rails.env.development? || Rails.env.review?) && LocalAuthorityLink.count.zero?
- links_data_paths = ["config/local_authorities_data/local_authority_links_2023.csv", "config/local_authorities_data/local_authority_links_2022.csv"]
- links_data_paths.each do |path|
- service = Imports::LocalAuthorityLinksService.new(path:)
- service.call
+ FactoryBot.create(:sales_log, :completed, assigned_to: managing_agent1_user, owning_organisation: mhclg)
+ FactoryBot.create(:sales_log, :completed, assigned_to: provider, owning_organisation: stock_owner1)
end
- pp "Seeded local authority links"
- end
-
- if LaRentRange.count.zero?
- Dir.glob("config/rent_range_data/*.csv").each do |path|
- start_year = File.basename(path, ".csv")
- service = Imports::RentRangesService.new(start_year:, path:)
- service.call
+ if LettingsLog.count.zero?
+ users_with_logs.each do |user|
+ FactoryBot.create(:lettings_log, :setup_completed, assigned_to: user)
+ FactoryBot.create(:lettings_log, :completed, assigned_to: user)
+ if user.organisation.owned_schemes.any?
+ scheme = user.organisation.owned_schemes.first
+ FactoryBot.create(:lettings_log, :setup_completed, :sh, scheme:, location: scheme.locations.first, assigned_to: user)
+ end
+ FactoryBot.create_list(:lettings_log, 2, :completed, :ignore_validation_errors, startdate: Time.zone.today - 1.year, assigned_to: user)
+
+ next unless FeatureToggle.allow_future_form_use?
+
+ FactoryBot.create(:lettings_log, :setup_completed, startdate: Time.zone.today + 1.year, assigned_to: user)
+ FactoryBot.create(:lettings_log, :completed, startdate: Time.zone.today + 1.year, assigned_to: user)
+ if user.organisation.owned_schemes.any?
+ scheme = user.organisation.owned_schemes.first
+ FactoryBot.create(:lettings_log, :setup_completed, :sh, scheme:, location: scheme.locations.first, startdate: Time.zone.today + 1.year, assigned_to: user)
+ end
+ end
+
+ FactoryBot.create(:lettings_log, :completed, assigned_to: managing_agent1_user, owning_organisation: mhclg)
+ FactoryBot.create(:lettings_log, :completed, assigned_to: provider, owning_organisation: stock_owner1)
end
- end
- if LaSaleRange.count.zero?
- Dir.glob("config/sale_range_data/*.csv").each do |path|
- start_year = File.basename(path, ".csv")
- service = Imports::SaleRangesService.new(start_year:, path:)
- service.call
+ if LocalAuthorityLink.count.zero?
+ links_data_paths = ["config/local_authorities_data/local_authority_links_2023.csv", "config/local_authorities_data/local_authority_links_2022.csv"]
+ links_data_paths.each do |path|
+ service = Imports::LocalAuthorityLinksService.new(path:)
+ service.call
+ end
end
end
end
@@ -440,4 +179,3 @@ if LocalAuthority.count.zero?
service = Imports::LocalAuthoritiesService.new(path:)
service.call
end
-# rubocop:enable Rails/Output
diff --git a/spec/components/check_answers_summary_list_card_component_spec.rb b/spec/components/check_answers_summary_list_card_component_spec.rb
index aa9ad1be5..c08fb3f42 100644
--- a/spec/components/check_answers_summary_list_card_component_spec.rb
+++ b/spec/components/check_answers_summary_list_card_component_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
let(:rendered) { render_inline(component) }
let(:user) { create(:user) }
- let(:log) { create(:lettings_log, :completed, age2: 99, retirement_value_check: 1) }
+ let(:log) { create(:lettings_log, :completed, sex1: "F", age2: 99, retirement_value_check: 1) }
let(:subsection_id) { "household_characteristics" }
let(:subsection) { log.form.get_subsection(subsection_id) }
let(:questions) { subsection.applicable_questions(log) }
diff --git a/spec/components/lettings_log_summary_component_spec.rb b/spec/components/lettings_log_summary_component_spec.rb
index 52b6b1955..78ce5d804 100644
--- a/spec/components/lettings_log_summary_component_spec.rb
+++ b/spec/components/lettings_log_summary_component_spec.rb
@@ -3,9 +3,11 @@ require "rails_helper"
RSpec.describe LettingsLogSummaryComponent, type: :component do
let(:support_user) { FactoryBot.create(:user, :support) }
let(:coordinator_user) { FactoryBot.create(:user) }
+ let(:organisation) { create(:organisation, name: "MHCLG") }
+ let(:log_user) { create(:user, name: "Danny Rojas", organisation:) }
let(:propcode) { "P3647" }
let(:tenancycode) { "T62863" }
- let(:lettings_log) { FactoryBot.create(:lettings_log, needstype: 1, tenancycode:, propcode:, startdate: Time.zone.today) }
+ let(:lettings_log) { FactoryBot.create(:lettings_log, assigned_to: log_user, needstype: 1, tenancycode:, propcode:, startdate: Time.zone.today) }
context "when rendering lettings log for a support user" do
it "shows the log summary with organisational relationships" do
diff --git a/spec/components/sales_log_summary_component_spec.rb b/spec/components/sales_log_summary_component_spec.rb
index ce9b3a45c..ec5c3cd80 100644
--- a/spec/components/sales_log_summary_component_spec.rb
+++ b/spec/components/sales_log_summary_component_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe SalesLogSummaryComponent, type: :component do
it "shows the log summary with organisational relationships" do
result = render_inline(described_class.new(current_user: support_user, log: sales_log))
- expect(result).to have_content("Owned by\n MHCLG")
+ expect(result).to have_content("Owned by\n #{sales_log.owning_organisation.name}")
expect(result).not_to have_content("Managed by")
end
end
diff --git a/spec/factories/lettings_log.rb b/spec/factories/lettings_log.rb
index 8ebe44875..c8c51ecf3 100644
--- a/spec/factories/lettings_log.rb
+++ b/spec/factories/lettings_log.rb
@@ -56,8 +56,8 @@ FactoryBot.define do
status { 2 }
tenancycode { Faker::Name.initials(number: 10) }
age1_known { 0 }
- age1 { 35 }
- sex1 { "F" }
+ age1 { Faker::Number.within(range: 25..45) }
+ sex1 { %w[F M X R].sample }
ethnic_group { 0 }
ethnic { 2 }
national { 13 }
@@ -67,8 +67,8 @@ FactoryBot.define do
relat2 { "P" }
age2_known { 0 }
details_known_2 { 0 }
- age2 { 32 }
- sex2 { "M" }
+ age2 { Faker::Number.within(range: 25..45) }
+ sex2 { %w[F M X R].sample }
ecstat2 { 6 }
homeless { 1 }
underoccupation_benefitcap { 0 }
@@ -163,7 +163,7 @@ FactoryBot.define do
uprn_known { 0 }
joint { 3 }
address_line1 { "Address line 1" }
- town_or_city { "London" }
+ town_or_city { Faker::Address.city }
ppcodenk { 1 }
tshortfall_known { 1 }
after(:build) do |log, _evaluator|
diff --git a/spec/factories/organisation.rb b/spec/factories/organisation.rb
index 6623ff355..ecab5bf81 100644
--- a/spec/factories/organisation.rb
+++ b/spec/factories/organisation.rb
@@ -1,11 +1,11 @@
FactoryBot.define do
factory :organisation do
- name { "MHCLG" }
- address_line1 { "2 Marsham Street" }
- address_line2 { "London" }
+ name { Faker::Company.name }
+ address_line1 { Faker::Address.street_address }
+ address_line2 { Faker::Address.city }
provider_type { "LA" }
- housing_registration_no { "1234" }
- postcode { "SW1P 4DF" }
+ housing_registration_no { rand(99_999).to_s }
+ postcode { Faker::Address.postcode }
created_at { Time.zone.now }
updated_at { Time.zone.now }
holds_own_stock { true }
@@ -41,7 +41,13 @@ FactoryBot.define do
trait :prp do
provider_type { "PRP" }
end
+ trait :la do
+ provider_type { "LA" }
+ end
+ trait :holds_own_stock do
+ holds_own_stock { true }
+ end
trait :does_not_own_stock do
holds_own_stock { false }
end
@@ -53,6 +59,10 @@ FactoryBot.define do
data_protection_confirmation { nil }
end
+
+ trait :if_unique do
+ initialize_with { Organisation.find_or_create_by(name:) }
+ end
end
factory :organisation_rent_period do
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index b809b9daf..687b042a4 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -5,7 +5,7 @@ FactoryBot.define do
created_by { assigned_to }
owning_organisation { assigned_to.organisation }
- managing_organisation { owning_organisation }
+ managing_organisation { assigned_to.organisation }
created_at { Time.zone.now }
updated_at { Time.zone.now }
trait :in_progress do
@@ -32,6 +32,17 @@ FactoryBot.define do
jointpur { 2 }
noint { 2 }
privacynotice { 1 }
+ purchid { rand(999_999_999).to_s }
+ end
+ trait :discounted_ownership_setup_complete do
+ saledate_today
+ ownershipsch { 2 }
+ type { 9 }
+ jointpur { 1 }
+ jointmore { 1 }
+ noint { 2 }
+ privacynotice { 1 }
+ purchid { rand(999_999_999).to_s }
end
trait :outright_sale_setup_complete do
saledate_today
@@ -67,14 +78,14 @@ FactoryBot.define do
noint { 2 }
privacynotice { 1 }
age1_known { 0 }
- age1 { 30 }
- sex1 { "X" }
+ age1 { Faker::Number.within(range: 27..45) }
+ sex1 { %w[F M X R].sample }
national { 18 }
buy1livein { 1 }
relat2 { "P" }
proptype { 1 }
age2_known { 0 }
- age2 { 35 }
+ age2 { Faker::Number.within(range: 25..45) }
builtype { 1 }
ethnic { 3 }
ethnic_group { 17 }
@@ -104,16 +115,16 @@ FactoryBot.define do
inc2mort { 1 }
uprn_known { 0 }
address_line1 { "Address line 1" }
- town_or_city { "Town or city" }
+ town_or_city { Faker::Address.city }
la_known { 1 }
la { "E09000003" }
savingsnk { 1 }
prevown { 1 }
prevshared { 2 }
- sex3 { "X" }
- sex4 { "X" }
- sex5 { "X" }
- sex6 { "X" }
+ sex3 { %w[F M X R].sample }
+ sex4 { %w[F M X R].sample }
+ sex5 { %w[F M X R].sample }
+ sex6 { %w[F M X R].sample }
mortgage { 20_000 }
ecstat3 { 9 }
ecstat4 { 3 }
@@ -122,6 +133,7 @@ FactoryBot.define do
disabled { 1 }
deposit { 80_000 }
value { 110_000 }
+ value_value_check { 0 }
grant { 10_000 }
proplen { 10 }
pregyrha { 1 }
@@ -161,6 +173,13 @@ FactoryBot.define do
log.uprn = "10033558653"
log.uprn_selection = 1
end
+ if log.saledate >= Time.zone.local(2025, 4, 1)
+ log.relat2 = "X" if log.relat2 == "C"
+ log.relat3 = "X" if log.relat3 == "C"
+ log.relat4 = "X" if log.relat4 == "C"
+ log.relat5 = "X" if log.relat5 == "C"
+ log.relat6 = "X" if log.relat6 == "C"
+ end
end
end
trait :with_uprn do
@@ -174,5 +193,12 @@ FactoryBot.define do
trait :imported do
old_id { Random.hex }
end
+ trait :ignore_validation_errors do
+ to_create do |instance|
+ instance.valid?
+ instance.errors.clear
+ instance.save!(validate: false)
+ end
+ end
end
end
diff --git a/spec/factories/scheme.rb b/spec/factories/scheme.rb
index 77d74b70a..34f98a8a6 100644
--- a/spec/factories/scheme.rb
+++ b/spec/factories/scheme.rb
@@ -41,5 +41,8 @@ FactoryBot.define do
support_type { 2 }
intended_stay { "M" }
end
+ trait :created_now do
+ created_at { Time.zone.now }
+ end
end
end
diff --git a/spec/factories/user.rb b/spec/factories/user.rb
index 956d88332..8708e319b 100644
--- a/spec/factories/user.rb
+++ b/spec/factories/user.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :user do
sequence(:email) { "test#{SecureRandom.hex}@example.com" }
- name { "Danny Rojas" }
+ name { Faker::Name.name }
password { "pAssword1" }
organisation { association :organisation, with_dsa: is_dpo ? false : true }
role { "data_provider" }
@@ -40,5 +40,9 @@ FactoryBot.define do
)
end
end
+
+ trait :if_unique do
+ initialize_with { User.find_or_create_by(email:) }
+ end
end
end
diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb
index 092ab2b40..efb7e7665 100644
--- a/spec/features/lettings_log_spec.rb
+++ b/spec/features/lettings_log_spec.rb
@@ -276,7 +276,7 @@ RSpec.describe "Lettings Log Features" do
expect(breadcrumbs.length).to eq 3
expect(breadcrumbs[0].text).to eq "Home"
expect(breadcrumbs[0][:href]).to eq root_path
- expect(breadcrumbs[1].text).to eq "Lettings logs (MHCLG)"
+ expect(breadcrumbs[1].text).to eq "Lettings logs (#{lettings_log.owning_organisation.name})"
expect(breadcrumbs[1][:href]).to eq lettings_logs_organisation_path(lettings_log.owning_organisation)
expect(breadcrumbs[2].text).to eq "Log #{lettings_log.id}"
expect(breadcrumbs[2][:href]).to eq lettings_log_path(lettings_log)
@@ -292,7 +292,7 @@ RSpec.describe "Lettings Log Features" do
expect(breadcrumbs.length).to eq 3
expect(breadcrumbs[0].text).to eq "Home"
expect(breadcrumbs[0][:href]).to eq root_path
- expect(breadcrumbs[1].text).to eq "Lettings logs (MHCLG)"
+ expect(breadcrumbs[1].text).to eq "Lettings logs (#{lettings_log.owning_organisation.name})"
expect(breadcrumbs[1][:href]).to eq lettings_logs_organisation_path(lettings_log.owning_organisation)
expect(breadcrumbs[2].text).to eq "Log #{lettings_log.id}"
expect(breadcrumbs[2][:href]).to eq lettings_log_path(lettings_log)
diff --git a/spec/features/sales_log_spec.rb b/spec/features/sales_log_spec.rb
index ceff00f94..879f2b5c8 100644
--- a/spec/features/sales_log_spec.rb
+++ b/spec/features/sales_log_spec.rb
@@ -259,7 +259,7 @@ RSpec.describe "Sales Log Features" do
expect(breadcrumbs.length).to eq 3
expect(breadcrumbs[0].text).to eq "Home"
expect(breadcrumbs[0][:href]).to eq root_path
- expect(breadcrumbs[1].text).to eq "Sales logs (MHCLG)"
+ expect(breadcrumbs[1].text).to eq "Sales logs (#{sales_log.owning_organisation.name})"
expect(breadcrumbs[1][:href]).to eq sales_logs_organisation_path(sales_log.owning_organisation)
expect(breadcrumbs[2].text).to eq "Log #{sales_log.id}"
expect(breadcrumbs[2][:href]).to eq sales_log_path(sales_log.id)
@@ -273,7 +273,7 @@ RSpec.describe "Sales Log Features" do
expect(breadcrumbs.length).to eq 3
expect(breadcrumbs[0].text).to eq "Home"
expect(breadcrumbs[0][:href]).to eq root_path
- expect(breadcrumbs[1].text).to eq "Sales logs (MHCLG)"
+ expect(breadcrumbs[1].text).to eq "Sales logs (#{sales_log.owning_organisation.name})"
expect(breadcrumbs[1][:href]).to eq sales_logs_organisation_path(sales_log.owning_organisation)
expect(breadcrumbs[2].text).to eq "Log #{sales_log.id}"
expect(breadcrumbs[2][:href]).to eq sales_log_path(sales_log.id)
diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb
index 7c7d9f3fb..dfb56665b 100644
--- a/spec/features/schemes_spec.rb
+++ b/spec/features/schemes_spec.rb
@@ -5,9 +5,10 @@ RSpec.describe "Schemes scheme Features" do
include SchemesHelpers
context "when viewing list of schemes" do
context "when I am signed as a coordinator user and there are schemes in the database" do
- let!(:user) { FactoryBot.create(:user, :data_coordinator, last_sign_in_at: Time.zone.now) }
- let!(:schemes) { FactoryBot.create_list(:scheme, 5, owning_organisation: user.organisation) }
- let!(:scheme_to_search) { FactoryBot.create(:scheme, owning_organisation: user.organisation) }
+ let(:organisation) { FactoryBot.create(:organisation, name: "MHCLG") }
+ let!(:user) { FactoryBot.create(:user, :data_coordinator, organisation:, last_sign_in_at: Time.zone.now) }
+ let!(:schemes) { FactoryBot.create_list(:scheme, 5, owning_organisation: organisation) }
+ let!(:scheme_to_search) { FactoryBot.create(:scheme, owning_organisation: organisation) }
before do
Timecop.freeze(Time.zone.local(2024, 3, 1))
@@ -225,7 +226,7 @@ RSpec.describe "Schemes scheme Features" do
end
it "shows list of links to the organisation's schemes" do
- click_on("Schemes (MHCLG)")
+ click_on("Schemes (#{user.organisation.name})")
same_organisation_schemes.each do |scheme|
expect(page).to have_link(scheme.service_name)
expect(page).to have_content(scheme.id_to_display)
diff --git a/spec/helpers/organisations_helper_spec.rb b/spec/helpers/organisations_helper_spec.rb
index 9ebe12d1f..ea0d9b158 100644
--- a/spec/helpers/organisations_helper_spec.rb
+++ b/spec/helpers/organisations_helper_spec.rb
@@ -3,7 +3,7 @@ require "rails_helper"
RSpec.describe OrganisationsHelper do
include TagHelper
describe "display_organisation_attributes" do
- let(:organisation) { create(:organisation) }
+ let(:organisation) { create(:organisation, :la, :holds_own_stock, address_line1: "2 Marsham Street", address_line2: "London", postcode: "SW1P 4DF", housing_registration_no: 1234, organisation_rent_periods: []) }
it "has the correct values" do
expect(display_organisation_attributes(organisation)).to eq(
diff --git a/spec/helpers/tab_nav_helper_spec.rb b/spec/helpers/tab_nav_helper_spec.rb
index 4a2d13377..89f867775 100644
--- a/spec/helpers/tab_nav_helper_spec.rb
+++ b/spec/helpers/tab_nav_helper_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe TabNavHelper do
describe "#org_cell" do
it "returns the users org name and role separated by a newline character" do
- expected_html = "MHCLG\nData provider"
+ expected_html = "#{organisation.name}\nData provider"
expect(org_cell(current_user)).to match(expected_html)
end
end
diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb
index d3dc7e21f..74594c9b9 100644
--- a/spec/models/form_spec.rb
+++ b/spec/models/form_spec.rb
@@ -329,7 +329,7 @@ RSpec.describe Form, type: :model do
end
context "when a value is changed such that a radio and free input questions are no longer routed to" do
- let(:log) { FactoryBot.create(:lettings_log, :completed, startdate: now) }
+ let(:log) { FactoryBot.create(:lettings_log, :completed, startdate: now, hhmemb: 2, details_known_2: 0, sex2: "M", relat2: "P", age2_known: 0, age2: 32, ecstat2: 6) }
it "all attributes relating to that checkbox question are cleared" do
expect(log.hhmemb).to be 2
diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb
index fe919a336..9b01845ae 100644
--- a/spec/models/organisation_spec.rb
+++ b/spec/models/organisation_spec.rb
@@ -207,7 +207,7 @@ RSpec.describe Organisation, type: :model do
end
describe "paper trail" do
- let(:organisation) { create(:organisation) }
+ let(:organisation) { create(:organisation, name: "MHCLG") }
it "creates a record of changes to a log" do
expect { organisation.update!(name: "new test name") }.to change(organisation.versions, :count).by(1)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 89f4f9dee..51cfc00bd 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -380,7 +380,7 @@ RSpec.describe User, type: :model do
end
describe "paper trail" do
- let(:user) { create(:user) }
+ let(:user) { create(:user, name: "Danny Rojas") }
it "creates a record of changes to a log" do
expect { user.update!(name: "new test name") }.to change(user.versions, :count).by(1)
diff --git a/spec/requests/merge_requests_controller_spec.rb b/spec/requests/merge_requests_controller_spec.rb
index a73db8067..2e2488b93 100644
--- a/spec/requests/merge_requests_controller_spec.rb
+++ b/spec/requests/merge_requests_controller_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe MergeRequestsController, type: :request do
end
it "shows the correct content" do
- expect(page).to have_content("Which organisations are merging into MHCLG?")
+ expect(page).to have_content("Which organisations are merging into #{organisation.name}?")
end
end
end
@@ -64,7 +64,7 @@ RSpec.describe MergeRequestsController, type: :request do
it "adds merging organisation to the page" do
merge_request.reload
- expect(page).to have_content("MHCLG")
+ expect(page).to have_content(organisation.name)
expect(page).to have_content("Other Test Org")
expect(page).to have_link("Remove")
end
@@ -657,7 +657,7 @@ RSpec.describe MergeRequestsController, type: :request do
it "shows user outcomes after merge" do
expect(page).to have_link("View all 4 Organisation with some users users (opens in a new tab)", href: users_organisation_path(organisation_with_some_users))
expect(page).to have_link("View all 12 Organisation with many users users (opens in a new tab)", href: users_organisation_path(organisation_with_some_more_users))
- expect(page).to have_link("View all 3 MHCLG users (opens in a new tab)", href: users_organisation_path(organisation))
+ expect(page).to have_link("View all 3 #{organisation.name} users (opens in a new tab)", href: users_organisation_path(organisation))
expect(page).to have_content("Organisation with no users and Organisation with no users too have no users.")
expect(page).to have_content("19 users after merge")
end
@@ -684,7 +684,7 @@ RSpec.describe MergeRequestsController, type: :request do
it "shows scheme outcomes after merge" do
expect(page).to have_link("View all 4 Organisation with some schemes schemes (opens in a new tab)", href: schemes_organisation_path(organisation_with_some_schemes))
expect(page).to have_link("View all 6 Organisation with many schemes schemes (opens in a new tab)", href: schemes_organisation_path(organisation_with_some_more_schemes))
- expect(page).to have_link("View all 3 MHCLG schemes (opens in a new tab)", href: schemes_organisation_path(organisation))
+ expect(page).to have_link("View all 3 #{organisation.name} schemes (opens in a new tab)", href: schemes_organisation_path(organisation))
expect(page).to have_content("Organisation with no schemes and Organisation with no schemes too have no schemes.")
expect(page).to have_content("13 schemes after merge")
end
@@ -710,8 +710,8 @@ RSpec.describe MergeRequestsController, type: :request do
it "shows logs outcomes after merge" do
expect(page).to have_link("View all 4 Organisation with some logs lettings logs (opens in a new tab)", href: lettings_logs_organisation_path(organisation_with_some_logs))
expect(page).to have_link("View all 2 Organisation with some logs sales logs (opens in a new tab)", href: sales_logs_organisation_path(organisation_with_some_logs))
- expect(page).to have_link("View all 2 MHCLG lettings logs (opens in a new tab)", href: lettings_logs_organisation_path(organisation))
- expect(page).to have_link("View all 3 MHCLG sales logs (opens in a new tab)", href: sales_logs_organisation_path(organisation))
+ expect(page).to have_link("View all 2 #{organisation.name} lettings logs (opens in a new tab)", href: lettings_logs_organisation_path(organisation))
+ expect(page).to have_link("View all 3 #{organisation.name} sales logs (opens in a new tab)", href: sales_logs_organisation_path(organisation))
expect(page).to have_content("Organisation with no logs and Organisation with no logs too have no lettings logs.")
expect(page).to have_content("Organisation with no logs and Organisation with no logs too have no sales logs.")
expect(page).to have_content("6 lettings logs after merge")
diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb
index 5a300c56c..c99ad3cfb 100644
--- a/spec/requests/organisations_controller_spec.rb
+++ b/spec/requests/organisations_controller_spec.rb
@@ -1431,7 +1431,7 @@ RSpec.describe OrganisationsController, type: :request do
end
context "when a search parameter is passed" do
- let!(:matching_user) { create(:user, organisation:, name: "joe", email: "matching@example.com") }
+ let!(:matching_user) { create(:user, organisation:, name: "abcdefghijklmnopqrstuvwxyz", email: "matching@example.com") }
let(:org_user_count) { User.where(organisation:).count }
before do
@@ -1439,7 +1439,7 @@ RSpec.describe OrganisationsController, type: :request do
end
context "when our search string matches case" do
- let(:search_param) { "joe" }
+ let(:search_param) { "abcdefghijklmnopqrstuvwxyz" }
it "returns only matching results" do
expect(page).to have_content(matching_user.name)
@@ -1459,7 +1459,7 @@ RSpec.describe OrganisationsController, type: :request do
end
context "when we need case insensitive search" do
- let(:search_param) { "Joe" }
+ let(:search_param) { "Abcdefghijklmnopqrstuvwxyz" }
it "returns only matching results" do
expect(page).to have_content(matching_user.name)
@@ -1643,6 +1643,11 @@ RSpec.describe OrganisationsController, type: :request do
context "when search results require pagination" do
let(:search_param) { "MHCLG" }
+ before do
+ create_list(:organisation, 27, name: "MHCLG")
+ get "/organisations?search=#{search_param}"
+ end
+
it "has search and pagination in the title" do
expect(page).to have_title("Organisations (27 organisations matching ‘#{search_param}’) (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 2b7210402..12418d532 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -1264,8 +1264,8 @@ RSpec.describe UsersController, type: :request do
end
context "when user is signed in as a support user" do
- let(:user) { create(:user, :support, organisation: create(:organisation, :without_dpc)) }
- let(:other_user) { create(:user, organisation: user.organisation, last_sign_in_at: Time.zone.now) }
+ let(:user) { create(:user, :support, name: "Danny Rojas", organisation: create(:organisation, :without_dpc)) }
+ let(:other_user) { create(:user, name: "Danny Rojas", organisation: user.organisation, last_sign_in_at: Time.zone.now) }
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
@@ -2002,7 +2002,7 @@ RSpec.describe UsersController, type: :request do
end
context "when the user is not part of the same organisation as the current user" do
- let(:other_user) { create(:user) }
+ let(:other_user) { create(:user, organisation: create(:organisation, name: "Another org")) }
let(:params) { { id: other_user.id, user: { name: new_name } } }
it "updates the user" do
@@ -2191,9 +2191,9 @@ RSpec.describe UsersController, type: :request do
context "when different organisations manage the logs" do
before do
- create(:lettings_log, managing_organisation: other_user.organisation, assigned_to: other_user)
- create(:lettings_log, managing_organisation: new_organisation_2, assigned_to: other_user)
- create(:sales_log, managing_organisation: new_organisation_3, assigned_to: other_user)
+ create(:lettings_log, owning_organisation: other_user.organisation, managing_organisation: other_user.organisation, assigned_to: other_user)
+ create(:lettings_log, owning_organisation: other_user.organisation, managing_organisation: new_organisation_2, assigned_to: other_user)
+ create(:sales_log, owning_organisation: other_user.organisation, managing_organisation: new_organisation_3, assigned_to: other_user)
patch "/users/#{other_user.id}/log-reassignment", headers:, params:
end
@@ -2209,8 +2209,8 @@ RSpec.describe UsersController, type: :request do
context "when users organisation manages the logs" do
before do
- create(:lettings_log, owning_organisation: other_user.organisation, assigned_to: other_user)
- create(:sales_log, owning_organisation: other_user.organisation, assigned_to: other_user)
+ create(:lettings_log, owning_organisation: other_user.organisation, managing_organisation: other_user.organisation, assigned_to: other_user)
+ create(:sales_log, owning_organisation: other_user.organisation, managing_organisation: other_user.organisation, assigned_to: other_user)
patch "/users/#{other_user.id}/log-reassignment", headers:, params:
end
@@ -2222,15 +2222,15 @@ RSpec.describe UsersController, type: :request do
context "when different organisations manage the logs" do
before do
- create(:lettings_log, owning_organisation: other_user.organisation, assigned_to: other_user)
- create(:lettings_log, owning_organisation: new_organisation_2, assigned_to: other_user)
+ create(:lettings_log, owning_organisation: other_user.organisation, managing_organisation: other_user.organisation, assigned_to: other_user)
+ create(:lettings_log, owning_organisation: new_organisation_2, managing_organisation: other_user.organisation, assigned_to: other_user)
create(:sales_log, owning_organisation: new_organisation_3, managing_organisation: other_user.organisation, assigned_to: other_user)
patch "/users/#{other_user.id}/log-reassignment", headers:, params:
end
it "required the new org to have managing agent relationship with owning organisations" do
expect(response).to have_http_status(:unprocessable_entity)
- expect(page).to have_content("New org must be a managing agent of #{other_user.organisation_name}, #{new_organisation_2.name}, and #{new_organisation_3.name} to make this change.")
+ expect(page).to have_content("New org must be a managing agent of #{other_user.organisation.name}, #{new_organisation_2.name}, and #{new_organisation_3.name} to make this change.")
end
end
end
diff --git a/spec/services/csv/lettings_log_csv_service_spec.rb b/spec/services/csv/lettings_log_csv_service_spec.rb
index 3134fa451..7a0e15a12 100644
--- a/spec/services/csv/lettings_log_csv_service_spec.rb
+++ b/spec/services/csv/lettings_log_csv_service_spec.rb
@@ -196,7 +196,7 @@ RSpec.describe Csv::LettingsLogCsvService do
describe "the full CSV output" do
context "when the requested log year is 2024" do
let(:year) { 2024 }
- let(:organisation) { create(:organisation, provider_type: "LA") }
+ let(:organisation) { create(:organisation, provider_type: "LA", name: "MHCLG") }
let(:log) do
create(
:lettings_log,
@@ -389,7 +389,7 @@ RSpec.describe Csv::LettingsLogCsvService do
context "when the requested log year is 2023" do
let(:year) { 2023 }
- let(:organisation) { create(:organisation, provider_type: "LA") }
+ let(:organisation) { create(:organisation, provider_type: "LA", name: "MHCLG") }
let(:log) do
create(
:lettings_log,
diff --git a/spec/services/csv/sales_log_csv_service_spec.rb b/spec/services/csv/sales_log_csv_service_spec.rb
index 4bbbaf645..3cf56af2e 100644
--- a/spec/services/csv/sales_log_csv_service_spec.rb
+++ b/spec/services/csv/sales_log_csv_service_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Csv::SalesLogCsvService do
subject(:task) { Rake::Task["data_import:add_variable_definitions"] }
let(:form_handler_mock) { instance_double(FormHandler) }
- let(:organisation) { create(:organisation) }
+ let(:organisation) { create(:organisation, name: "MHCLG") }
let(:fixed_time) { now }
let(:now) { Time.zone.now }
let(:user) { create(:user, :support, email: "billyboy@eyeKLAUD.com") }
@@ -17,15 +17,23 @@ RSpec.describe Csv::SalesLogCsvService do
created_at: fixed_time,
updated_at: now,
owning_organisation: organisation,
+ managing_organisation: organisation,
purchid: nil,
hholdcount: 3,
+ age1: 30,
+ sex1: "X",
+ age2: 35,
+ sex2: "X",
+ sex3: "X",
age4_known: 1,
+ sex4: "X",
details_known_5: 2,
age6_known: nil,
age6: nil,
ecstat6: nil,
relat6: nil,
sex6: nil,
+ town_or_city: "Town or city",
address_line1_as_entered: "address line 1 as entered",
address_line2_as_entered: "address line 2 as entered",
town_or_city_as_entered: "town or city as entered",
diff --git a/spec/services/csv/scheme_csv_service_spec.rb b/spec/services/csv/scheme_csv_service_spec.rb
index 57f009c65..77c0bae45 100644
--- a/spec/services/csv/scheme_csv_service_spec.rb
+++ b/spec/services/csv/scheme_csv_service_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe Csv::SchemeCsvService do
- let(:organisation) { create(:organisation) }
+ let(:organisation) { create(:organisation, name: "MHCLG") }
let(:fixed_time) { Time.zone.local(2023, 6, 26) }
let(:scheme) { create(:scheme, :export, owning_organisation: organisation, service_name: "Test name") }
let(:location) { create(:location, :export, scheme:) }
diff --git a/spec/services/exports/lettings_log_export_service_spec.rb b/spec/services/exports/lettings_log_export_service_spec.rb
index 6f7d88c91..6a07af8dd 100644
--- a/spec/services/exports/lettings_log_export_service_spec.rb
+++ b/spec/services/exports/lettings_log_export_service_spec.rb
@@ -15,7 +15,8 @@ RSpec.describe Exports::LettingsLogExportService do
let(:expected_data_filename) { "core_2021_2022_apr_mar_f0001_inc0001_pt001.xml" }
let(:expected_manifest_filename) { "manifest.xml" }
let(:start_time) { Time.zone.local(2022, 5, 1) }
- let(:user) { FactoryBot.create(:user, email: "test1@example.com") }
+ let(:organisation) { create(:organisation, name: "MHCLG", housing_registration_no: 1234) }
+ let(:user) { FactoryBot.create(:user, email: "test1@example.com", organisation:) }
def replace_entity_ids(lettings_log, export_template)
export_template.sub!(/\{id\}/, (lettings_log["id"] + Exports::LettingsLogExportService::LOG_ID_OFFSET).to_s)
@@ -79,7 +80,7 @@ RSpec.describe Exports::LettingsLogExportService do
end
context "and one lettings log is available for export" do
- let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", tenancycode: "BZ737", startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) }
+ let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, age1: 35, sex1: "F", age2: 32, sex2: "M", propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", town_or_city: "London", tenancycode: "BZ737", startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) }
it "generates a ZIP export file with the expected filename" do
expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args)
@@ -123,7 +124,7 @@ RSpec.describe Exports::LettingsLogExportService do
end
context "and one lettings log with unknown user details is available for export" do
- let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, details_known_2: 1, assigned_to: user, propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", tenancycode: "BZ737", startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) }
+ let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, details_known_2: 1, assigned_to: user, age1: 35, sex1: "F", propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", town_or_city: "London", tenancycode: "BZ737", startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) }
def replace_person_details(export_file)
export_file.sub!("32", "-9")
@@ -176,7 +177,7 @@ RSpec.describe Exports::LettingsLogExportService do
end
context "and one lettings log is available for export" do
- let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, uprn_known: 1, uprn: "100023336956", propcode: "123", postcode_full: "SE2 6RT", ppostcode_full: "SE2 6RT", tenancycode: "BZ737", startdate: Time.zone.local(2023, 4, 2, 10, 36, 49), voiddate: Time.zone.local(2021, 11, 3), mrcdate: Time.zone.local(2022, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) }
+ let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, age1: 35, sex1: "F", age2: 32, sex2: "M", uprn_known: 1, uprn: "100023336956", propcode: "123", postcode_full: "SE2 6RT", ppostcode_full: "SE2 6RT", tenancycode: "BZ737", startdate: Time.zone.local(2023, 4, 2, 10, 36, 49), voiddate: Time.zone.local(2021, 11, 3), mrcdate: Time.zone.local(2022, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) }
let(:expected_zip_filename) { "core_2023_2024_apr_mar_f0001_inc0001.zip" }
let(:expected_data_filename) { "core_2023_2024_apr_mar_f0001_inc0001_pt001.xml" }
let(:xml_export_file) { File.open("spec/fixtures/exports/general_needs_log_23_24.xml", "r:UTF-8") }
@@ -396,7 +397,7 @@ RSpec.describe Exports::LettingsLogExportService do
end
context "and one lettings log with duplicate reference is available for export" do
- let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", tenancycode: "BZ737", startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4, duplicate_set_id: 123) }
+ let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, age1: 35, sex1: "F", age2: 32, sex2: "M", propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", town_or_city: "London", tenancycode: "BZ737", startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4, duplicate_set_id: 123) }
def replace_duplicate_set_id(export_file)
export_file.sub!("", "123")
@@ -429,7 +430,7 @@ RSpec.describe Exports::LettingsLogExportService do
end
context "and one lettings log is available for export" do
- let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, ppostcode_full: "A1 1AA", nationality_all_group: 13, propcode: "123", postcode_full: "SE2 6RT", tenancycode: "BZ737", startdate: Time.zone.local(2024, 4, 2, 10, 36, 49), voiddate: Time.zone.local(2021, 11, 3), mrcdate: Time.zone.local(2022, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4, creation_method: 2, bulk_upload_id: 1, address_line1_as_entered: "address line 1 as entered", address_line2_as_entered: "address line 2 as entered", town_or_city_as_entered: "town or city as entered", county_as_entered: "county as entered", postcode_full_as_entered: "AB1 2CD", la_as_entered: "la as entered") }
+ let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, assigned_to: user, age1: 35, sex1: "F", age2: 32, sex2: "M", ppostcode_full: "A1 1AA", nationality_all_group: 13, propcode: "123", postcode_full: "SE2 6RT", tenancycode: "BZ737", startdate: Time.zone.local(2024, 4, 2, 10, 36, 49), voiddate: Time.zone.local(2021, 11, 3), mrcdate: Time.zone.local(2022, 5, 5, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4, creation_method: 2, bulk_upload_id: 1, address_line1_as_entered: "address line 1 as entered", address_line2_as_entered: "address line 2 as entered", town_or_city_as_entered: "town or city as entered", county_as_entered: "county as entered", postcode_full_as_entered: "AB1 2CD", la_as_entered: "la as entered") }
let(:expected_zip_filename) { "core_2024_2025_apr_mar_f0001_inc0001.zip" }
let(:expected_data_filename) { "core_2024_2025_apr_mar_f0001_inc0001_pt001.xml" }
let(:xml_export_file) { File.open("spec/fixtures/exports/general_needs_log_24_25.xml", "r:UTF-8") }
@@ -450,13 +451,13 @@ RSpec.describe Exports::LettingsLogExportService do
context "when exporting a supported housing lettings logs in XML" do
let(:export_file) { File.open("spec/fixtures/exports/supported_housing_logs.xml", "r:UTF-8") }
- let(:organisation) { FactoryBot.create(:organisation, provider_type: "LA") }
+ let(:organisation) { FactoryBot.create(:organisation, name: "MHCLG", provider_type: "LA", housing_registration_no: 1234) }
let(:user) { FactoryBot.create(:user, organisation:, email: "fake@email.com") }
let(:other_user) { FactoryBot.create(:user, organisation:, email: "other@email.com") }
let(:scheme) { FactoryBot.create(:scheme, :export, owning_organisation: organisation) }
let(:location) { FactoryBot.create(:location, :export, scheme:, startdate: Time.zone.local(2021, 4, 1), old_id: "1a") }
- let(:lettings_log) { FactoryBot.create(:lettings_log, :completed, :export, :sh, scheme:, location:, assigned_to: user, updated_by: other_user, owning_organisation: organisation, startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), underoccupation_benefitcap: 4, sheltered: 1) }
+ let(:lettings_log) { FactoryBot.create(:lettings_log, :completed, :export, :sh, scheme:, location:, assigned_to: user, updated_by: other_user, owning_organisation: organisation, age1: 35, sex1: "F", age2: 32, sex2: "M", startdate: Time.zone.local(2022, 2, 2, 10, 36, 49), voiddate: Time.zone.local(2019, 11, 3), mrcdate: Time.zone.local(2020, 5, 5, 10, 36, 49), underoccupation_benefitcap: 4, sheltered: 1) }
before do
lettings_log.postcode_full = nil
diff --git a/spec/services/exports/organisation_export_service_spec.rb b/spec/services/exports/organisation_export_service_spec.rb
index 4de0e84a8..43ca19095 100644
--- a/spec/services/exports/organisation_export_service_spec.rb
+++ b/spec/services/exports/organisation_export_service_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe Exports::OrganisationExportService do
end
context "and one organisation is available for export" do
- let!(:organisation) { create(:organisation) }
+ let!(:organisation) { create(:organisation, name: "MHCLG", address_line1: "2 Marsham Street", address_line2: "London", postcode: "SW1P 4DF", housing_registration_no: "1234") }
it "generates a ZIP export file with the expected filename" do
expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args)
diff --git a/spec/services/exports/user_export_service_spec.rb b/spec/services/exports/user_export_service_spec.rb
index 713d6f907..8a0e22267 100644
--- a/spec/services/exports/user_export_service_spec.rb
+++ b/spec/services/exports/user_export_service_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe Exports::UserExportService do
let(:expected_data_filename) { "users_2024_2025_apr_mar_f0001_inc0001_pt001.xml" }
let(:expected_manifest_filename) { "manifest.xml" }
let(:start_time) { Time.zone.local(2022, 5, 1) }
- let(:organisation) { create(:organisation, with_dsa: false) }
+ let(:organisation) { create(:organisation, name: "MHCLG", with_dsa: false) }
def replace_entity_ids(user, export_template)
export_template.sub!(/\{id\}/, user["id"].to_s)
@@ -42,7 +42,7 @@ RSpec.describe Exports::UserExportService do
end
context "and one user is available for export" do
- let!(:user) { create(:user, organisation:, phone_extension: "123") }
+ let!(:user) { create(:user, organisation:, name: "Danny Rojas", phone_extension: "123") }
it "generates a ZIP export file with the expected filename" do
expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args)
diff --git a/spec/services/merge/merge_organisations_service_spec.rb b/spec/services/merge/merge_organisations_service_spec.rb
index 7163a142f..fbb52c2a5 100644
--- a/spec/services/merge/merge_organisations_service_spec.rb
+++ b/spec/services/merge/merge_organisations_service_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Merge::MergeOrganisationsService do
it "moves the users from merging organisation to absorbing organisation" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
- expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
+ expect(Rails.logger).to receive(:info).with("\t#{merging_organisation.data_protection_officers.first.name} (#{merging_organisation.data_protection_officers.first.email})")
expect(Rails.logger).to receive(:info).with("\tfake name (fake@email.com)")
expect(Rails.logger).to receive(:info).with("New schemes from fake org:")
merge_organisations_service.call
@@ -477,7 +477,7 @@ RSpec.describe Merge::MergeOrganisationsService do
it "logs the merged schemes and locations" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
- expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
+ expect(Rails.logger).to receive(:info).with("\t#{merging_organisation.data_protection_officers.first.name} (#{merging_organisation.data_protection_officers.first.email})")
expect(Rails.logger).to receive(:info).with("\tfake name (fake@email.com)")
expect(Rails.logger).to receive(:info).with("New schemes from fake org:")
expect(Rails.logger).to receive(:info).with(/\t#{scheme.service_name} \(S/)
@@ -623,7 +623,7 @@ RSpec.describe Merge::MergeOrganisationsService do
context "and merging sales logs" do
let(:owning_organisation) { create(:organisation, holds_own_stock: true) }
- let!(:sales_log) { create(:sales_log, saledate: Time.zone.today, owning_organisation: merging_organisation, purchid: "owned") }
+ let!(:sales_log) { create(:sales_log, saledate: Time.zone.today, owning_organisation: merging_organisation, managing_organisation: merging_organisation, purchid: "owned") }
let!(:managed_sales_log) { create(:sales_log, saledate: Time.zone.today, purchid: "managed") }
before do
@@ -744,7 +744,7 @@ RSpec.describe Merge::MergeOrganisationsService do
it "logs the merged schemes" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
- expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
+ expect(Rails.logger).to receive(:info).with("\t#{merging_organisation.data_protection_officers.first.name} (#{merging_organisation.data_protection_officers.first.email})")
expect(Rails.logger).to receive(:info).with("\tfake name (fake@email.com)")
expect(Rails.logger).to receive(:info).with("New schemes from fake org:")
expect(Rails.logger).to receive(:info).with(/\t#{scheme.service_name} \(S/)
@@ -922,7 +922,7 @@ RSpec.describe Merge::MergeOrganisationsService do
let!(:merging_organisation_user) { create(:user, organisation: merging_organisation, name: "fake name", email: "fake@email.com") }
before do
- create_list(:user, 5, organisation: merging_organisation_too)
+ create_list(:user, 5, organisation: merging_organisation_too, name: "Danny Rojas")
end
it "sets merge date and absorbing organisation on merged organisations" do
@@ -961,10 +961,11 @@ RSpec.describe Merge::MergeOrganisationsService do
context "and merging users" do
it "moves the users from merging organisations to absorbing organisation" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
- expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
+ expect(Rails.logger).to receive(:info).with("\t#{merging_organisation.data_protection_officers.first.name} (#{merging_organisation.data_protection_officers.first.email})")
expect(Rails.logger).to receive(:info).with("\tfake name (fake@email.com)")
expect(Rails.logger).to receive(:info).with("Merged users from second org:")
- expect(Rails.logger).to receive(:info).with(/\tDanny Rojas/).exactly(6).times
+ expect(Rails.logger).to receive(:info).with(/\tDanny Rojas/).exactly(5).times
+ expect(Rails.logger).to receive(:info).with(/\t#{merging_organisation_too.data_protection_officers.first.name}/)
expect(Rails.logger).to receive(:info).with("New schemes from fake org:")
expect(Rails.logger).to receive(:info).with("New schemes from second org:")
merge_organisations_service.call
@@ -1113,7 +1114,7 @@ RSpec.describe Merge::MergeOrganisationsService do
it "moves the users from merging organisation to absorbing organisation" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
- expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
+ expect(Rails.logger).to receive(:info).with("\t#{merging_organisation.data_protection_officers.first.name} (#{merging_organisation.data_protection_officers.first.email})")
expect(Rails.logger).to receive(:info).with("\tfake name (fake@email.com)")
expect(Rails.logger).to receive(:info).with("New schemes from fake org:")
merge_organisations_service.call
@@ -1251,7 +1252,7 @@ RSpec.describe Merge::MergeOrganisationsService do
it "logs the merged schemes" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
- expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
+ expect(Rails.logger).to receive(:info).with("\t#{merging_organisation.data_protection_officers.first.name} (#{merging_organisation.data_protection_officers.first.email})")
expect(Rails.logger).to receive(:info).with("\tfake name (fake@email.com)")
expect(Rails.logger).to receive(:info).with("New schemes from fake org:")
expect(Rails.logger).to receive(:info).with(/\t#{scheme.service_name} \(S/)
@@ -1462,7 +1463,7 @@ RSpec.describe Merge::MergeOrganisationsService do
it "logs the merged schemes" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
- expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
+ expect(Rails.logger).to receive(:info).with("\t#{merging_organisation.data_protection_officers.first.name} (#{merging_organisation.data_protection_officers.first.email})")
expect(Rails.logger).to receive(:info).with("\tfake name (fake@email.com)")
expect(Rails.logger).to receive(:info).with("New schemes from fake org:")
expect(Rails.logger).to receive(:info).with(/\t#{scheme.service_name} \(S/)
@@ -1590,15 +1591,16 @@ RSpec.describe Merge::MergeOrganisationsService do
let!(:merging_organisation_user) { create(:user, organisation: merging_organisation, name: "fake name", email: "fake@email.com") }
before do
- create_list(:user, 5, organisation: merging_organisation_too)
+ create_list(:user, 5, organisation: merging_organisation_too, name: "Danny Rojas")
end
it "moves the users from merging organisations to absorbing organisation" do
expect(Rails.logger).to receive(:info).with("Merged users from fake org:")
- expect(Rails.logger).to receive(:info).with("\tDanny Rojas (#{merging_organisation.data_protection_officers.first.email})")
+ expect(Rails.logger).to receive(:info).with("\t#{merging_organisation.data_protection_officers.first.name} (#{merging_organisation.data_protection_officers.first.email})")
expect(Rails.logger).to receive(:info).with("\tfake name (fake@email.com)")
expect(Rails.logger).to receive(:info).with("Merged users from second org:")
- expect(Rails.logger).to receive(:info).with(/\tDanny Rojas/).exactly(6).times
+ expect(Rails.logger).to receive(:info).with(/\tDanny Rojas/).exactly(5).times
+ expect(Rails.logger).to receive(:info).with(/\t#{merging_organisation_too.data_protection_officers.first.name}/)
expect(Rails.logger).to receive(:info).with("New schemes from fake org:")
expect(Rails.logger).to receive(:info).with("New schemes from second org:")
merge_organisations_service.call