aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-02-02 14:34:02 +0000
committerLouise Crow <louise.crow@gmail.com>2015-02-23 11:17:56 +0000
commit2c6250666b8dd5ca383ec29ea786805b102e2ac7 (patch)
tree25b528e65c625007cf064dee4d9cc6b1e0eb2d59 /spec/models
parent60e3aad7ac32ac826b93a707db9589237fd4948d (diff)
Test localised value for import against existing localised value
Previously the call to public_body.send would return the value for the default locale if no value was set in the current locale, meaning that translations for attributes that were the same as the attribute values in the default locale were not being loaded. Fixes #2134.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/public_body_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 225958cac..23f3aa5d6 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -598,6 +598,22 @@ CSV
PublicBody.csv_import_fields = old_csv_import_fields
end
+ it "should import translations for fields whose values are the same as the default locale's" do
+ original_count = PublicBody.count
+
+ csv_contents = load_file_fixture("multiple-locales-same-name.csv")
+
+ errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin', ['en', 'es']) # true means dry run
+ errors.should == []
+ notes.size.should == 3
+ notes[0..1].should == [
+ "line 2: creating new authority 'Test' (locale: en):\n\t{\"name\":\"Test\",\"request_email\":\"test@test.es\",\"home_page\":\"http://www.test.es/\",\"tag_string\":\"37\"}",
+ "line 2: creating new authority 'Test' (locale: es):\n\t{\"name\":\"Test\"}",
+ ]
+ notes[2].should =~ /Notes: Some bodies are in database, but not in CSV file:\n( .+\n)*You may want to delete them manually.\n/
+
+ PublicBody.count.should == original_count
+ end
end
describe PublicBody do