aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-12-01 12:16:52 +0000
committerLouise Crow <louise.crow@gmail.com>2014-12-01 12:16:52 +0000
commitd40aa95b320ded8f43231490acb11f109cbe7985 (patch)
treefa7c1e0c035ad3ab90c581f3dc00137958780767
parent6a25a188fd367a58f65edac7ec67882a83429b6d (diff)
Validate the presence of the description.
It's required in [PublicBody#type_of_authority]( https://github.com/mysociety/alaveteli/blob/rails-3-develop/app/models/public_body.rb#L343-L347)
-rw-r--r--app/models/public_body_category.rb1
-rw-r--r--spec/models/public_body_category_spec.rb6
2 files changed, 7 insertions, 0 deletions
diff --git a/app/models/public_body_category.rb b/app/models/public_body_category.rb
index 8eaecd596..2dfdde41a 100644
--- a/app/models/public_body_category.rb
+++ b/app/models/public_body_category.rb
@@ -22,6 +22,7 @@ class PublicBodyCategory < ActiveRecord::Base
validates_uniqueness_of :category_tag, :message => N_('Tag is already taken')
validates_presence_of :title, :message => N_("Title can't be blank")
validates_presence_of :category_tag, :message => N_("Tag can't be blank")
+ validates_presence_of :description, :message => N_("Description can't be blank")
def self.get
locale = I18n.locale.to_s || default_locale.to_s || ""
diff --git a/spec/models/public_body_category_spec.rb b/spec/models/public_body_category_spec.rb
index 2d39a7376..c185a3169 100644
--- a/spec/models/public_body_category_spec.rb
+++ b/spec/models/public_body_category_spec.rb
@@ -61,5 +61,11 @@ describe PublicBodyCategory do
existing = FactoryGirl.create(:public_body_category)
PublicBodyCategory.new(:email => existing.category_tag).should_not be_valid
end
+
+ it 'should require a description' do
+ category = PublicBodyCategory.new
+ category.should_not be_valid
+ category.errors[:description].should == ["Description can't be blank"]
+ end
end
end