From 5486976a86896c46ae4b557943a3ce6a75dfd516 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Tue, 25 Sep 2007 18:13:56 +0000 Subject: [PATCH] ActionItem70: restricting to top-level categories --- app/models/environment.rb | 2 +- test/unit/environment_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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