fix rubocop and add translations
This commit is contained in:
parent
346e985c49
commit
126015ca67
8 changed files with 20 additions and 17 deletions
|
@ -46,6 +46,11 @@ class ArticlesController < ApplicationController
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@article = Article.find(params[:id])
|
||||||
|
render :action => 'new', :layout => false
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@article = Article.new(params[:article])
|
@article = Article.new(params[:article])
|
||||||
if @article.valid? && @article.save
|
if @article.valid? && @article.save
|
||||||
|
@ -55,11 +60,6 @@ class ArticlesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
|
||||||
@article = Article.find(params[:id])
|
|
||||||
render :action => 'new', :layout => false
|
|
||||||
end
|
|
||||||
|
|
||||||
# Updates one Article and highlights the line if succeded
|
# Updates one Article and highlights the line if succeded
|
||||||
def update
|
def update
|
||||||
@article = Article.find(params[:id])
|
@article = Article.find(params[:id])
|
||||||
|
|
|
@ -82,9 +82,8 @@ class Supplier < ApplicationRecord
|
||||||
FoodsoftFile::parse file, options do |status, new_attrs, line|
|
FoodsoftFile::parse file, options do |status, new_attrs, line|
|
||||||
article = articles.undeleted.where(order_number: new_attrs[:order_number]).first
|
article = articles.undeleted.where(order_number: new_attrs[:order_number]).first
|
||||||
|
|
||||||
|
|
||||||
unless new_attrs[:article_category].blank?
|
unless new_attrs[:article_category].blank?
|
||||||
new_attrs[:article_category] = ArticleCategory.find_match(new_attrs[:article_category]) ? ArticleCategory.find_match(new_attrs[:article_category]) : ArticleCategory.create_or_find_by!(name: new_attrs[:article_category])
|
new_attrs[:article_category] = ArticleCategory.find_match(new_attrs[:article_category]) || ArticleCategory.create_or_find_by!(name: new_attrs[:article_category])
|
||||||
end
|
end
|
||||||
|
|
||||||
new_attrs[:tax] ||= FoodsoftConfig[:tax_default]
|
new_attrs[:tax] ||= FoodsoftConfig[:tax_default]
|
||||||
|
@ -94,7 +93,7 @@ class Supplier < ApplicationRecord
|
||||||
if article.nil?
|
if article.nil?
|
||||||
new_articles << new_article
|
new_articles << new_article
|
||||||
else
|
else
|
||||||
unequal_attributes = article.unequal_attributes(new_article, options.slice(:convert_units,:update_category))
|
unequal_attributes = article.unequal_attributes(new_article, options.slice(:convert_units, :update_category))
|
||||||
unless unequal_attributes.empty?
|
unless unequal_attributes.empty?
|
||||||
article.attributes = unequal_attributes
|
article.attributes = unequal_attributes
|
||||||
updated_article_pairs << [article, unequal_attributes]
|
updated_article_pairs << [article, unequal_attributes]
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
.control-group
|
.control-group
|
||||||
%label(for="articles_update_category")
|
%label(for="articles_update_category")
|
||||||
= f.check_box "update_category"
|
= f.check_box "update_category"
|
||||||
= "update category ?"
|
= t '.options.update_category'
|
||||||
%label(for="articles_outlist_absent")
|
%label(for="articles_outlist_absent")
|
||||||
= f.check_box "outlist_absent"
|
= f.check_box "outlist_absent"
|
||||||
= t '.options.outlist_absent'
|
= t '.options.outlist_absent'
|
||||||
|
|
|
@ -568,6 +568,7 @@ de:
|
||||||
options:
|
options:
|
||||||
convert_units: Derzeitige Einheiten beibehalten, berechne Mengeneinheit und Preis (wie Synchronisieren).
|
convert_units: Derzeitige Einheiten beibehalten, berechne Mengeneinheit und Preis (wie Synchronisieren).
|
||||||
outlist_absent: Artikel löschen, die nicht in der hochgeladenen Datei sind.
|
outlist_absent: Artikel löschen, die nicht in der hochgeladenen Datei sind.
|
||||||
|
update_category: Kategorien aus der Datei übernehmen.
|
||||||
sample:
|
sample:
|
||||||
juices: Säfte
|
juices: Säfte
|
||||||
nuts: Nüsse
|
nuts: Nüsse
|
||||||
|
|
|
@ -569,6 +569,7 @@ en:
|
||||||
options:
|
options:
|
||||||
convert_units: Keep current units, recompute unit quantity and price (like synchronize).
|
convert_units: Keep current units, recompute unit quantity and price (like synchronize).
|
||||||
outlist_absent: Delete articles not in uploaded file.
|
outlist_absent: Delete articles not in uploaded file.
|
||||||
|
update_category: Take over categoriesfrom uploaded file.
|
||||||
sample:
|
sample:
|
||||||
juices: Juices
|
juices: Juices
|
||||||
nuts: Nuts
|
nuts: Nuts
|
||||||
|
|
|
@ -515,6 +515,7 @@ es:
|
||||||
options:
|
options:
|
||||||
convert_units: Mantener unidades actuales, recomputar la cantidad y precio de unidades (como sincronizar).
|
convert_units: Mantener unidades actuales, recomputar la cantidad y precio de unidades (como sincronizar).
|
||||||
outlist_absent: Borrar artículos que no están en el archivo subido.
|
outlist_absent: Borrar artículos que no están en el archivo subido.
|
||||||
|
update_category: Toma las categorías del archivo subido.
|
||||||
sample:
|
sample:
|
||||||
juices: Jugos
|
juices: Jugos
|
||||||
nuts: Nueces
|
nuts: Nueces
|
||||||
|
|
|
@ -539,6 +539,7 @@ nl:
|
||||||
options:
|
options:
|
||||||
convert_units: Bestaande eenheden behouden, herbereken groothandelseenheid en prijs (net als synchronizeren).
|
convert_units: Bestaande eenheden behouden, herbereken groothandelseenheid en prijs (net als synchronizeren).
|
||||||
outlist_absent: Artikelen die niet in het bestand voorkomen, verwijderen.
|
outlist_absent: Artikelen die niet in het bestand voorkomen, verwijderen.
|
||||||
|
upload_category: Categorieën overnemen uit bestand.
|
||||||
sample:
|
sample:
|
||||||
juices: Sappen
|
juices: Sappen
|
||||||
nuts: Noten
|
nuts: Noten
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
require_relative '../spec_helper'
|
require_relative '../spec_helper'
|
||||||
|
|
||||||
feature ArticlesController do
|
feature ArticlesController do
|
||||||
let(:user) { create :user, groups: [create(:workgroup, role_article_meta: true)] }
|
let(:user) { create(:user, groups: [create(:workgroup, role_article_meta: true)]) }
|
||||||
let(:supplier) { create :supplier }
|
let(:supplier) { create(:supplier) }
|
||||||
let!(:article_category) { create :article_category }
|
let!(:article_category) { create(:article_category) }
|
||||||
|
|
||||||
before { login user }
|
before { login user }
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ feature ArticlesController do
|
||||||
it 'can create a new article' do
|
it 'can create a new article' do
|
||||||
click_on I18n.t('articles.index.new')
|
click_on I18n.t('articles.index.new')
|
||||||
expect(page).to have_selector('form#new_article')
|
expect(page).to have_selector('form#new_article')
|
||||||
article = build :article, supplier: supplier, article_category: article_category
|
article = build(:article, supplier: supplier, article_category: article_category)
|
||||||
within('#new_article') do
|
within('#new_article') do
|
||||||
fill_in 'article_name', :with => article.name
|
fill_in 'article_name', :with => article.name
|
||||||
fill_in 'article_unit', :with => article.unit
|
fill_in 'article_unit', :with => article.unit
|
||||||
|
@ -65,7 +65,7 @@ feature ArticlesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "can update existing article" do
|
describe "can update existing article" do
|
||||||
let!(:article) { create :article, supplier: supplier, name: 'Foobar', order_number: 1, unit: '250 g' }
|
let!(:article) { create(:article, supplier: supplier, name: 'Foobar', order_number: 1, unit: '250 g') }
|
||||||
|
|
||||||
it do
|
it do
|
||||||
find('input[type="submit"]').click
|
find('input[type="submit"]').click
|
||||||
|
@ -80,7 +80,7 @@ feature ArticlesController do
|
||||||
describe "handles missing data" do
|
describe "handles missing data" do
|
||||||
it do
|
it do
|
||||||
find('input[type="submit"]').click # to overview
|
find('input[type="submit"]').click # to overview
|
||||||
element = find('#new_articles__price')
|
element = find_by_id('new_articles__price')
|
||||||
element.fill_in with: ""
|
element.fill_in with: ""
|
||||||
find('input[type="submit"]').click # missing category, re-show form
|
find('input[type="submit"]').click # missing category, re-show form
|
||||||
expect(find('tr.alert')).to be_present
|
expect(find('tr.alert')).to be_present
|
||||||
|
@ -93,7 +93,7 @@ feature ArticlesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "can remove an existing article" do
|
describe "can remove an existing article" do
|
||||||
let!(:article) { create :article, supplier: supplier, name: 'Foobar', order_number: 99999 }
|
let!(:article) { create(:article, supplier: supplier, name: 'Foobar', order_number: 99999) }
|
||||||
|
|
||||||
it do
|
it do
|
||||||
check('articles_outlist_absent')
|
check('articles_outlist_absent')
|
||||||
|
@ -107,7 +107,7 @@ feature ArticlesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "can convert units when updating" do
|
describe "can convert units when updating" do
|
||||||
let!(:article) { create :article, supplier: supplier, order_number: 1, unit: '250 g' }
|
let!(:article) { create(:article, supplier: supplier, order_number: 1, unit: '250 g') }
|
||||||
|
|
||||||
it do
|
it do
|
||||||
check('articles_convert_units')
|
check('articles_convert_units')
|
||||||
|
|
Loading…
Reference in a new issue