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,7 +39,7 @@ class PriceDetailTest < ActiveSupport::TestCase | ||
39 | p = PriceDetail.new | 39 | p = PriceDetail.new |
40 | p.valid? | 40 | p.valid? |
41 | 41 | ||
42 | - assert p.errors.invalid?(:product_id) | 42 | + assert p.errors[:product_id].any? |
43 | end | 43 | end |
44 | 44 | ||
45 | should 'have production cost' do | 45 | should 'have production cost' do |
@@ -54,7 +54,7 @@ class PriceDetailTest < ActiveSupport::TestCase | @@ -54,7 +54,7 @@ class PriceDetailTest < ActiveSupport::TestCase | ||
54 | p = PriceDetail.new | 54 | p = PriceDetail.new |
55 | p.valid? | 55 | p.valid? |
56 | 56 | ||
57 | - assert p.errors.invalid?(:production_cost) | 57 | + assert p.errors[:production_cost].any? |
58 | end | 58 | end |
59 | 59 | ||
60 | should 'th production cost be unique on scope of product' do | 60 | should 'th production cost be unique on scope of product' do |
@@ -65,7 +65,7 @@ class PriceDetailTest < ActiveSupport::TestCase | @@ -65,7 +65,7 @@ class PriceDetailTest < ActiveSupport::TestCase | ||
65 | detail2 = product.price_details.build(:production_cost_id => cost.id, :price => 10) | 65 | detail2 = product.price_details.build(:production_cost_id => cost.id, :price => 10) |
66 | 66 | ||
67 | detail2.valid? | 67 | detail2.valid? |
68 | - assert detail2.errors.invalid?(:production_cost_id) | 68 | + assert detail2.errors[:production_cost_id].any? |
69 | end | 69 | end |
70 | 70 | ||
71 | should 'format values to float with 2 decimals' do | 71 | should 'format values to float with 2 decimals' do |
@@ -82,7 +82,7 @@ class PriceDetailTest < ActiveSupport::TestCase | @@ -82,7 +82,7 @@ class PriceDetailTest < ActiveSupport::TestCase | ||
82 | product = fast_create(Product) | 82 | product = fast_create(Product) |
83 | cost = fast_create(ProductionCost, :name => 'Energy',:owner_id => Environment.default.id, :owner_type => 'environment') | 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 | assert_equal 'Energy', detail.name | 87 | assert_equal 'Energy', detail.name |
88 | end | 88 | end |