diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-06-12 10:37:37 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-06-12 10:37:37 +0100 |
commit | 47a0cac0454268b0e044db7465c72eecdb86e46b (patch) | |
tree | 40d58b5f180ec12321a211efe71da33b31c23125 /spec/models | |
parent | b78ccd9d0dc14b8ebd71cb28c15f1187b646ce42 (diff) | |
parent | 1524f83baa3b93a506dbefe7def0c4c304f93745 (diff) |
Merge branch 'updating-derived-atts' into develop
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/public_body_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index d6abf7b5f..ca94c59a8 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -282,6 +282,31 @@ describe PublicBody, " when saving" do pb.first_letter.should == 'Å' end + it 'should save the first letter of a translation' do + existing = FactoryGirl.create(:public_body, :first_letter => 'T', :name => 'Test body') + I18n.with_locale(:es) { existing.update_attributes :name => 'Prueba body' } + PublicBody::Translation. + where(:public_body_id => existing.id, :locale => :es). + pluck('first_letter').first.should == 'P' + end + + it 'should save the first letter of a translation, even when it is the same as the + first letter in the default locale' do + existing = FactoryGirl.create(:public_body, :first_letter => 'T', :name => 'Test body') + I18n.with_locale(:es) { existing.update_attributes :name => existing.name } + PublicBody::Translation. + where(:public_body_id => existing.id, :locale => :es). + pluck('first_letter').first.should == 'T' + end + + it 'should create a url_name for a translation' do + existing = FactoryGirl.create(:public_body, :first_letter => 'T', :short_name => 'Test body') + I18n.with_locale(:es) do + existing.update_attributes :short_name => 'Prueba', :name => 'Prueba body' + existing.url_name.should == 'prueba' + end + end + it "should not save if the url_name is already taken" do existing = FactoryGirl.create(:public_body) pb = PublicBody.new(existing.attributes) |