Commit 70ba11a8a4378bc75bc99ae77ec27d4b6a9be952
1 parent
0bf069f7
Exists in
master
and in
22 other branches
rails3: fix PriceDetail unit tests
Showing
2 changed files
with
6 additions
and
4 deletions
Show diff stats
app/models/price_detail.rb
test/unit/price_detail_test.rb
| ... | ... | @@ -39,7 +39,7 @@ class PriceDetailTest < ActiveSupport::TestCase |
| 39 | 39 | p = PriceDetail.new |
| 40 | 40 | p.valid? |
| 41 | 41 | |
| 42 | - assert p.errors.invalid?(:product_id) | |
| 42 | + assert p.errors[:product_id].any? | |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | 45 | should 'have production cost' do |
| ... | ... | @@ -54,7 +54,7 @@ class PriceDetailTest < ActiveSupport::TestCase |
| 54 | 54 | p = PriceDetail.new |
| 55 | 55 | p.valid? |
| 56 | 56 | |
| 57 | - assert p.errors.invalid?(:production_cost) | |
| 57 | + assert p.errors[:production_cost].any? | |
| 58 | 58 | end |
| 59 | 59 | |
| 60 | 60 | should 'th production cost be unique on scope of product' do |
| ... | ... | @@ -65,7 +65,7 @@ class PriceDetailTest < ActiveSupport::TestCase |
| 65 | 65 | detail2 = product.price_details.build(:production_cost_id => cost.id, :price => 10) |
| 66 | 66 | |
| 67 | 67 | detail2.valid? |
| 68 | - assert detail2.errors.invalid?(:production_cost_id) | |
| 68 | + assert detail2.errors[:production_cost_id].any? | |
| 69 | 69 | end |
| 70 | 70 | |
| 71 | 71 | should 'format values to float with 2 decimals' do |
| ... | ... | @@ -82,7 +82,7 @@ class PriceDetailTest < ActiveSupport::TestCase |
| 82 | 82 | product = fast_create(Product) |
| 83 | 83 | cost = fast_create(ProductionCost, :name => 'Energy',:owner_id => Environment.default.id, :owner_type => 'environment') |
| 84 | 84 | |
| 85 | - detail = product.price_details.create(:production_cost => cost, :price => 10) | |
| 85 | + detail = product.price_details.create(:production_cost_id => cost.id, :price => 10) | |
| 86 | 86 | |
| 87 | 87 | assert_equal 'Energy', detail.name |
| 88 | 88 | end | ... | ... |