From a814d9d7d527de480556534966f081b6b814543d Mon Sep 17 00:00:00 2001 From: Kat <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:05:36 +0000 Subject: [PATCH] Some tests --- spec/features/lettings_log_spec.rb | 8 ++++++++ spec/features/sales_log_spec.rb | 8 ++++++++ spec/features/schemes_spec.rb | 1 + spec/fixtures/exports/general_needs_log.xml | 4 ++-- spec/fixtures/exports/general_needs_log_23_24.xml | 4 ++-- spec/fixtures/exports/general_needs_log_24_25.xml | 4 ++-- spec/fixtures/exports/organisation.xml | 2 +- spec/fixtures/exports/supported_housing_logs.xml | 4 ++-- spec/fixtures/exports/user.xml | 2 +- spec/helpers/tab_nav_helper_spec.rb | 2 +- .../form/lettings/questions/managing_organisation_spec.rb | 2 +- spec/requests/merge_requests_controller_spec.rb | 1 + .../organisation_relationships_controller_spec.rb | 8 ++++---- spec/services/exports/lettings_log_export_service_spec.rb | 2 ++ spec/services/exports/organisation_export_service_spec.rb | 1 + spec/services/exports/user_export_service_spec.rb | 1 + 16 files changed, 38 insertions(+), 16 deletions(-) diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb index b10dfc6e5..cce057992 100644 --- a/spec/features/lettings_log_spec.rb +++ b/spec/features/lettings_log_spec.rb @@ -270,6 +270,10 @@ RSpec.describe "Lettings Log Features" do context "when visiting a subsection check answers page" do let(:lettings_log) { create(:lettings_log, :setup_completed) } + before do + lettings_log.owning_organisation.update!(name: "MHCLG") + end + it "has the correct breadcrumbs with the correct links" do visit lettings_log_setup_check_answers_path(lettings_log) breadcrumbs = page.find_all(".govuk-breadcrumbs__link") @@ -286,6 +290,10 @@ RSpec.describe "Lettings Log Features" do context "when reviewing a complete log" do let(:lettings_log) { create(:lettings_log, :completed) } + before do + lettings_log.owning_organisation.update!(name: "MHCLG") + end + it "has the correct breadcrumbs with the correct links" do visit review_lettings_log_path(lettings_log) breadcrumbs = page.find_all(".govuk-breadcrumbs__link") diff --git a/spec/features/sales_log_spec.rb b/spec/features/sales_log_spec.rb index d418bcb37..9ed46f66b 100644 --- a/spec/features/sales_log_spec.rb +++ b/spec/features/sales_log_spec.rb @@ -253,6 +253,10 @@ RSpec.describe "Sales Log Features" do end context "when visiting a subsection check answers page as a support user" do + before do + sales_log.owning_organisation.update!(name: "MHCLG") + end + it "has the correct breadcrumbs with the correct links" do visit sales_log_setup_check_answers_path(sales_log.id) breadcrumbs = page.find_all(".govuk-breadcrumbs__link") @@ -267,6 +271,10 @@ RSpec.describe "Sales Log Features" do end context "when reviewing a complete log" do + before do + sales_log.owning_organisation.update!(name: "MHCLG") + end + it "has the correct breadcrumbs with the correct links" do visit review_sales_log_path(sales_log.id, sales_log: true) breadcrumbs = page.find_all(".govuk-breadcrumbs__link") diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index dfb56665b..bc946cd17 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -197,6 +197,7 @@ RSpec.describe "Schemes scheme Features" do context "when I visit schemes page" do before do + user.organisation.update!(name: "MHCLG") visit("schemes") end diff --git a/spec/fixtures/exports/general_needs_log.xml b/spec/fixtures/exports/general_needs_log.xml index bacc7e9f0..0341dd2d4 100644 --- a/spec/fixtures/exports/general_needs_log.xml +++ b/spec/fixtures/exports/general_needs_log.xml @@ -147,10 +147,10 @@ {id} {owning_org_id} - MHCLG + {owning_org_name} 1234 {managing_org_id} - MHCLG + {managing_org_name} 1234 2022-05-01T00:00:00+01:00 2022-05-01T00:00:00+01:00 diff --git a/spec/fixtures/exports/general_needs_log_23_24.xml b/spec/fixtures/exports/general_needs_log_23_24.xml index 9635cd0e4..ef0c4066c 100644 --- a/spec/fixtures/exports/general_needs_log_23_24.xml +++ b/spec/fixtures/exports/general_needs_log_23_24.xml @@ -148,10 +148,10 @@ {id} {owning_org_id} - MHCLG + {owning_org_name} 1234 {managing_org_id} - MHCLG + {managing_org_name} 1234 2023-04-03T00:00:00+01:00 2023-04-03T00:00:00+01:00 diff --git a/spec/fixtures/exports/general_needs_log_24_25.xml b/spec/fixtures/exports/general_needs_log_24_25.xml index a665a284e..00d8bb1a5 100644 --- a/spec/fixtures/exports/general_needs_log_24_25.xml +++ b/spec/fixtures/exports/general_needs_log_24_25.xml @@ -161,10 +161,10 @@ la as entered {id} {owning_org_id} - MHCLG + {owning_org_name} 1234 {managing_org_id} - MHCLG + {managing_org_name} 1234 2024-04-03T00:00:00+01:00 2024-04-03T00:00:00+01:00 diff --git a/spec/fixtures/exports/organisation.xml b/spec/fixtures/exports/organisation.xml index 8d87da16c..70c699915 100644 --- a/spec/fixtures/exports/organisation.xml +++ b/spec/fixtures/exports/organisation.xml @@ -2,7 +2,7 @@
{id} - MHCLG + {name} 1 2 Marsham Street diff --git a/spec/fixtures/exports/supported_housing_logs.xml b/spec/fixtures/exports/supported_housing_logs.xml index 50649241b..310d5ba2b 100644 --- a/spec/fixtures/exports/supported_housing_logs.xml +++ b/spec/fixtures/exports/supported_housing_logs.xml @@ -146,10 +146,10 @@ {id} {owning_org_id} - MHCLG + {owning_org_name} 1234 {managing_org_id} - MHCLG + {managing_org_name} 1234 2022-05-01T00:00:00+01:00 2022-05-01T00:00:00+01:00 diff --git a/spec/fixtures/exports/user.xml b/spec/fixtures/exports/user.xml index 5652ac9c6..d29a33225 100644 --- a/spec/fixtures/exports/user.xml +++ b/spec/fixtures/exports/user.xml @@ -12,6 +12,6 @@ false false true - MHCLG + {organisation_name}
diff --git a/spec/helpers/tab_nav_helper_spec.rb b/spec/helpers/tab_nav_helper_spec.rb index bd29f4c46..79884a68f 100644 --- a/spec/helpers/tab_nav_helper_spec.rb +++ b/spec/helpers/tab_nav_helper_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" RSpec.describe TabNavHelper do - let(:organisation) { FactoryBot.create(:organisation) } + let(:organisation) { FactoryBot.create(:organisation, name: "MHCLG") } let(:current_user) { FactoryBot.build(:user, organisation:) } let(:scheme) { FactoryBot.create(:scheme, service_name: "Some name") } let(:location) { FactoryBot.create(:location, scheme:) } diff --git a/spec/models/form/lettings/questions/managing_organisation_spec.rb b/spec/models/form/lettings/questions/managing_organisation_spec.rb index 776a873a6..00485e80f 100644 --- a/spec/models/form/lettings/questions/managing_organisation_spec.rb +++ b/spec/models/form/lettings/questions/managing_organisation_spec.rb @@ -185,7 +185,7 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do context "when organisation has merged" do let(:absorbing_org) { create(:organisation, name: "Absorbing org", holds_own_stock: true) } let!(:merged_org) { create(:organisation, name: "Merged org", holds_own_stock: false) } - let!(:merged_deleted_org) { create(:organisation, name: "Merged org", holds_own_stock: false, discarded_at: Time.zone.yesterday) } + let!(:merged_deleted_org) { create(:organisation, name: "Merged org 2", holds_own_stock: false, discarded_at: Time.zone.yesterday) } let(:user) { create(:user, :data_coordinator, organisation: absorbing_org) } let(:log) do diff --git a/spec/requests/merge_requests_controller_spec.rb b/spec/requests/merge_requests_controller_spec.rb index 074d2186c..b80df41ed 100644 --- a/spec/requests/merge_requests_controller_spec.rb +++ b/spec/requests/merge_requests_controller_spec.rb @@ -12,6 +12,7 @@ RSpec.describe MergeRequestsController, type: :request do context "when user is signed in with a support user" do before do + organisation.update!(name: "MHCLG") allow(support_user).to receive(:need_two_factor_authentication?).and_return(false) sign_in support_user end diff --git a/spec/requests/organisation_relationships_controller_spec.rb b/spec/requests/organisation_relationships_controller_spec.rb index 79706fff9..264730fcd 100644 --- a/spec/requests/organisation_relationships_controller_spec.rb +++ b/spec/requests/organisation_relationships_controller_spec.rb @@ -58,7 +58,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do context "when adding a stock owner" do let!(:active_organisation) { FactoryBot.create(:organisation, name: "Active Org", active: true) } - let!(:inactive_organisation) { FactoryBot.create(:organisation, name: "Inactive LTD", active: false) } + let!(:inactive_organisation) { FactoryBot.create(:organisation, name: "Inactive LTD 2", active: false) } before do get "/organisations/#{organisation.id}/stock-owners/add", headers:, params: {} @@ -115,7 +115,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do let!(:managing_agent) { FactoryBot.create(:organisation) } let!(:other_org_managing_agent) { FactoryBot.create(:organisation, name: "Foobar LTD") } let!(:inactive_managing_agent) { FactoryBot.create(:organisation, name: "Inactive LTD", active: false) } - let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD") } + let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD 3") } before do FactoryBot.create(:organisation_relationship, parent_organisation: organisation, child_organisation: managing_agent) @@ -316,7 +316,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do context "with an organisation that the user belongs to" do let!(:stock_owner) { FactoryBot.create(:organisation) } let!(:other_org_stock_owner) { FactoryBot.create(:organisation, name: "Foobar LTD") } - let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD") } + let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD 2") } before do FactoryBot.create(:organisation_relationship, child_organisation: organisation, parent_organisation: stock_owner) @@ -452,7 +452,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do context "with an organisation that the user belongs to" do let!(:managing_agent) { FactoryBot.create(:organisation) } let!(:other_org_managing_agent) { FactoryBot.create(:organisation, name: "Foobar LTD") } - let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD") } + let!(:other_organisation) { FactoryBot.create(:organisation, name: "Foobar LTD 5") } before do FactoryBot.create(:organisation_relationship, parent_organisation: organisation, child_organisation: managing_agent) diff --git a/spec/services/exports/lettings_log_export_service_spec.rb b/spec/services/exports/lettings_log_export_service_spec.rb index 8c123b47e..c0dde5771 100644 --- a/spec/services/exports/lettings_log_export_service_spec.rb +++ b/spec/services/exports/lettings_log_export_service_spec.rb @@ -21,7 +21,9 @@ RSpec.describe Exports::LettingsLogExportService do def replace_entity_ids(lettings_log, export_template) export_template.sub!(/\{id\}/, (lettings_log["id"] + Exports::LettingsLogExportService::LOG_ID_OFFSET).to_s) export_template.sub!(/\{owning_org_id\}/, (lettings_log["owning_organisation_id"] + Exports::LettingsLogExportService::LOG_ID_OFFSET).to_s) + export_template.sub!(/\{owning_org_name\}/, lettings_log.owning_organisation.name) export_template.sub!(/\{managing_org_id\}/, (lettings_log["managing_organisation_id"] + Exports::LettingsLogExportService::LOG_ID_OFFSET).to_s) + export_template.sub!(/\{managing_org_name\}/, lettings_log.managing_organisation.name) export_template.sub!(/\{location_id\}/, (lettings_log["location_id"]).to_s) if lettings_log.needstype == 2 export_template.sub!(/\{scheme_id\}/, (lettings_log["scheme_id"]).to_s) if lettings_log.needstype == 2 export_template.sub!(/\{log_id\}/, lettings_log["id"].to_s) diff --git a/spec/services/exports/organisation_export_service_spec.rb b/spec/services/exports/organisation_export_service_spec.rb index 43ca19095..51c8fe8cf 100644 --- a/spec/services/exports/organisation_export_service_spec.rb +++ b/spec/services/exports/organisation_export_service_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Exports::OrganisationExportService do def replace_entity_ids(organisation, export_template) export_template.sub!(/\{id\}/, organisation["id"].to_s) + export_template.sub!(/\{name\}/, organisation["name"]) export_template.sub!(/\{dsa_signed_at\}/, organisation.data_protection_confirmation&.signed_at.to_s) export_template.sub!(/\{dpo_email\}/, organisation.data_protection_confirmation&.data_protection_officer_email) end diff --git a/spec/services/exports/user_export_service_spec.rb b/spec/services/exports/user_export_service_spec.rb index 8a0e22267..854dd1ce7 100644 --- a/spec/services/exports/user_export_service_spec.rb +++ b/spec/services/exports/user_export_service_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Exports::UserExportService do def replace_entity_ids(user, export_template) export_template.sub!(/\{id\}/, user["id"].to_s) export_template.sub!(/\{organisation_id\}/, user["organisation_id"].to_s) + export_template.sub!(/\{organisation_name\}/, user.organisation.name) export_template.sub!(/\{email\}/, user["email"].to_s) end