Commit 5486976a86896c46ae4b557943a3ce6a75dfd516
1 parent
bd8b5b89
Exists in
master
and in
22 other branches
ActionItem70: restricting to top-level categories
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@539 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
5 additions
and
1 deletions
Show diff stats
app/models/environment.rb
@@ -23,7 +23,7 @@ class Environment < ActiveRecord::Base | @@ -23,7 +23,7 @@ class Environment < ActiveRecord::Base | ||
23 | has_many :profiles | 23 | has_many :profiles |
24 | 24 | ||
25 | has_many :categories | 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 | # Attributes | 29 | # Attributes |
test/unit/environment_test.rb
@@ -128,6 +128,10 @@ class EnvironmentTest < Test::Unit::TestCase | @@ -128,6 +128,10 @@ class EnvironmentTest < Test::Unit::TestCase | ||
128 | cat1 = env.categories.create(:name => 'category one', :display_color => 1) | 128 | cat1 = env.categories.create(:name => 'category one', :display_color => 1) |
129 | assert ! cat1.new_record? | 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 | cat2 = env.categories.create(:name => 'category two') | 135 | cat2 = env.categories.create(:name => 'category two') |
132 | assert !cat2.new_record? | 136 | assert !cat2.new_record? |
133 | 137 |