You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sqm-dashboards/spec/models/recipient_spec.rb

22 lines
760 B

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(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
describe "When Deleted" do
it 'should delete all recipient_schedules'
end
end