From acf45dc90a81e3da6a7e6cbf244ccdcab2bc88d9 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 11 Oct 2007 18:37:12 +0000 Subject: [PATCH] ActionItem102: adding relationship with regions to environment --- app/models/environment.rb | 2 ++ test/unit/environment_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/app/models/environment.rb b/app/models/environment.rb index 0f6e45c..4aa51bb 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -25,6 +25,8 @@ class Environment < ActiveRecord::Base has_many :categories has_many :display_categories, :class_name => 'Category', :conditions => 'display_color is not null and parent_id is null', :order => 'display_color' + has_many :regions + has_many :role_assignments, :as => 'resource' def superior_intances [self, nil] diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index e9a5f36..27e67b9 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -121,6 +121,17 @@ class EnvironmentTest < Test::Unit::TestCase assert !env.display_categories.include?(cat2) end + should 'have regions' do + env = Environment.create!(:name => 'a test environment') + assert_kind_of Array, env.regions + assert_raise ActiveRecord::AssociationTypeMismatch do + env.regions << 1 + end + assert_nothing_raised do + env.regions << Region.new + end + end + should 'have a contact email' do env = Environment.new assert_nil env.contact_email -- libgit2 0.21.2