Sha256: 1f04bd1322ef48ca7f94007f55de0ac74cb1ab97893c1a16f61e6c86d1929cca

Contents?: true

Size: 885 Bytes

Versions: 10

Compression:

Stored size: 885 Bytes

Contents

require 'rails_helper'

RSpec.describe CsvImportMagic::Failure, type: :service do
  let(:csv_parsed) { CsvImportMagic::Importer.new(import.id).call }
  subject { described_class.new(csv_parsed, import.id) }

  describe '#generate' do
    context 'creates and upload the failures file' do
      let(:attachment) { fixture_file_upload(Rails.root.join('../fixtures/companies_invalid.csv')) }
      let!(:import) { create :importer, attachment: attachment, source: 'company', columns: %w(name street number neighborhood city state country) }

      it 'when invalid record' do
        expect do
          subject.generate
          import.reload
        end.to change(import, :message).from(nil).to('Alguns registros não foram importados pois contém erros!')

        expect(import.status).to eq('error')
        expect(import.attachment_error).to be_present
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
csv_import_magic-0.0.11 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.10 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.8 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.7 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.6 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.5 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.4 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.3 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.2 spec/services/csv_import_magic/failure_spec.rb
csv_import_magic-0.0.1 spec/services/csv_import_magic/failure_spec.rb