diff --git a/app/models/organisation.rb b/app/models/organisation.rb index dd2abf7..93167c6 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -13,6 +13,7 @@ class Organisation < ActiveRecord::Base has_ancestry validates_presence_of :registration_no, :census_url_no, :name, :status + validates_inclusion_of :status, in: STATES scope :open, where(status: 'O') diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 2eb8664..1ccec71 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -22,6 +22,10 @@ FactoryGirl.build(:organisation, status: nil).should_not be_valid end + it 'is invalid with a status of anything other than O or C' do + FactoryGirl.build(:organisation, status: 'P').should_not be_valid + end + it 'has many memberships' do FactoryGirl.create(:organisation).should have_many(:memberships) end