adapt specs to include file format

This commit is contained in:
viehlieb 2023-02-02 22:39:39 +01:00
parent ca440ee720
commit 8f95ff45a9
3 changed files with 4 additions and 4 deletions

View file

@ -187,8 +187,8 @@ describe ArticlesController, type: :controller do
describe '#parse_upload' do
let(:file) { Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/files/upload_test.csv'), original_filename: 'upload_test.csv') }
it 'updates particles from spreadsheet' do
post_with_supplier :parse_upload, params: { articles: { file: file, outlist_absent: '1', convert_units: '1' } }
it 'updates articles from spreadsheet' do
post_with_supplier :parse_upload, params: { articles: { file: file, outlist_absent: '1', convert_units: '1', type: 'foodsoft' } }
expect(response).to have_http_status(:success)
end

View file

@ -42,12 +42,12 @@ feature ArticlesController do
before do
visit upload_supplier_articles_path(supplier_id: supplier.id)
attach_file 'articles_file', file
find("#articles_type option[value='foodsoft']").select_option
end
Dir.glob('spec/fixtures/foodsoft_file_01.*') do |test_file|
describe "can import articles from #{test_file}" do
let(:file) { Rails.root.join(test_file) }
it do
find('input[type="submit"]').click
expect(find("tr:nth-child(1) #new_articles__note").value).to eq "bio ◎"

View file

@ -11,7 +11,7 @@ describe Supplier do
options = { filename: 'foodsoft_file_01.csv' }
options[:outlist_absent] = true
options[:convert_units] = true
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_from_file(Rails.root.join('spec/fixtures/foodsoft_file_01.csv'), options)
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_from_file(Rails.root.join('spec/fixtures/foodsoft_file_01.csv'), "foodsoft", options)
expect(new_articles.length).to be > 0
expect(updated_article_pairs.first[1][:name]).to eq 'Tomaten'
expect(outlisted_articles.first).to eq article2