Browse Source

CLDC-3290 Update some test setup (#2466)

* test prof in test context

* time reduced from ~1.4 to 0.27

* time reduced from ~1.1 to 0.7

* time reduced from ~0.13 to 0.07

* add testprof env variables to spec helper

* reorder gems for linting copmlaint

* Remove test-prof gem

---------

Co-authored-by: Kat <katrina@kosiak.co.uk>
pull/2513/head
Arthur Campbell 5 months ago committed by GitHub
parent
commit
3adfb29143
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      spec/components/sales_log_summary_component_spec.rb
  2. 8
      spec/models/bulk_upload_spec.rb
  3. 6
      spec/models/form/lettings/pages/created_by_spec.rb

10
spec/components/sales_log_summary_component_spec.rb

@ -1,12 +1,16 @@
require "rails_helper"
RSpec.describe SalesLogSummaryComponent, type: :component do
let(:support_user) { FactoryBot.create(:user, :support) }
let(:coordinator_user) { FactoryBot.create(:user) }
let(:support_user) { build(:user, :support) }
let(:coordinator_user) { build(:user) }
let(:purchid) { "62863" }
let(:ownershipsch) { "0" }
let(:saledate) { Time.zone.today }
let(:sales_log) { FactoryBot.create(:sales_log, ownershipsch:, purchid:, saledate:) }
let(:sales_log) { build(:sales_log, ownershipsch:, purchid:, saledate:) }
before do
allow(sales_log).to receive(:id).and_return 1
end
context "when rendering sales log for a support user" do
it "shows the log summary with organisational relationships" do

8
spec/models/bulk_upload_spec.rb

@ -6,14 +6,14 @@ RSpec.describe BulkUpload, type: :model do
describe "def bulk_upload.completed?" do
context "when there are incomplete logs" do
it "returns false" do
create_list(:lettings_log, 2, :in_progress, bulk_upload:)
create(:lettings_log, :in_progress, bulk_upload:)
expect(bulk_upload.completed?).to equal(false)
end
end
context "when there are no incomplete logs" do
it "returns true" do
create_list(:lettings_log, 2, :completed, :startdate_today, bulk_upload:)
create(:lettings_log, :completed, :startdate_today, bulk_upload:)
expect(bulk_upload.completed?).to equal(true)
end
end
@ -21,7 +21,7 @@ RSpec.describe BulkUpload, type: :model do
describe "value check clearing" do
context "with a lettings log bulk upload" do
let(:log) { create(:lettings_log, :startdate_today, bulk_upload:) }
let(:log) { build(:lettings_log, :startdate_today, bulk_upload:) }
it "has the correct number of value checks to be set as confirmed" do
expect(bulk_upload.fields_to_confirm(log)).to match_array %w[rent_value_check void_date_value_check major_repairs_date_value_check pregnancy_value_check retirement_value_check referral_value_check net_income_value_check carehome_charges_value_check scharge_value_check pscharge_value_check supcharg_value_check address_search_value_check multiple_partners_value_check partner_under_16_value_check reasonother_value_check]
@ -29,7 +29,7 @@ RSpec.describe BulkUpload, type: :model do
end
context "with a sales log bulk upload" do
let(:log) { create(:sales_log, :saledate_today, bulk_upload:) }
let(:log) { build(:sales_log, :saledate_today, bulk_upload:) }
it "has the correct number of value checks to be set as confirmed" do
expect(bulk_upload.fields_to_confirm(log)).to match_array %w[value_value_check monthly_charges_value_check percentage_discount_value_check income1_value_check income2_value_check combined_income_value_check retirement_value_check old_persons_shared_ownership_value_check buyer_livein_value_check student_not_child_value_check wheel_value_check mortgage_value_check savings_value_check deposit_value_check staircase_bought_value_check stairowned_value_check hodate_check shared_ownership_deposit_value_check extrabor_value_check grant_value_check discounted_sale_value_check deposit_and_mortgage_value_check address_search_value_check multiple_partners_value_check partner_under_16_value_check]

6
spec/models/form/lettings/pages/created_by_spec.rb

@ -18,19 +18,19 @@ RSpec.describe Form::Lettings::Pages::CreatedBy, type: :model do
context "when support" do
it "is shown" do
expect(page.routed_to?(nil, create(:user, :support))).to eq(true)
expect(page.routed_to?(nil, build(:user, :support))).to eq(true)
end
end
context "when data coordinator" do
it "is shown" do
expect(page.routed_to?(nil, create(:user, :data_coordinator))).to eq(true)
expect(page.routed_to?(nil, build(:user, :data_coordinator))).to eq(true)
end
end
context "when data provider" do
it "is not shown" do
expect(page.routed_to?(nil, create(:user))).to eq(false)
expect(page.routed_to?(nil, build(:user))).to eq(false)
end
end
end

Loading…
Cancel
Save