diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-09-26 12:11:31 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-09-26 12:11:31 +0100 |
commit | 9599df75c8d3b63b3952861d830500744f3f6635 (patch) | |
tree | 69b863b3772f87b725454e8ee528b67801deb17f | |
parent | dcdd84885f37d63a63b4521b8a585a524f0fcf16 (diff) |
Don't require a category description
Some existing themes don't use one for categories like 'misc' and that
seems reasonable usage. Add some specs for the things we do validate.
-rw-r--r-- | app/models/public_body_category.rb | 1 | ||||
-rw-r--r-- | spec/models/public_body_category_spec.rb | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/app/models/public_body_category.rb b/app/models/public_body_category.rb index 9e6783a05..e594d08e7 100644 --- a/app/models/public_body_category.rb +++ b/app/models/public_body_category.rb @@ -22,7 +22,6 @@ 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 # migrate from file-based public body categories diff --git a/spec/models/public_body_category_spec.rb b/spec/models/public_body_category_spec.rb index 3f6fbe5ec..f27c4838b 100644 --- a/spec/models/public_body_category_spec.rb +++ b/spec/models/public_body_category_spec.rb @@ -52,4 +52,24 @@ describe PublicBodyCategory do end end + + context 'when validating' do + + it 'should require a title' do + category = PublicBodyCategory.new + category.should_not be_valid + category.errors[:title].should == ["Title can't be blank"] + end + + it 'should require a category tag' do + category = PublicBodyCategory.new + category.should_not be_valid + category.errors[:category_tag].should == ["Tag can't be blank"] + end + + it 'should require a unique tag' do + existing = FactoryGirl.create(:public_body_category) + PublicBodyCategory.new(:email => existing.category_tag).should_not be_valid + end + end end |