require "spec_helper"

describe "uploading donors" do
  before(:each) do
    Title.delete_all
    Donor.delete_all
    Title.create(number: 54, description: "Ms")
    Title.create(number: 4, description: "Mr")
    Title.create(number: 30, description: "Dr")
  end

  it "uploads donors" do
    file = Rack::Test::UploadedFile.new(Rails.root.join('spec', 'fixtures', 'files', 'donors.csv'), 'text/csv')

    post "donor_upload", donor_upload: { contents: file }
    Donor.first.donor_no.should eql "100001"
    Donor.last.donor_no.should eql "100002"
  end

  it "uploads donors that have non-ASCII characters" do
    file = Rack::Test::UploadedFile.new(Rails.root.join('spec', 'fixtures', 'files', 'donors_dodgy.csv'), 'text/csv')

    post "donor_upload", donor_upload: { contents: file }
    response.code.should eql "200"
    Donor.first.donor_no.should eql "102594"
  end
end

require "spec_helper"

describe "uploading donors" do
  before(:each) do
    Title.create(number: 54, description: "Ms")
    Title.create(number: 4, description: "Mr")
    Title.create(number: 30, description: "Dr")
  end

  it "uploads donors" do
    file = Rack::Test::UploadedFile.new(Rails.root.join('spec', 'fixtures', 'files', 'donors.csv'), 'text/csv')

    post "donor_upload", donor_upload: { contents: file }
    Donor.first.donor_no.should eql "100001"
    Donor.last.donor_no.should eql "100002"
  end

  it "uploads donors that have non-ASCII characters" do
    file = Rack::Test::UploadedFile.new(Rails.root.join('spec', 'fixtures', 'files', 'donors_dodgy.csv'), 'text/csv')

    post "donor_upload", donor_upload: { contents: file }
    response.code.should eql "200"
    Donor.first.donor_no.should eql "102594"
  end
end

Remove unnecessary truncating of DB
Remove unnecessary truncating of DB
