Browse Source

Update bu factory year specification

pull/2509/head
Rachael Booth 2 years ago
parent
commit
99ce3f62f5
  1. 33
      spec/components/bulk_upload_error_row_component_spec.rb
  2. 4
      spec/factories/bulk_upload.rb

33
spec/components/bulk_upload_error_row_component_spec.rb

@ -8,7 +8,7 @@ RSpec.describe BulkUploadErrorRowComponent, type: :component do
let(:purchaser_code) { nil }
let(:field) { :field_130 }
let(:error) { "some error" }
let(:bulk_upload) { create(:bulk_upload, :lettings, year: 2024) }
let(:bulk_upload) { create(:bulk_upload, :lettings) }
let(:bulk_upload_errors) do
[
FactoryBot.build(
@ -45,11 +45,29 @@ RSpec.describe BulkUploadErrorRowComponent, type: :component do
expect(result).to have_content(expected)
end
it "renders the question for lettings" do
context "when the bulk upload is for 2024" do
context "for a lettings bulk upload" do
let(:bulk_upload) { build(:bulk_upload, :lettings, year: 2024) }
let(:field) { :field_130 }
it "renders the expected question" do
expected = "What do you expect the outstanding amount to be?"
result = render_inline(described_class.new(bulk_upload_errors:))
expect(result).to have_content(expected)
end
end
context "for a sales bulk upload" do
let(:bulk_upload) { create(:bulk_upload, :sales, year: 2024) }
let(:field) { :field_86 }
it "renders the expected question" do
expected = "Is this a staircasing transaction?"
result = render_inline(described_class.new(bulk_upload_errors:))
expect(result).to have_content(expected)
end
end
end
context "when tenant_code not present" do
let(:tenant_code) { nil }
@ -78,17 +96,6 @@ RSpec.describe BulkUploadErrorRowComponent, type: :component do
end
end
context "when a sales bulk upload" do
let(:bulk_upload) { create(:bulk_upload, :sales, year: 2024) }
let(:field) { :field_86 }
it "renders the question for sales" do
expected = "Is this a staircasing transaction?"
result = render_inline(described_class.new(bulk_upload_errors:))
expect(result).to have_content(expected)
end
end
it "renders the error" do
expected = error
result = render_inline(described_class.new(bulk_upload_errors:))

4
spec/factories/bulk_upload.rb

@ -1,10 +1,12 @@
require "securerandom"
include CollectionTimeHelper
FactoryBot.define do
factory :bulk_upload do
user
log_type { BulkUpload.log_types.values.sample }
year { 2024 }
year { current_collection_start_year }
identifier { SecureRandom.uuid }
sequence(:filename) { |n| "bulk-upload-#{n}.csv" }
needstype { 1 }

Loading…
Cancel
Save