From d0eca4af17dcc83cb0e7e62d584cce27fc0af79e Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Sun, 15 Apr 2012 20:43:58 -0300 Subject: [PATCH] Fixes for ProductTest --- test/unit/product_test.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/unit/product_test.rb b/test/unit/product_test.rb index 7dd58c1..407668d 100644 --- a/test/unit/product_test.rb +++ b/test/unit/product_test.rb @@ -98,11 +98,15 @@ class ProductTest < ActiveSupport::TestCase end should 'be indexed by category full name' do - p = Product.create(:name => 'a test product', :product_category => @product_category, :enterprise_id => @profile.id) - p.stubs(:category_full_name).returns('interesting category') - p.save! + parent_cat = fast_create(ProductCategory, :name => 'Parent') + prod_cat = fast_create(ProductCategory, :name => 'Category1', :parent_id => parent_cat.id) + prod_cat2 = fast_create(ProductCategory, :name => 'Category2') + p = Product.create(:name => 'a test', :product_category => prod_cat, :enterprise_id => @profile.id) + p2 = Product.create(:name => 'another test', :product_category => prod_cat2, :enterprise_id => @profile.id) - assert_includes Product.find_by_contents('interesting')[:results], p + r = Product.find_by_contents('Parent')[:results].docs + assert_includes r, p + assert_not_includes r, p2 end should 'have same lat and lng of its enterprise' do @@ -327,7 +331,7 @@ class ProductTest < ActiveSupport::TestCase should 'index by schema name when database is postgresql' do uses_postgresql 'schema_one' p1 = Product.create!(:name => 'some thing', :product_category => @product_category, :enterprise_id => @profile.id) - assert_equal Product.find_by_contents('thing')[:results], [p1] + assert_equal [p1], Product.find_by_contents('thing')[:results].docs uses_postgresql 'schema_two' p2 = Product.create!(:name => 'another thing', :product_category => @product_category, :enterprise_id => @profile.id) assert_not_includes Product.find_by_contents('thing')[:results], p1 @@ -341,7 +345,7 @@ class ProductTest < ActiveSupport::TestCase should 'not index by schema name when database is not postgresql' do uses_sqlite p1 = Product.create!(:name => 'some thing', :product_category => @product_category, :enterprise_id => @profile.id) - assert_equal Product.find_by_contents('thing')[:results], [p1] + assert_equal [p1], Product.find_by_contents('thing')[:results].docs p2 = Product.create!(:name => 'another thing', :product_category => @product_category, :enterprise_id => @profile.id) assert_includes Product.find_by_contents('thing')[:results], p1 assert_includes Product.find_by_contents('thing')[:results], p2 -- libgit2 0.21.2