Commit f6b51288b1c8902caeb46e736502645979b384b2
1 parent
bf4da137
Exists in
master
and in
22 other branches
Fix unit tests
Showing
4 changed files
with
10 additions
and
6 deletions
Show diff stats
app/models/input.rb
| 1 | class Input < ActiveRecord::Base | 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 | belongs_to :product | 6 | belongs_to :product |
| 6 | belongs_to :product_category | 7 | belongs_to :product_category |
app/models/product.rb
| @@ -10,7 +10,8 @@ class Product < ActiveRecord::Base | @@ -10,7 +10,8 @@ class Product < ActiveRecord::Base | ||
| 10 | :display => %w[full map] | 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 | def self.default_search_display | 16 | def self.default_search_display |
| 16 | 'full' | 17 | 'full' |
test/unit/external_feed_test.rb
| @@ -18,7 +18,8 @@ class ExternalFeedTest < ActiveSupport::TestCase | @@ -18,7 +18,8 @@ class ExternalFeedTest < ActiveSupport::TestCase | ||
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | should 'not add same item twice' do | 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 | assert e.add_item('Article title', 'http://orig.link.invalid', Time.now, 'Content for external post') | 23 | assert e.add_item('Article title', 'http://orig.link.invalid', Time.now, 'Content for external post') |
| 23 | assert !e.add_item('Article title', 'http://orig.link.invalid', Time.now, 'Content for external post') | 24 | assert !e.add_item('Article title', 'http://orig.link.invalid', Time.now, 'Content for external post') |
| 24 | assert_equal 1, e.blog.posts.size | 25 | assert_equal 1, e.blog.posts.size |
| @@ -52,7 +53,8 @@ class ExternalFeedTest < ActiveSupport::TestCase | @@ -52,7 +53,8 @@ class ExternalFeedTest < ActiveSupport::TestCase | ||
| 52 | 53 | ||
| 53 | should 'add items to blog as posts' do | 54 | should 'add items to blog as posts' do |
| 54 | handler = FeedHandler.new | 55 | handler = FeedHandler.new |
| 55 | - e = create(:external_feed) | 56 | + blog = create_blog |
| 57 | + e = create(:external_feed, blog: blog) | ||
| 56 | handler.process(e) | 58 | handler.process(e) |
| 57 | assert_equal ["Last POST", "Second POST", "First POST"], e.blog.posts.map{|i| i.title} | 59 | assert_equal ["Last POST", "Second POST", "First POST"], e.blog.posts.map{|i| i.title} |
| 58 | end | 60 | end |
test/unit/product_test.rb
| @@ -492,7 +492,7 @@ class ProductTest < ActiveSupport::TestCase | @@ -492,7 +492,7 @@ class ProductTest < ActiveSupport::TestCase | ||
| 492 | :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false) | 492 | :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false) |
| 493 | assert_equal 25, prod.percentage_from_solidarity_economy.first | 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 | prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, | 496 | prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, |
| 497 | :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true) | 497 | :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true) |
| 498 | prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, | 498 | prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, |
| @@ -503,7 +503,7 @@ class ProductTest < ActiveSupport::TestCase | @@ -503,7 +503,7 @@ class ProductTest < ActiveSupport::TestCase | ||
| 503 | :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false) | 503 | :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => false) |
| 504 | assert_equal 75, prod.percentage_from_solidarity_economy.first | 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 | prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, | 507 | prod.inputs.create!(:product_id => prod.id, :product_category_id => @product_category.id, |
| 508 | :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true) | 508 | :amount_used => 10, :price_per_unit => 10, :is_from_solidarity_economy => true) |
| 509 | assert_equal 100, prod.percentage_from_solidarity_economy.first | 509 | assert_equal 100, prod.percentage_from_solidarity_economy.first |