finish plugin for bnn, foodsoft, odin uploads

This commit is contained in:
viehlieb 2023-03-30 14:55:24 +02:00
parent 9d0e2fdafc
commit e42baa1d3b
9 changed files with 167 additions and 210 deletions

View file

@ -1,28 +1,15 @@
require_relative '../test_helper'
require_relative '../../../../spec/spec_helper'
feature ArticlesController do
let(:user) { create(:user, groups: [create(:workgroup, role_article_meta: true)]) }
let(:supplier) { create(:supplier) }
let!(:article_category) { create(:article_category) }
before do
FoodsoftConfig[:use_article_import] = true
login user
end
after do
FoodsoftConfig[:use_article_import] = false
end
before { login user }
describe ':index', js: true do
puts "
" + "______________" + "
" + "______________" + "
" + "______________" + "
" + "Plugin" + "
" + "______________"+ "
" + "______________"+ "
" + "______________"
before do
login user
visit supplier_articles_path(supplier_id: supplier.id)

View file

@ -0,0 +1,21 @@
require_relative '../test_helper'
require_relative '../../../../spec/spec_helper'
describe Supplier do
let(:supplier) { create :supplier }
context 'syncs from file' do
it 'imports and updates articles' do
article1 = create(:article, supplier: supplier, order_number: 177813, unit: '250 g', price: 0.1)
article2 = create(:article, supplier: supplier, order_number: 12345)
supplier.articles = [article1, article2]
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'), '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
end
end
end