Commit 5e1647a9881ca6c81eddb631b47686402b163f36
1 parent
a522ab44
Exists in
master
and in
28 other branches
ActionItem517: not display categories without subcategory
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2147 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
32 additions
and
2 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -404,7 +404,7 @@ module ApplicationHelper |
| 404 | 404 | } |
| 405 | 405 | Effect.toggle( div, "slide", { link:link, div:div, afterFinish:end } ) |
| 406 | 406 | }') |
| 407 | - environment.top_level_categories.each do |toplevel| | |
| 407 | + environment.top_level_categories.select{|i| !i.children.empty?}.each do |toplevel| | |
| 408 | 408 | next unless object.accept_category?(toplevel) |
| 409 | 409 | # FIXME |
| 410 | 410 | ([toplevel] + toplevel.children_for_menu).each do |cat| | ... | ... |
test/unit/application_helper_test.rb
| ... | ... | @@ -120,10 +120,40 @@ class ApplicationHelperTest < Test::Unit::TestCase |
| 120 | 120 | assert_equal 'Profile Member', rolename_for(person, community) |
| 121 | 121 | end |
| 122 | 122 | |
| 123 | + should 'display categories' do | |
| 124 | + category = Category.create!(:name => 'parent category for testing', :environment_id => Environment.default) | |
| 125 | + child = Category.create!(:name => 'child category for testing', :environment => Environment.default, :display_in_menu => true, :parent => category) | |
| 126 | + owner = create_user('testuser').person | |
| 127 | + @article = owner.articles.create!(:name => 'ytest') | |
| 128 | + @article.add_category(category) | |
| 129 | + expects(:environment).returns(Environment.default) | |
| 130 | + result = select_categories(:article) | |
| 131 | + assert_match /parent category/, result | |
| 132 | + end | |
| 133 | + | |
| 134 | + should 'not display categories if has no child' do | |
| 135 | + category = Category.create!(:name => 'parent category for testing', :environment_id => Environment.default) | |
| 136 | + owner = create_user('testuser').person | |
| 137 | + @article = owner.articles.create!(:name => 'ytest') | |
| 138 | + @article.add_category(category) | |
| 139 | + expects(:environment).returns(Environment.default) | |
| 140 | + result = select_categories(:article) | |
| 141 | + assert_no_match /parent category/, result | |
| 142 | + end | |
| 143 | + | |
| 123 | 144 | protected |
| 124 | 145 | |
| 125 | - def content_tag(tag, content, options) | |
| 146 | + def content_tag(tag, content, options = {}) | |
| 126 | 147 | content.strip |
| 127 | 148 | end |
| 149 | + def javascript_tag(any) | |
| 150 | + '' | |
| 151 | + end | |
| 152 | + def link_to(label, action, options = {}) | |
| 153 | + label | |
| 154 | + end | |
| 155 | + def check_box_tag(name, value = 1, checked = false, options = {}) | |
| 156 | + name | |
| 157 | + end | |
| 128 | 158 | |
| 129 | 159 | end | ... | ... |