Add file import test

This commit is contained in:
wvengen 2015-01-14 22:51:08 +01:00
parent c31d015434
commit 1063aea4af
2 changed files with 23 additions and 0 deletions

5
spec/fixtures/foodsoft_file_01.csv vendored Normal file
View file

@ -0,0 +1,5 @@
status;art. nummer;productnaam;notitie;producent;herkomst;eenheid;prijs ex btw;btw (%);statiegeld;colligrootte;(reserved);(reserved);categorienaam
;29932;Walnoten (ongeroosterd);bio ◎;Het grote bomenbos;Veluwe, NL;kg;2.34;6;0;1;;;Nuts
;28391;Pijnboompitten;dem;Het warme woud;TR;100g;5.56;6;0;10;;;Nuts
;1829;Appelsap (verpakt);;Appelgaarde;DE;4x250ml;3.21;6;0.4;10;;;Drinks
;177813;Tomaten;bio;De röde hof;Best, NL;500 g;1.2;6;0;20;;;Vegetables
1 status art. nummer productnaam notitie producent herkomst eenheid prijs ex btw btw (%) statiegeld colligrootte (reserved) (reserved) categorienaam
2 29932 Walnoten (ongeroosterd) bio ◎ Het grote bomenbos Veluwe, NL kg 2.34 6 0 1 Nuts
3 28391 Pijnboompitten dem Het warme woud TR 100g 5.56 6 0 10 Nuts
4 1829 Appelsap (verpakt) Appelgaarde DE 4x250ml 3.21 6 0.4 10 Drinks
5 177813 Tomaten bio De röde hof Best, NL 500 g 1.2 6 0 20 Vegetables

View file

@ -1,3 +1,4 @@
# encoding: utf-8
require_relative '../spec_helper'
describe 'supplier', :type => :feature do
@ -58,6 +59,23 @@ describe 'supplier', :type => :feature do
end
expect(page).to have_content(article.name)
end
it 'can import articles' do
article_category.save!
visit upload_supplier_articles_path(supplier)
attach_file 'articles_file', Rails.root.join('spec/fixtures/foodsoft_file_01.csv')
find('input[type="submit"]').click
expect(find("#articles_0_note").value).to eq "bio ◎"
expect(find("#articles_1_name").value).to eq "Pijnboompitten"
4.times do |i|
select article_category.name, :from => "articles_#{i}_article_category_id"
end
find('input[type="submit"]').click
expect(supplier.articles.count).to eq 4
end
end
end