bulk import recipients

This commit is contained in:
Jared Cosulich 2017-03-01 15:13:44 -05:00
parent 392696301c
commit 16133cdd9d
6 changed files with 56 additions and 2 deletions

View file

@ -0,0 +1,16 @@
require 'rails_helper'
describe Recipient do
describe "Import" do
let(:data) { "name,phone\rJared,111-222-333\rLauren,222-333-4444\rAbby,333-444-5555\r" }
let(:file) { instance_double('File', path: 'path') }
it "should parse file contents and return a result" do
expect(File).to receive(:open).with('path', universal_newline: false, headers: true) { StringIO.new(data) }
Recipient.import(file)
expect(Recipient.count).to eq(3)
expect(Recipient.all.map(&:name)).to eq(['Jared', 'Lauren', 'Abby'])
end
end
end