From f6b51288b1c8902caeb46e736502645979b384b2 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Sun, 22 Feb 2015 14:36:14 -0300 Subject: [PATCH] Fix unit tests --- app/models/input.rb | 3 ++- app/models/product.rb | 3 ++- test/unit/external_feed_test.rb | 6 ++++-- test/unit/product_test.rb | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/input.rb b/app/models/input.rb index a8809f2..a4938cc 100644 --- a/app/models/input.rb +++ b/app/models/input.rb @@ -1,6 +1,7 @@ class Input < ActiveRecord::Base - attr_accessible :product, :product_category, :product_category_id, :amount_used, :unit_id, :price_per_unit, :relevant_to_price + attr_accessible :product, :product_id, :product_category, :product_category_id, + :amount_used, :unit_id, :price_per_unit, :relevant_to_price, :is_from_solidarity_economy belongs_to :product belongs_to :product_category diff --git a/app/models/product.rb b/app/models/product.rb index d7a6c28..e9137ff 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -10,7 +10,8 @@ class Product < ActiveRecord::Base :display => %w[full map] } - attr_accessible :name, :product_category, :highlighted, :price, :enterprise, :image_builder, :description, :available, :qualifiers, :unit_id, :discount, :inputs, :qualifiers_list + attr_accessible :name, :product_category, :profile, :profile_id, :enterprise, + :highlighted, :price, :image_builder, :description, :available, :qualifiers, :unit_id, :discount, :inputs, :qualifiers_list def self.default_search_display 'full' diff --git a/test/unit/external_feed_test.rb b/test/unit/external_feed_test.rb index abcbce6..f6e299d 100644 --- a/test/unit/external_feed_test.rb +++ b/test/unit/external_feed_test.rb @@ -18,7 +18,8 @@ class ExternalFeedTest < ActiveSupport::TestCase end should 'not add same item twice' do - e = create(:external_feed) + blog = create_blog + e = create(:external_feed, blog: blog) assert e.add_item('Article title', 'http://orig.link.invalid', Time.now, 'Content for external post') assert !e.add_item('Article title', 'http://orig.link.invalid', Time.now, 'Content for external post') assert_equal 1, e.blog.posts.size @@ -52,7 +53,8 @@ class ExternalFeedTest < ActiveSupport::TestCase should 'add items to blog as posts' do handler = FeedHandler.new - e = create(:external_feed) + blog = create_blog + e = create(:external_feed, blog: blog) handler.process(e) assert_equal ["Last POST", "Second POST", "First POST"], e.blog.posts.map{|i| i.title} end diff --git a/test/unit/product_test.rb b/test/unit/product_test.rb index a4f2d0d..afd5de9 100644 --- a/test/unit/product_test.rb +++ b/test/unit/product_test.rb @@ -492,7 +492,7 @@ class ProductTest < ActiveSupport::TestCase :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false) assert_equal 25, prod.percentage_from_solidarity_economy.first - prod = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :enterprise_id => @profile.id) + prod = fast_create(Product, :name => 'test product1', :product_category_id => @product_category.id, :profile_id => @profile.id) prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true) prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, @@ -503,7 +503,7 @@ class ProductTest < ActiveSupport::TestCase :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false) assert_equal 75, prod.percentage_from_solidarity_economy.first - prod = fast_create(Product, :name => 'test product', :product_category_id => @product_category.id, :enterprise_id => @profile.id) + prod = fast_create(Product, :name => 'test product', :product_category_id => @product_category.id, :profile_id => @profile.id) prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true) assert_equal 100, prod.percentage_from_solidarity_economy.first -- libgit2 0.21.2