diff options
author | Mark Longair <mhl@pobox.com> | 2014-01-03 16:35:12 +0000 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2014-01-09 17:54:47 +0000 |
commit | 68c192aa36e2a091fb12b8b227ba2fa387ba6ab5 (patch) | |
tree | 76cc7aa464d12ba329898462b84df3f7131e38ba /spec/models | |
parent | 1555a395957f6d1208980509efb9bc989443a063 (diff) |
Add further tests for creation of the internal admin body
The internal admin body should be created automatically if it
doesn't exist on calls to PublicBody.internal_admin_body; we've
seen errors (#1001) where this fails after the default locale
changes. (Although these tests don't actually replicate that
problem.)
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/public_body_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index ed24ced52..dc09bdfa6 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -300,6 +300,37 @@ describe PublicBody, "when searching" do end end +describe PublicBody, "when asked for the internal_admin_body" do + before(:each) do + # Make sure that there's no internal_admin_body before each of + # these tests: + PublicBody.connection.delete("DELETE FROM public_bodies WHERE url_name = 'internal_admin_body'") + PublicBody.connection.delete("DELETE FROM public_body_translations WHERE url_name = 'internal_admin_body'") + end + + it "should create the internal_admin_body if it didn't exist" do + iab = PublicBody.internal_admin_body + iab.should_not be_nil + end + + it "should find the internal_admin_body even if the default locale has changed since it was created" do + with_default_locale("en") do + I18n.with_locale(:en) do + iab = PublicBody.internal_admin_body + iab.should_not be_nil + end + end + with_default_locale("es") do + I18n.with_locale(:es) do + iab = PublicBody.internal_admin_body + iab.should_not be_nil + end + end + end + +end + + describe PublicBody, " when dealing public body locales" do it "shouldn't fail if it internal_admin_body was created in a locale other than the default" do # first time, do it with the non-default locale |