Commit 69526673c81c7792ddbfede97a8c2930631e5a23
1 parent
ddc33f23
Exists in
master
and in
28 other branches
ActionItem243: still fixing regressions when generating links to categories
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1600 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
23 additions
and
1 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -308,7 +308,7 @@ module ApplicationHelper |
| 308 | 308 | |
| 309 | 309 | def link_to_category(category) |
| 310 | 310 | return _('Uncategorized product') unless category |
| 311 | - link_to category.full_name, :controller => 'category', :action => 'view', :path => category.path.split('/') | |
| 311 | + link_to category.full_name, :controller => 'category', :action => 'view', :category_path => category.path.split('/') | |
| 312 | 312 | end |
| 313 | 313 | |
| 314 | 314 | def link_to_product(product) | ... | ... |
test/integration/categories_menu_test.rb
| ... | ... | @@ -13,4 +13,16 @@ class CategoriesMenuTest < ActionController::IntegrationTest |
| 13 | 13 | |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | + should 'display link to sub-categories' do | |
| 17 | + Category.delete_all | |
| 18 | + cat1 = Category.create!(:name => 'Food', :environment => Environment.default) | |
| 19 | + cat2 = Category.create!(:name => 'Vegetables', :environment => Environment.default, :parent => cat1) | |
| 20 | + | |
| 21 | + get '/cat/food' | |
| 22 | + | |
| 23 | + # there must be a link to the subcategory | |
| 24 | + assert_tag :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } | |
| 25 | + | |
| 26 | + end | |
| 27 | + | |
| 16 | 28 | end | ... | ... |
test/unit/application_helper_test.rb
| ... | ... | @@ -55,6 +55,16 @@ class ApplicationHelperTest < Test::Unit::TestCase |
| 55 | 55 | button('type', 'label', 'url', { :class => 'class1' }) |
| 56 | 56 | end |
| 57 | 57 | |
| 58 | + should 'generate correct link to category' do | |
| 59 | + cat = mock | |
| 60 | + cat.expects(:path).returns('my-category/my-subcatagory') | |
| 61 | + cat.expects(:full_name).returns('category name') | |
| 62 | + | |
| 63 | + result = "/cat/my-category/my-subcatagory" | |
| 64 | + expects(:link_to).with('category name', :controller => 'category', :action => 'view', :category_path => ['my-category', 'my-subcatagory']).returns(result) | |
| 65 | + assert_same result, link_to_category(cat) | |
| 66 | + end | |
| 67 | + | |
| 58 | 68 | protected |
| 59 | 69 | |
| 60 | 70 | def content_tag(tag, content, options) | ... | ... |