Commit e8ccb188525f1ceca6ccf844501b19032265611a
1 parent
dc814725
Exists in
master
and in
22 other branches
ActionItem252: updating tests and fixing helper
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1976 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
13 additions
and
13 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -503,7 +503,7 @@ module ApplicationHelper | @@ -503,7 +503,7 @@ module ApplicationHelper | ||
503 | environment.top_level_categories.each do |toplevel| | 503 | environment.top_level_categories.each do |toplevel| |
504 | next if toplevel.is_a?(ProductCategory) | 504 | next if toplevel.is_a?(ProductCategory) |
505 | # FIXME | 505 | # FIXME |
506 | - toplevel.children_for_menu do |cat| | 506 | + ([toplevel] + toplevel.children_for_menu).each do |cat| |
507 | if cat.top_level? | 507 | if cat.top_level? |
508 | result << '<div class="categorie_box">' | 508 | result << '<div class="categorie_box">' |
509 | result << icon_button( :down, _('open'), '#', :onclick => 'open_close_cat(this); return false' ) | 509 | result << icon_button( :down, _('open'), '#', :onclick => 'open_close_cat(this); return false' ) |
test/functional/cms_controller_test.rb
@@ -236,10 +236,10 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -236,10 +236,10 @@ class CmsControllerTest < Test::Unit::TestCase | ||
236 | 236 | ||
237 | should 'display checkboxes for selecting categories' do | 237 | should 'display checkboxes for selecting categories' do |
238 | env = Environment.default | 238 | env = Environment.default |
239 | - top = env.categories.build(:name => 'Top-Level category'); top.save! | ||
240 | - c1 = env.categories.build(:name => "Test category 1", :parent_id => top.id); c1.save! | ||
241 | - c2 = env.categories.build(:name => "Test category 2", :parent_id => top.id); c2.save! | ||
242 | - c3 = env.categories.build(:name => "Test Category 3", :parent_id => top.id); c3.save! | 239 | + top = env.categories.build(:display_in_menu => true, :name => 'Top-Level category'); top.save! |
240 | + c1 = env.categories.build(:display_in_menu => true, :name => "Test category 1", :parent_id => top.id); c1.save! | ||
241 | + c2 = env.categories.build(:display_in_menu => true, :name => "Test category 2", :parent_id => top.id); c2.save! | ||
242 | + c3 = env.categories.build(:display_in_menu => true, :name => "Test Category 3", :parent_id => top.id); c3.save! | ||
243 | 243 | ||
244 | article = Article.new(:name => 'test') | 244 | article = Article.new(:name => 'test') |
245 | article.profile = profile | 245 | article.profile = profile |
test/functional/profile_editor_controller_test.rb
@@ -70,13 +70,13 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | @@ -70,13 +70,13 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | ||
70 | end | 70 | end |
71 | 71 | ||
72 | should 'display categories to choose to associate profile' do | 72 | should 'display categories to choose to associate profile' do |
73 | - cat1 = Environment.default.categories.build(:name => 'top category'); cat1.save! | ||
74 | - cat2 = Environment.default.categories.build(:name => 'sub category', :parent => cat1); cat2.save! | 73 | + cat1 = Environment.default.categories.build(:display_in_menu => true, :name => 'top category'); cat1.save! |
74 | + cat2 = Environment.default.categories.build(:display_in_menu => true, :name => 'sub category', :parent => cat1); cat2.save! | ||
75 | person = create_user('test_user').person | 75 | person = create_user('test_user').person |
76 | get :edit, :profile => 'test_user' | 76 | get :edit, :profile => 'test_user' |
77 | assert_response :success | 77 | assert_response :success |
78 | assert_template 'edit' | 78 | assert_template 'edit' |
79 | - assert_tag :tag => 'input', :attributes => {:name => 'profile_data[category_ids][]'} | 79 | + assert_tag :tag => 'input', :attributes => {:name => 'profile_data[category_ids][]', :value => cat2.id} |
80 | end | 80 | end |
81 | 81 | ||
82 | should 'save categorization of profile' do | 82 | should 'save categorization of profile' do |
@@ -253,11 +253,11 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | @@ -253,11 +253,11 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | ||
253 | end | 253 | end |
254 | 254 | ||
255 | should 'show categories field on edit profile' do | 255 | should 'show categories field on edit profile' do |
256 | - cat1 = Environment.default.categories.create!(:name => 'top category') | ||
257 | - cat2 = Environment.default.categories.create!(:name => 'sub category', :parent => cat1) | 256 | + cat1 = Environment.default.categories.create!(:display_in_menu => true, :name => 'top category') |
257 | + cat2 = Environment.default.categories.create!(:display_in_menu => true, :name => 'sub category', :parent => cat1) | ||
258 | person = create_user('testuser').person | 258 | person = create_user('testuser').person |
259 | get :edit, :profile => 'testuser' | 259 | get :edit, :profile => 'testuser' |
260 | - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'profile_data[category_ids][]' } | 260 | + assert_tag :tag => 'input', :attributes => { :type => 'checkbox', :name => 'profile_data[category_ids][]', :value => cat2.id} |
261 | end | 261 | end |
262 | 262 | ||
263 | should 'render edit template' do | 263 | should 'render edit template' do |
test/integration/categories_menu_test.rb
@@ -4,8 +4,8 @@ class CategoriesMenuTest < ActionController::IntegrationTest | @@ -4,8 +4,8 @@ class CategoriesMenuTest < ActionController::IntegrationTest | ||
4 | 4 | ||
5 | def setup | 5 | def setup |
6 | Category.delete_all | 6 | Category.delete_all |
7 | - @cat1 = Category.create!(:name => 'Food', :environment => Environment.default, :display_color => 1) | ||
8 | - @cat2 = Category.create!(:name => 'Vegetables', :environment => Environment.default, :parent => @cat1) | 7 | + @cat1 = Category.create!(:display_in_menu => true, :name => 'Food', :environment => Environment.default, :display_color => 1) |
8 | + @cat2 = Category.create!(:display_in_menu => true, :name => 'Vegetables', :environment => Environment.default, :parent => @cat1) | ||
9 | 9 | ||
10 | # all categories must be shown for these tests | 10 | # all categories must be shown for these tests |
11 | Category.any_instance.stubs(:display_in_menu?).returns(true) | 11 | Category.any_instance.stubs(:display_in_menu?).returns(true) |