From 1063aea4afa30dfa8024b7256c3f60d2a65e5dcf Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 14 Jan 2015 22:51:08 +0100 Subject: [PATCH] Add file import test --- spec/fixtures/foodsoft_file_01.csv | 5 +++++ spec/integration/supplier_spec.rb | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 spec/fixtures/foodsoft_file_01.csv diff --git a/spec/fixtures/foodsoft_file_01.csv b/spec/fixtures/foodsoft_file_01.csv new file mode 100644 index 00000000..8221394b --- /dev/null +++ b/spec/fixtures/foodsoft_file_01.csv @@ -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 diff --git a/spec/integration/supplier_spec.rb b/spec/integration/supplier_spec.rb index e50a8e25..34ec912c 100644 --- a/spec/integration/supplier_spec.rb +++ b/spec/integration/supplier_spec.rb @@ -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