Commit 9a2bbd09154179bab2a04099216d783e87e41d78
1 parent
3d461d73
Exists in
master
and in
29 other branches
Returning 0 on price_description_percentage when price is 0
(ActionItem2273)
Showing
2 changed files
with
23 additions
and
0 deletions
Show diff stats
app/models/product.rb
test/unit/product_test.rb
... | ... | @@ -510,4 +510,26 @@ class ProductTest < Test::Unit::TestCase |
510 | 510 | assert_equal "50.00", product.formatted_value(:inputs_cost) |
511 | 511 | end |
512 | 512 | |
513 | + should 'return 0 on price_description_percentage by default' do | |
514 | + assert_equal 0, Product.new.price_description_percentage | |
515 | + end | |
516 | + | |
517 | + should 'return 0 on price_description_percentage if price is 0' do | |
518 | + product = fast_create(Product, :price => 0) | |
519 | + | |
520 | + assert_equal 0, product.price_description_percentage | |
521 | + end | |
522 | + | |
523 | + should 'return 0 on price_description_percentage if price is not defined' do | |
524 | + product = fast_create(Product) | |
525 | + | |
526 | + assert_equal 0, product.price_description_percentage | |
527 | + end | |
528 | + | |
529 | + should 'return 0 on price_description_percentage if total_production_cost is 0' do | |
530 | + product = fast_create(Product, :price => 50) | |
531 | + | |
532 | + assert_equal 0, product.price_description_percentage | |
533 | + end | |
534 | + | |
513 | 535 | end | ... | ... |