mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
working on bulk import
This commit is contained in:
parent
16133cdd9d
commit
1387612623
3 changed files with 13 additions and 6 deletions
|
|
@ -3,14 +3,16 @@ require 'rails_helper'
|
|||
describe Recipient do
|
||||
describe "Import" do
|
||||
|
||||
let(:school) { School.create!(name: 'School') }
|
||||
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)
|
||||
Recipient.import(school, file)
|
||||
expect(Recipient.count).to eq(3)
|
||||
expect(Recipient.all.map(&:name)).to eq(['Jared', 'Lauren', 'Abby'])
|
||||
expect(Recipient.all.map(&:school).uniq).to eq([school])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue