diff --git a/app/models/environment.rb b/app/models/environment.rb index 4cf1199..d2a6643 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -23,7 +23,7 @@ class Environment < ActiveRecord::Base has_many :profiles has_many :categories - has_many :display_categories, :class_name => 'Category', :conditions => 'display_color is not null ', :order => 'display_color' + has_many :display_categories, :class_name => 'Category', :conditions => 'display_color is not null and parent_id is null', :order => 'display_color' # ################################################# # Attributes diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index 42cc631..8933987 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -128,6 +128,10 @@ class EnvironmentTest < Test::Unit::TestCase cat1 = env.categories.create(:name => 'category one', :display_color => 1) assert ! cat1.new_record? + # subcategories should be ignored + subcat1 = env.categories.create(:name => 'subcategory one', :parent_id => cat1.id) + assert ! subcat1.new_record? + cat2 = env.categories.create(:name => 'category two') assert !cat2.new_record? -- libgit2 0.21.2