Commit 300d1dd29bbdfdfd110367da63067fa162b70fe1

Authored by Rodrigo Souto
1 parent 44a21bb9

Testing side bar category links and breadcrumb links

Showing 1 changed file with 37 additions and 0 deletions   Show diff stats
test/functional/catalog_controller_test.rb
... ... @@ -176,4 +176,41 @@ class CatalogControllerTest < ActionController::TestCase
176 176 assert_tag :tag => 'img', :attributes => { :class => 'star', :src => /star.png/ }
177 177 end
178 178  
  179 + should 'display categories and sub-categories link' do
  180 + pc1 = ProductCategory.create!(:name => "PC1", :environment => @enterprise.environment)
  181 + pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id)
  182 + pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id)
  183 + pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id)
  184 + p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id)
  185 + p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id)
  186 + p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id)
  187 + p4 = fast_create(Product, :product_category_id => pc4.id, :enterprise_id => @enterprise.id)
  188 +
  189 + get :index, :profile => @enterprise.identifier
  190 +
  191 + assert_tag :tag => 'a', :attributes => {:href => /level=#{pc1.id}/}
  192 + assert_tag :tag => 'a', :attributes => {:href => /level=#{pc2.id}/}
  193 + assert_tag :tag => 'a', :attributes => {:href => /level=#{pc3.id}/}
  194 + assert_no_tag :tag => 'a', :attributes => {:href => /level=#{pc4.id}/}
  195 + end
  196 +
  197 +
  198 + should 'display categories on breadcrumb' do
  199 + pc1 = ProductCategory.create!(:name => "PC1", :environment => @enterprise.environment)
  200 + pc2 = ProductCategory.create!(:name => "PC2", :environment => @enterprise.environment, :parent_id => pc1.id)
  201 + pc3 = ProductCategory.create!(:name => "PC3", :environment => @enterprise.environment, :parent_id => pc1.id)
  202 + pc4 = ProductCategory.create!(:name => "PC4", :environment => @enterprise.environment, :parent_id => pc2.id)
  203 + p1 = fast_create(Product, :product_category_id => pc1.id, :enterprise_id => @enterprise.id)
  204 + p2 = fast_create(Product, :product_category_id => pc2.id, :enterprise_id => @enterprise.id)
  205 + p3 = fast_create(Product, :product_category_id => pc3.id, :enterprise_id => @enterprise.id)
  206 + p4 = fast_create(Product, :product_category_id => pc4.id, :enterprise_id => @enterprise.id)
  207 +
  208 + get :index, :profile => @enterprise.identifier, :level => pc4.id
  209 +
  210 + assert_tag :tag => 'div', :attributes => {:id => 'breadcrumb'}, :descendant => {:tag => 'a', :attributes => {:href => /level=#{pc1.id}/}}
  211 + assert_tag :tag => 'div', :attributes => {:id => 'breadcrumb'}, :descendant => {:tag => 'a', :attributes => {:href => /level=#{pc2.id}/}}
  212 + assert_tag :tag => 'div', :attributes => {:id => 'breadcrumb'}, :descendant => {:tag => 'strong', :content => pc4.name}
  213 + assert_no_tag :tag => 'div', :attributes => {:id => 'breadcrumb'}, :descendant => {:tag => 'a', :attributes => {:href => /level=#{pc3.id}/}}
  214 + end
  215 +
179 216 end
... ...