Skip to content

Commit

Permalink
wip: failing test for out of range error
Browse files Browse the repository at this point in the history
  • Loading branch information
yksflip committed Oct 2, 2023
1 parent 55234b4 commit ab1fc34
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/models/article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
expect(new_unit_quantity).to eq 1.5
expect(new_price).to eq 120
end

it 'does not exceed limits when converting from 100ml to 0.1ml' do
article1 = build(:article, supplier: supplier, unit: '0.1ml', unit_quantity: 1)
article2 = build(:article, supplier: supplier, unit: '100ml', unit_quantity: 1.0)
_, new_unit_quantity = article1.convert_units(article2)
expect(new_unit_quantity.to_f).to eq 1000
end
end

it 'computes changed article attributes' do
Expand Down Expand Up @@ -161,5 +168,16 @@
article.update(order_number: nil)
expect(supplier.sync_all).to eq [[], [], []]
end

it 'does not exceed integer limits when converting from 0.1ml to 100ml' do # @todo this fails!!!
article.update!(unit: '0.1ml', unit_quantity: 1)
shared_article.update!(unit: '100ml', unit_quantity: 1.0)
puts "article: unit: #{article.unit}, unit_quantity: #{article.unit_quantity}"
puts "shared: unit: #{shared_article.unit}, unit_quantity: #{shared_article.unit_quantity}"
updated_article = supplier.sync_all[0].select { |s| s[0].id == article.id }.first[0]
puts "updated: unit: #{updated_article.unit}, unit_quantity: #{updated_article.unit_quantity}"
article.update(updated_article.attributes.reject { |k, _v| %w[id type].include?(k) })
expect(article.unit_quantity).to eq(shared_article.unit_quantity)
end
end
end

0 comments on commit ab1fc34

Please sign in to comment.