aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/public_body_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/public_body_spec.rb')
-rw-r--r--spec/models/public_body_spec.rb42
1 files changed, 17 insertions, 25 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index bdfaab6bf..f12582f21 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -30,23 +30,23 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PublicBody do
- describe :translated_versions= do
+ describe :translations_attributes= do
context 'translation_attrs is a Hash' do
it 'takes the correct code path for a Hash' do
attrs = {}
attrs.should_receive(:each_value)
- PublicBody.new().translated_versions = attrs
+ PublicBody.new().translations_attributes = attrs
end
it 'updates an existing translation' do
body = public_bodies(:geraldine_public_body)
translation = body.translation_for(:es)
- params = { translation.id.to_sym => { :locale => 'es',
- :name => 'Renamed' } }
+ params = { 'es' => { :locale => 'es',
+ :name => 'Renamed' } }
- body.translated_versions = params
+ body.translations_attributes = params
I18n.with_locale(:es) { expect(body.name).to eq('Renamed') }
end
@@ -56,15 +56,11 @@ describe PublicBody do
expect(body.translations.size).to eq(2)
- body.translated_versions = {
- translation.id.to_sym => {
- :locale => 'es',
- :name => 'Renamed'
- },
- :new_translation => {
- :locale => 'fr',
- :name => 'Le Geraldine Quango'
- }
+ body.translations_attributes = {
+ 'es' => { :locale => 'es',
+ :name => 'Renamed' },
+ 'fr' => { :locale => 'fr',
+ :name => 'Le Geraldine Quango' }
}
expect(body.translations.size).to eq(3)
@@ -78,14 +74,10 @@ describe PublicBody do
expect(body.translations.size).to eq(2)
- body.translated_versions = {
- translation.id.to_sym => {
- :locale => 'es',
- :name => 'Renamed'
- },
- :empty_translation => {
- :locale => 'es'
- }
+ body.translations_attributes = {
+ 'es' => { :locale => 'es',
+ :name => 'Renamed' },
+ 'fr' => { :locale => 'fr' }
}
expect(body.translations.size).to eq(2)
@@ -98,7 +90,7 @@ describe PublicBody do
it 'takes the correct code path for an Array' do
attrs = []
attrs.should_receive(:each)
- PublicBody.new().translated_versions = attrs
+ PublicBody.new().translations_attributes = attrs
end
it 'creates a new translation' do
@@ -108,7 +100,7 @@ describe PublicBody do
expect(body.translations.size).to eq(1)
- body.translated_versions = [ {
+ body.translations_attributes = [ {
:locale => 'es',
:name => 'Renamed'
}
@@ -125,7 +117,7 @@ describe PublicBody do
expect(body.translations.size).to eq(1)
- body.translated_versions = [
+ body.translations_attributes = [
{ :locale => 'empty' }
]