aboutsummaryrefslogtreecommitdiffstats
path: root/spec/helpers
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-01-22 15:05:11 +0000
committerGareth Rees <gareth@mysociety.org>2015-02-03 16:24:01 +0000
commit40dd8b05787e665d3d5534acfb6208e236240698 (patch)
treee54abc92d8ca93312cb4e30f79d93fdb67efecc6 /spec/helpers
parent7c7b008a0f2c6937b6bf02ab26134bb90aae19ee (diff)
Build available locales in the controller
Removes logic from views and obsoletes AdminPublicBodyHelper#public_body_form_object
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/admin_public_body_helper_spec.rb79
1 files changed, 0 insertions, 79 deletions
diff --git a/spec/helpers/admin_public_body_helper_spec.rb b/spec/helpers/admin_public_body_helper_spec.rb
deleted file mode 100644
index c135ef348..000000000
--- a/spec/helpers/admin_public_body_helper_spec.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-
-describe AdminPublicBodyHelper do
-
- include AdminPublicBodyHelper
-
- describe :public_body_form_object do
-
- context 'in the default locale' do
-
- before(:each) do
- @locale = I18n.default_locale
- @public_body = Factory.create(:public_body)
- end
-
- it 'provides the original object' do
- object = public_body_form_object(@public_body, @locale)[:object]
- expect(object).to eq(@public_body)
- end
-
- it 'provides the prefix public_body' do
- prefix = public_body_form_object(@public_body, @locale)[:prefix]
- expect(prefix).to eq('public_body')
- end
-
- end
-
- context 'in an alternative locale' do
-
- it 'provides the prefix :translations' do
- public_body = FactoryGirl.build(:public_body)
- locale = :es
- prefix = public_body_form_object(public_body, locale)[:prefix]
- expect(prefix).to eq(:translations)
- end
-
- context 'when the PublicBody is new' do
-
- it 'builds a new PublicBody::Translation' do
- public_body = FactoryGirl.build(:public_body)
- locale = :es
-
- object = public_body_form_object(public_body, locale)[:object]
-
- expect(object).to be_instance_of(PublicBody::Translation)
- expect(object).to be_new_record
- end
-
- end
-
- context 'when the PublicBody has been persisted' do
-
- it 'finds an existing PublicBody::Translation for the locale' do
- public_body = public_bodies(:geraldine_public_body)
- locale = :es
- translation = public_body.find_translation_by_locale(locale)
-
- object = public_body_form_object(public_body, locale)[:object]
-
- expect(object).to eq(translation)
- end
-
- it 'builds a new PublicBody::Translation if the record does not have one for that locale' do
- public_body = FactoryGirl.create(:public_body)
- locale = :es
-
- object = public_body_form_object(public_body, locale)[:object]
-
- expect(object).to be_instance_of(PublicBody::Translation)
- expect(object).to be_new_record
- end
-
- end
-
- end
-
- end
-
-end