aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-04-14 11:22:24 +0100
committerGareth Rees <gareth@mysociety.org>2014-04-14 11:22:24 +0100
commitf1fd69bff059cf0dbd4c0e543dbd9d9079ea3be8 (patch)
treeecf335fcdffe98ae5f04de6edda1ff8c628292a4 /spec/models
parent1062cea89abf8f7cd75355873ae0051c1d906582 (diff)
Add missing validation to PublicBody
There's a unique index on public_bodies url_name, so we should have a validation for that.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/public_body_spec.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index efd170013..c443f0d6a 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -205,6 +205,12 @@ describe PublicBody, " when saving" do
pb.first_letter.should == 'Å'
end
+ it "should not save if the url_name is already taken" do
+ existing = FactoryGirl.create(:public_body)
+ pb = PublicBody.new(existing.attributes)
+ pb.should have(1).errors_on(:url_name)
+ end
+
it "should save the name when renaming an existing public body" do
public_body = public_bodies(:geraldine_public_body)
public_body.name = "Mark's Public Body"