Skip to content

Commit

Permalink
Adds validation of status to model and associated unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Campbell committed Jul 25, 2013
1 parent 642d959 commit af33c89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/organisation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
4 changes: 4 additions & 0 deletions spec/models/organisation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit af33c89

Please sign in to comment.