Commit 65e9fc03453a1e8507a1d86505873be07346eff0
Exists in
master
and in
29 other branches
Merge commit 'refs/merge-requests/185' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/185
Showing
3 changed files
with
17 additions
and
1 deletions
Show diff stats
app/models/input.rb
app/models/product.rb
... | ... | @@ -158,7 +158,7 @@ class Product < ActiveRecord::Base |
158 | 158 | |
159 | 159 | def inputs_cost |
160 | 160 | return 0 if inputs.empty? |
161 | - inputs.map(&:cost).inject { |sum,price| sum + price } | |
161 | + inputs.relevant_to_price.map(&:cost).inject { |sum,price| sum + price } | |
162 | 162 | end |
163 | 163 | |
164 | 164 | def total_production_cost | ... | ... |
test/unit/input_test.rb
... | ... | @@ -177,4 +177,18 @@ class InputTest < ActiveSupport::TestCase |
177 | 177 | assert_equal 0.00, input.cost |
178 | 178 | end |
179 | 179 | |
180 | + should 'list inputs relevants to price' do | |
181 | + product_category = fast_create(ProductCategory) | |
182 | + product = fast_create(Product, :product_category_id => product_category.id) | |
183 | + | |
184 | + i1 = Input.create!(:product => product, :product_category => product_category, :relevant_to_price => true) | |
185 | + | |
186 | + i2 = Input.create!(:product => product, :product_category => product_category, :relevant_to_price => false) | |
187 | + | |
188 | + i1.save! | |
189 | + i2.save! | |
190 | + assert_includes Input.relevant_to_price, i1 | |
191 | + assert_not_includes Input.relevant_to_price, i2 | |
192 | + end | |
193 | + | |
180 | 194 | end | ... | ... |