Commit dd2b608125df198ebb1819c8e3625f5294789b35
1 parent
d81e89da
Exists in
master
and in
29 other branches
rails3: fix catalog tests
Showing
2 changed files
with
10 additions
and
10 deletions
Show diff stats
app/helpers/catalog_helper.rb
@@ -9,7 +9,7 @@ module CatalogHelper | @@ -9,7 +9,7 @@ module CatalogHelper | ||
9 | @categories = ProductCategory.on_level(params[:level]).order(:name) | 9 | @categories = ProductCategory.on_level(params[:level]).order(:name) |
10 | end | 10 | end |
11 | 11 | ||
12 | - @products = profile.products.from_category(@category).paginate(:order => 'available desc, highlighted desc, name asc', :per_page => 9, :page => options[:page]) | 12 | + @products = profile.products.from_category(@category).reorder('available desc, highlighted desc, name asc').paginate(:per_page => 9, :page => options[:page]) |
13 | end | 13 | end |
14 | 14 | ||
15 | def breadcrumb(category) | 15 | def breadcrumb(category) |
@@ -33,7 +33,7 @@ module CatalogHelper | @@ -33,7 +33,7 @@ module CatalogHelper | ||
33 | category.children.order(:name).each do |sub_category| | 33 | category.children.order(:name).each do |sub_category| |
34 | sub_categories << category_link(sub_category, true) | 34 | sub_categories << category_link(sub_category, true) |
35 | end | 35 | end |
36 | - content_tag('ul', sub_categories) if sub_categories.size > 1 | 36 | + content_tag('ul', sub_categories.join) if sub_categories.size > 1 |
37 | end | 37 | end |
38 | 38 | ||
39 | end | 39 | end |
test/functional/catalog_controller_test.rb
@@ -122,10 +122,10 @@ class CatalogControllerTest < ActionController::TestCase | @@ -122,10 +122,10 @@ class CatalogControllerTest < ActionController::TestCase | ||
122 | end | 122 | end |
123 | 123 | ||
124 | should 'filter products based on level selected' do | 124 | should 'filter products based on level selected' do |
125 | - pc1 = create(ProductCategory, :name => "PC1", :environment => @enterprise.environment) | ||
126 | - pc2 = create(ProductCategory, :name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
127 | - pc3 = create(ProductCategory, :name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
128 | - pc4 = create(ProductCategory, :name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | 125 | + pc1 = ProductCategory.create!(:name => "PC1", :environment => @enterprise.environment) |
126 | + pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
127 | + pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
128 | + pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | ||
129 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) | 129 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
130 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) | 130 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
131 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) | 131 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |
@@ -171,10 +171,10 @@ class CatalogControllerTest < ActionController::TestCase | @@ -171,10 +171,10 @@ class CatalogControllerTest < ActionController::TestCase | ||
171 | end | 171 | end |
172 | 172 | ||
173 | should 'display categories and sub-categories link' do | 173 | should 'display categories and sub-categories link' do |
174 | - pc1 = create(ProductCategory, :name => "PC1", :environment => @enterprise.environment) | ||
175 | - pc2 = create(ProductCategory, :name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
176 | - pc3 = create(ProductCategory, :name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
177 | - pc4 = create(ProductCategory, :name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | 174 | + pc1 = ProductCategory.create!(:name => "PC1", :environment => @enterprise.environment) |
175 | + pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
176 | + pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id) | ||
177 | + pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id) | ||
178 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) | 178 | p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id) |
179 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) | 179 | p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id) |
180 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) | 180 | p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id) |