Commit f6b51288b1c8902caeb46e736502645979b384b2

Authored by Braulio Bhavamitra
1 parent bf4da137

Fix unit tests

app/models/input.rb
1 1 class Input < ActiveRecord::Base
2 2  
3   - attr_accessible :product, :product_category, :product_category_id, :amount_used, :unit_id, :price_per_unit, :relevant_to_price
  3 + attr_accessible :product, :product_id, :product_category, :product_category_id,
  4 + :amount_used, :unit_id, :price_per_unit, :relevant_to_price, :is_from_solidarity_economy
4 5  
5 6 belongs_to :product
6 7 belongs_to :product_category
... ...
app/models/product.rb
... ... @@ -10,7 +10,8 @@ class Product &lt; ActiveRecord::Base
10 10 :display => %w[full map]
11 11 }
12 12  
13   - attr_accessible :name, :product_category, :highlighted, :price, :enterprise, :image_builder, :description, :available, :qualifiers, :unit_id, :discount, :inputs, :qualifiers_list
  13 + attr_accessible :name, :product_category, :profile, :profile_id, :enterprise,
  14 + :highlighted, :price, :image_builder, :description, :available, :qualifiers, :unit_id, :discount, :inputs, :qualifiers_list
14 15  
15 16 def self.default_search_display
16 17 'full'
... ...
test/unit/external_feed_test.rb
... ... @@ -18,7 +18,8 @@ class ExternalFeedTest &lt; ActiveSupport::TestCase
18 18 end
19 19  
20 20 should 'not add same item twice' do
21   - e = create(:external_feed)
  21 + blog = create_blog
  22 + e = create(:external_feed, blog: blog)
22 23 assert e.add_item('Article title', 'http://orig.link.invalid', Time.now, 'Content for external post')
23 24 assert !e.add_item('Article title', 'http://orig.link.invalid', Time.now, 'Content for external post')
24 25 assert_equal 1, e.blog.posts.size
... ... @@ -52,7 +53,8 @@ class ExternalFeedTest &lt; ActiveSupport::TestCase
52 53  
53 54 should 'add items to blog as posts' do
54 55 handler = FeedHandler.new
55   - e = create(:external_feed)
  56 + blog = create_blog
  57 + e = create(:external_feed, blog: blog)
56 58 handler.process(e)
57 59 assert_equal ["Last POST", "Second POST", "First POST"], e.blog.posts.map{|i| i.title}
58 60 end
... ...
test/unit/product_test.rb
... ... @@ -492,7 +492,7 @@ class ProductTest &lt; ActiveSupport::TestCase
492 492 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false)
493 493 assert_equal 25, prod.percentage_from_solidarity_economy.first
494 494  
495   - prod = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :enterprise_id => @profile.id)
  495 + prod = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :profile_id => @profile.id)
496 496 prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id,
497 497 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true)
498 498 prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id,
... ... @@ -503,7 +503,7 @@ class ProductTest &lt; ActiveSupport::TestCase
503 503 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false)
504 504 assert_equal 75, prod.percentage_from_solidarity_economy.first
505 505  
506   - prod = fast_create(Product, :name => 'test product', :product_category_id => @product_category.id, :enterprise_id => @profile.id)
  506 + prod = fast_create(Product, :name => 'test product', :product_category_id => @product_category.id, :profile_id => @profile.id)
507 507 prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id,
508 508 :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true)
509 509 assert_equal 100, prod.percentage_from_solidarity_economy.first
... ...