Browse Source

Update tests that expect fixed default org name

pull/2824/head
Rachael Booth 1 year ago
parent
commit
99328d545b
  1. 4
      spec/features/lettings_log_spec.rb
  2. 2
      spec/models/organisation_spec.rb
  3. 12
      spec/requests/merge_requests_controller_spec.rb
  4. 5
      spec/requests/organisations_controller_spec.rb
  5. 4
      spec/services/csv/lettings_log_csv_service_spec.rb
  6. 3
      spec/services/csv/sales_log_csv_service_spec.rb
  7. 2
      spec/services/csv/scheme_csv_service_spec.rb
  8. 5
      spec/services/exports/lettings_log_export_service_spec.rb
  9. 2
      spec/services/exports/organisation_export_service_spec.rb
  10. 2
      spec/services/exports/user_export_service_spec.rb

4
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)

2
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)

12
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
@ -623,7 +623,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
@ -650,7 +650,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
@ -676,8 +676,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")

5
spec/requests/organisations_controller_spec.rb

@ -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

4
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,

3
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,6 +17,7 @@ RSpec.describe Csv::SalesLogCsvService do
created_at: fixed_time,
updated_at: now,
owning_organisation: organisation,
managing_organisation: organisation,
purchid: nil,
hholdcount: 3,
age1: 30,

2
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:) }

5
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)
@ -450,7 +451,7 @@ 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) }

2
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)

2
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)

Loading…
Cancel
Save