Skip to content

Commit

Permalink
fix: article convert_unit will fail when unit contains a comma character
Browse files Browse the repository at this point in the history
  • Loading branch information
yksflip committed Jan 26, 2024
1 parent ebbac04 commit fa9083d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/article.rb
Expand Up @@ -189,6 +189,7 @@ def shared_article(supplier = self.supplier)
# returns nil if units are eqal
def convert_units(new_article = shared_article)
return unless unit != new_article.unit
return false if new_article.unit.include?(',')

# legacy, used by foodcoops in Germany
if new_article.unit == 'KI' && unit == 'ST' # 'KI' means a box, with a different amount of items in it
Expand Down
3 changes: 1 addition & 2 deletions spec/models/article_spec.rb
Expand Up @@ -31,8 +31,7 @@
expect(article1.convert_units(article2)).to be false
end

xit 'returns false if unit becomes zero because of , symbol in unit format' do
# @todo broken after latest update as conversion logic changes?!
it 'returns false if unit becomes zero because of , symbol in unit format' do
article1 = build(:article, supplier: supplier, unit: '0,8kg', price: 2, unit_quantity: 1)
article2 = build(:article, supplier: supplier, unit: '0,9kg', price: 2, unit_quantity: 1)
expect(article1.convert_units(article2)).to be false
Expand Down

0 comments on commit fa9083d

Please sign in to comment.