Commit 5486976a86896c46ae4b557943a3ce6a75dfd516

Authored by AntonioTerceiro
1 parent bd8b5b89

ActionItem70: restricting to top-level categories



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@539 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/environment.rb
... ... @@ -23,7 +23,7 @@ class Environment < ActiveRecord::Base
23 23 has_many :profiles
24 24  
25 25 has_many :categories
26   - has_many :display_categories, :class_name => 'Category', :conditions => 'display_color is not null ', :order => 'display_color'
  26 + has_many :display_categories, :class_name => 'Category', :conditions => 'display_color is not null and parent_id is null', :order => 'display_color'
27 27  
28 28 # #################################################
29 29 # Attributes
... ...
test/unit/environment_test.rb
... ... @@ -128,6 +128,10 @@ class EnvironmentTest < Test::Unit::TestCase
128 128 cat1 = env.categories.create(:name => 'category one', :display_color => 1)
129 129 assert ! cat1.new_record?
130 130  
  131 + # subcategories should be ignored
  132 + subcat1 = env.categories.create(:name => 'subcategory one', :parent_id => cat1.id)
  133 + assert ! subcat1.new_record?
  134 +
131 135 cat2 = env.categories.create(:name => 'category two')
132 136 assert !cat2.new_record?
133 137  
... ...