diff --git a/app/models/region.rb b/app/models/region.rb index b5def92..c5a39de 100644 --- a/app/models/region.rb +++ b/app/models/region.rb @@ -1,3 +1,4 @@ # Region is a special type of category that is related to geographical issues. class Region < Category + has_and_belongs_to_many :validators, :class_name => Organization.name, :join_table => :region_validators end diff --git a/test/unit/region_test.rb b/test/unit/region_test.rb index e89ea04..2068cc3 100644 --- a/test/unit/region_test.rb +++ b/test/unit/region_test.rb @@ -5,4 +5,15 @@ class RegionTest < Test::Unit::TestCase should 'be a subclass of category' do assert_equal Category, Region.superclass end + + should 'have an array of validators' do + region = Region.new + assert_raise ActiveRecord::AssociationTypeMismatch do + region.validators = [ 1 ] + end + assert_nothing_raised do + region.validators = [ Organization.new ] + end + end + end -- libgit2 0.21.2