Form::Import spec reduce factories (#32924)

This commit is contained in:
Matt Jankowski 2024-11-18 04:22:09 -05:00 committed by GitHub
parent 02985aae69
commit be413d67de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -237,51 +237,26 @@ RSpec.describe Form::Import do
let(:import_file) { file } let(:import_file) { file }
let(:import_mode) { mode } let(:import_mode) { mode }
before do before { subject.save }
subject.save
end
it 'creates the expected rows' do
expect(account.bulk_imports.first.rows.pluck(:data)).to match_array(expected_rows)
end
context 'with a BulkImport' do context 'with a BulkImport' do
let(:bulk_import) { account.bulk_imports.first } let(:bulk_import) { account.bulk_imports.first }
it 'creates a non-nil bulk import' do it 'creates a bulk import with correct values' do
expect(bulk_import).to_not be_nil expect(bulk_import)
end .to be_present
.and have_attributes(
it 'matches the subjects type' do type: eq(subject.type),
expect(bulk_import.type.to_sym).to eq subject.type.to_sym original_filename: eq(subject.data.original_filename),
end likely_mismatched?: eq(subject.likely_mismatched?),
overwrite?: eq(!!subject.overwrite), # rubocop:disable Style/DoubleNegation
it 'matches the subjects original filename' do processed_items: eq(0),
expect(bulk_import.original_filename).to eq subject.data.original_filename imported_items: eq(0),
end total_items: eq(bulk_import.rows.count),
state_unconfirmed?: be(true)
it 'matches the subjects likely_mismatched? value' do )
expect(bulk_import.likely_mismatched?).to eq subject.likely_mismatched? expect(bulk_import.rows.pluck(:data))
end .to match_array(expected_rows)
it 'matches the subject overwrite value' do
expect(bulk_import.overwrite?).to eq !!subject.overwrite # rubocop:disable Style/DoubleNegation
end
it 'has zero processed items' do
expect(bulk_import.processed_items).to eq 0
end
it 'has zero imported items' do
expect(bulk_import.imported_items).to eq 0
end
it 'has a correct total_items value' do
expect(bulk_import.total_items).to eq bulk_import.rows.count
end
it 'defaults to unconfirmed true' do
expect(bulk_import.state_unconfirmed?).to be true
end end
end end
end end