Browse Source

Specify orgs on sh logs when needed for tests

pull/2452/head
Rachael Booth 2 years ago
parent
commit
2e395d3e02
  1. 10
      spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb
  2. 11
      spec/models/lettings_log_spec.rb
  3. 6
      spec/requests/locations_controller_spec.rb

10
spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb

@ -336,11 +336,11 @@ RSpec.describe "bulk_update" do
updated_at: Time.zone.local(2022, 3, 1),
scheme:)
end
let!(:lettings_log) { FactoryBot.create(:lettings_log, :sh, location: locations[0], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log_2) { FactoryBot.create(:lettings_log, :sh, location: locations[1], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log_3) { FactoryBot.create(:lettings_log, :sh, location: locations[2], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log_4) { FactoryBot.create(:lettings_log, :sh, location: locations[0], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log_5) { FactoryBot.create(:lettings_log, :sh, location: locations[0], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log) { FactoryBot.create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, location: locations[0], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log_2) { FactoryBot.create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, location: locations[1], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log_3) { FactoryBot.create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, location: locations[2], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log_4) { FactoryBot.create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, location: locations[0], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
let!(:lettings_log_5) { FactoryBot.create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, location: locations[0], scheme:, values_updated_at: nil, startdate: Time.zone.local(2023, 4, 4)) }
before do
allow(storage_service).to receive(:get_file_io)

11
spec/models/lettings_log_spec.rb

@ -494,7 +494,7 @@ RSpec.describe LettingsLog do
end
context "and a scheme with a single log is selected" do
let(:scheme) { create(:scheme) }
let(:scheme) { create(:scheme, owning_organisation:) }
let!(:location) { create(:location, scheme:) }
before do
@ -567,7 +567,7 @@ RSpec.describe LettingsLog do
end
context "and not renewal" do
let(:scheme) { create(:scheme) }
let(:scheme) { create(:scheme, owning_organisation:) }
let(:location) { create(:location, scheme:, postcode: "M11AE", type_of_unit: 1, mobility_type: "W") }
let(:supported_housing_lettings_log) do
@ -1743,7 +1743,7 @@ RSpec.describe LettingsLog do
end
context "when there is a duplicate supported housing log" do
let(:scheme) { create(:scheme) }
let(:scheme) { create(:scheme, owning_organisation: organisation) }
let(:location) { create(:location, scheme:) }
let(:location_2) { create(:location, scheme:) }
let!(:supported_housing_log) { create(:lettings_log, :duplicate, needstype: 2, location:, scheme:, owning_organisation: organisation) }
@ -1770,9 +1770,8 @@ RSpec.describe LettingsLog do
end
it "does not return logs not associated with the user if user is given" do
user = create(:user)
supported_housing_log.update!(assigned_to: user, owning_organisation: user.organisation)
duplicate_supported_housing_log.update!(owning_organisation: user.organisation)
user = create(:user, organisation:)
supported_housing_log.update!(assigned_to: user)
duplicate_sets = described_class.duplicate_sets(user.id)
expect(duplicate_sets.count).to eq(1)
expect(duplicate_sets.first).to contain_exactly(supported_housing_log.id, duplicate_supported_housing_log.id)

6
spec/requests/locations_controller_spec.rb

@ -1582,8 +1582,8 @@ RSpec.describe LocationsController, type: :request do
before do
allow(LocationOrSchemeDeactivationMailer).to receive(:send_deactivation_mail).and_call_original
create(:lettings_log, :sh, location:, scheme:, startdate:, assigned_to: user_a)
create_list(:lettings_log, 3, :sh, location:, scheme:, startdate:, assigned_to: user_b)
create(:lettings_log, :sh, owning_organisation: scheme.owning_organisation, location:, scheme:, startdate:, assigned_to: user_a)
create_list(:lettings_log, 3, :sh, owning_organisation: scheme.owning_organisation, location:, scheme:, startdate:, assigned_to: user_b)
Timecop.freeze(Time.utc(2022, 10, 10))
sign_in user
@ -1915,7 +1915,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a support user" do
let(:user) { create(:user, :support) }
let(:scheme) { create(:scheme) }
let(:scheme) { create(:scheme, owning_organisation: user.organisation) }
let(:location) { create(:location, scheme:) }
let(:add_deactivations) { location.location_deactivation_periods << location_deactivation_period }

Loading…
Cancel
Save