Browse Source

feat: unfreeze all timecop freezes

flaky_tests_testing
natdeanlewissoftwire 2 years ago
parent
commit
9a10435f8d
  1. 106
      spec/components/log_summary_component_spec.rb
  2. 1
      spec/helpers/collection_time_helper_spec.rb
  3. 1
      spec/models/form_handler_spec.rb
  4. 2
      spec/models/validations/sales/financial_validations_spec.rb
  5. 4
      spec/models/validations/tenancy_validations_spec.rb
  6. 2
      spec/requests/lettings_logs_controller_spec.rb
  7. 2
      spec/requests/sales_logs_controller_spec.rb
  8. 1
      spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb
  9. 1
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

106
spec/components/log_summary_component_spec.rb

@ -1,53 +1,53 @@
# require "rails_helper"
#
# RSpec.describe LogSummaryComponent, type: :component do
# let(:support_user) { FactoryBot.create(:user, :support) }
# let(:coordinator_user) { FactoryBot.create(:user) }
# let(:propcode) { "P3647" }
# let(:tenancycode) { "T62863" }
# let(:lettings_log) { FactoryBot.create(:lettings_log, needstype: 1, tenancycode:, propcode:, startdate: Time.zone.today) }
# let(:sales_log) { FactoryBot.create(:sales_log) }
#
# context "when rendering lettings log for a support user" do
# it "show the log summary with organisational relationships" do
# result = render_inline(described_class.new(current_user: support_user, log: lettings_log))
#
# expect(result).to have_link(lettings_log.id.to_s)
# expect(result).to have_text(lettings_log.tenancycode)
# expect(result).to have_text(lettings_log.propcode)
# expect(result).to have_text("General needs")
# expect(result).to have_text("Tenancy starts #{Time.zone.today.strftime('%e %B %Y')}")
# expect(result).to have_text("Created #{Time.zone.today.strftime('%e %B %Y')}")
# expect(result).to have_text("by Danny Rojas")
# expect(result).to have_content("Owned by\n DLUHC")
# expect(result).to have_content("Managed by\n DLUHC")
# end
# end
#
# context "when rendering lettings log for a data coordinator user" do
# it "show the log summary" do
# result = render_inline(described_class.new(current_user: coordinator_user, log: lettings_log))
#
# expect(result).not_to have_content("Owned by")
# expect(result).not_to have_content("Managed by")
# end
# end
#
# context "when rendering sales log for a support user" do
# it "show 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 DLUHC")
# expect(result).not_to have_content("Managed by")
# end
# end
#
# context "when rendering sales log for a data coordinator user" do
# it "show the log summary" do
# result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log))
#
# expect(result).not_to have_content("Owned by")
# expect(result).not_to have_content("Managed by")
# end
# end
# end
require "rails_helper"
RSpec.describe LogSummaryComponent, type: :component do
let(:support_user) { FactoryBot.create(:user, :support) }
let(:coordinator_user) { FactoryBot.create(:user) }
let(:propcode) { "P3647" }
let(:tenancycode) { "T62863" }
let(:lettings_log) { FactoryBot.create(:lettings_log, needstype: 1, tenancycode:, propcode:, startdate: Time.zone.today) }
let(:sales_log) { FactoryBot.create(:sales_log) }
context "when rendering lettings log for a support user" do
it "show the log summary with organisational relationships" do
result = render_inline(described_class.new(current_user: support_user, log: lettings_log))
expect(result).to have_link(lettings_log.id.to_s)
expect(result).to have_text(lettings_log.tenancycode)
expect(result).to have_text(lettings_log.propcode)
expect(result).to have_text("General needs")
expect(result).to have_text("Tenancy starts #{Time.zone.today.strftime('%e %B %Y')}")
expect(result).to have_text("Created #{Time.zone.today.strftime('%e %B %Y')}")
expect(result).to have_text("by Danny Rojas")
expect(result).to have_content("Owned by\n DLUHC")
expect(result).to have_content("Managed by\n DLUHC")
end
end
context "when rendering lettings log for a data coordinator user" do
it "show the log summary" do
result = render_inline(described_class.new(current_user: coordinator_user, log: lettings_log))
expect(result).not_to have_content("Owned by")
expect(result).not_to have_content("Managed by")
end
end
context "when rendering sales log for a support user" do
it "show 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 DLUHC")
expect(result).not_to have_content("Managed by")
end
end
context "when rendering sales log for a data coordinator user" do
it "show the log summary" do
result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log))
expect(result).not_to have_content("Owned by")
expect(result).not_to have_content("Managed by")
end
end
end

1
spec/helpers/collection_time_helper_spec.rb

@ -9,6 +9,7 @@ RSpec.describe CollectionTimeHelper do
Timecop.freeze(now) do
example.run
end
Timecop.return
end
context "when the date is after 1st of April" do

1
spec/models/form_handler_spec.rb

@ -9,6 +9,7 @@ RSpec.describe FormHandler do
Singleton.__init__(described_class)
example.run
end
Timecop.return
Singleton.__init__(described_class)
end

2
spec/models/validations/sales/financial_validations_spec.rb

@ -274,7 +274,7 @@ RSpec.describe Validations::Sales::FinancialValidations do
Timecop.freeze(now) do
example.run
end
Timecop.unfreeze
Timecop.return
end
context "with a log in the 22/23 collection year" do

4
spec/models/validations/tenancy_validations_spec.rb

@ -7,6 +7,10 @@ RSpec.describe Validations::TenancyValidations do
Timecop.freeze(Time.zone.local(2021, 5, 1))
end
after do
Timecop.unfreeze
end
let(:validator_class) { Class.new { include Validations::TenancyValidations } }
let(:record) { FactoryBot.create(:lettings_log, startdate: Time.zone.local(2021, 5, 1), needstype: 1, rent_type: 1) }

2
spec/requests/lettings_logs_controller_spec.rb

@ -337,7 +337,7 @@ RSpec.describe LettingsLogsController, type: :request do
Timecop.freeze(2022, 3, 1) do
example.run
end
Timecop.unfreeze
Timecop.return
end
let!(:lettings_log_2021) do

2
spec/requests/sales_logs_controller_spec.rb

@ -235,7 +235,7 @@ RSpec.describe SalesLogsController, type: :request do
Timecop.freeze(2022, 12, 1) do
example.run
end
Timecop.unfreeze
Timecop.return
end
let!(:sales_log_2022) do

1
spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb

@ -610,6 +610,7 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
Timecop.freeze(Date.new(2022, 4, 2)) do
example.run
end
Timecop.return
end
let(:attributes) { { bulk_upload:, field_96: "1", field_97: "1", field_98: "22" } }

1
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -562,6 +562,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
Timecop.freeze(Date.new(2022, 4, 2)) do
example.run
end
Timecop.return
end
let(:attributes) { { bulk_upload:, field_7: "1", field_8: "1", field_9: "22" } }

Loading…
Cancel
Save