Commit f2284832d8fe7aa7c47a2f2a46fdfd6f4072ff1d
1 parent
65e9fc03
Exists in
master
and in
29 other branches
Only list inputs relevant to price on price composition
(ActionItem2366)
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
app/views/catalog/index.rhtml
@@ -56,7 +56,7 @@ | @@ -56,7 +56,7 @@ | ||
56 | <div> | 56 | <div> |
57 | <div class="arrow"></div> | 57 | <div class="arrow"></div> |
58 | <div class="content" id="product-price-composition"> | 58 | <div class="content" id="product-price-composition"> |
59 | - <% product.inputs.each do |i| %> | 59 | + <% product.inputs.relevant_to_price.each do |i| %> |
60 | <div class="search-product-input-dots-to-price"> | 60 | <div class="search-product-input-dots-to-price"> |
61 | <div class="search-product-input-name"><%= i.product_category.name %></div> | 61 | <div class="search-product-input-name"><%= i.product_category.name %></div> |
62 | <%= price_span i.cost, :class => 'search-product-input-price' %> | 62 | <%= price_span i.cost, :class => 'search-product-input-price' %> |
test/unit/product_test.rb
@@ -381,6 +381,15 @@ class ProductTest < ActiveSupport::TestCase | @@ -381,6 +381,15 @@ class ProductTest < ActiveSupport::TestCase | ||
381 | assert_equal 50.0, product.inputs_cost | 381 | assert_equal 50.0, product.inputs_cost |
382 | end | 382 | end |
383 | 383 | ||
384 | + should 'return total value only of inputs relevant to price' do | ||
385 | + product = fast_create(Product) | ||
386 | + first_relevant = fast_create(Input, :product_id => product.id, :product_category_id => fast_create(ProductCategory).id, :price_per_unit => 20.0, :amount_used => 2) | ||
387 | + second_relevant = fast_create(Input, :product_id => product.id, :product_category_id => fast_create(ProductCategory).id, :price_per_unit => 10.0, :amount_used => 1) | ||
388 | + not_relevant = fast_create(Input, :product_id => product.id, :product_category_id => fast_create(ProductCategory).id, :price_per_unit => 10.0, :amount_used => 1, :relevant_to_price => false) | ||
389 | + | ||
390 | + assert_equal 50.0, product.inputs_cost | ||
391 | + end | ||
392 | + | ||
384 | should 'return 0 on total value of inputs if has no input' do | 393 | should 'return 0 on total value of inputs if has no input' do |
385 | product = fast_create(Product) | 394 | product = fast_create(Product) |
386 | 395 | ||
@@ -750,6 +759,8 @@ class ProductTest < ActiveSupport::TestCase | @@ -750,6 +759,8 @@ class ProductTest < ActiveSupport::TestCase | ||
750 | end | 759 | end |
751 | 760 | ||
752 | should 'return more recent products' do | 761 | should 'return more recent products' do |
762 | + Product.destroy_all | ||
763 | + | ||
753 | prod1 = Product.create!(:name => 'Damaged LP', :enterprise_id => @profile.id, :product_category_id => @product_category.id) | 764 | prod1 = Product.create!(:name => 'Damaged LP', :enterprise_id => @profile.id, :product_category_id => @product_category.id) |
754 | prod2 = Product.create!(:name => 'Damaged CD', :enterprise_id => @profile.id, :product_category_id => @product_category.id) | 765 | prod2 = Product.create!(:name => 'Damaged CD', :enterprise_id => @profile.id, :product_category_id => @product_category.id) |
755 | prod3 = Product.create!(:name => 'Damaged DVD', :enterprise_id => @profile.id, :product_category_id => @product_category.id) | 766 | prod3 = Product.create!(:name => 'Damaged DVD', :enterprise_id => @profile.id, :product_category_id => @product_category.id) |