diff options
author | David Cabo <david@calibea.com> | 2011-08-12 13:12:50 +0200 |
---|---|---|
committer | David Cabo <david@calibea.com> | 2011-08-12 13:12:50 +0200 |
commit | df1754847892bb6abce2681a42d8c50cf8d3a2da (patch) | |
tree | 73c518103906ad446cedd55c69690d8d91f0f362 /spec/models/public_body_spec.rb | |
parent | a63e598b9e0ddfa7ac695b1be41aaace6c0eb628 (diff) | |
parent | 766df1c7de8f820bd6e451526787632a136bc635 (diff) |
Merge branch 'master' of github.com:sebbacon/alaveteli into asktheeu
Conflicts:
locale/cy/app.po
locale/de/app.po
locale/es/app.po
locale/fr/app.po
locale/sq/app.po
locale/sr/app.po
locale/sr@latin/app.po
Diffstat (limited to 'spec/models/public_body_spec.rb')
-rw-r--r-- | spec/models/public_body_spec.rb | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 5bbf03d27..ec84cbe65 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -240,7 +240,56 @@ describe PublicBody, " when loading CSV files" do PublicBody.count.should == original_count + 3 end -end + it "should handle a field list and fields out of order" do + original_count = PublicBody.count + + csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") + errors, notes = PublicBody.import_csv(csv_contents, 'fake', true, 'someadmin') # true means dry run + errors.should == [] + notes.size.should == 3 + notes.should == ["line 2: new authority 'North West Fake Authority' with email north_west_foi@localhost", + "line 3: new authority 'Scottish Fake Authority' with email scottish_foi@localhost", + "line 4: new authority 'Fake Authority of Northern Ireland' with email ni_foi@localhost"] + + PublicBody.count.should == original_count + end + + it "should create bodies with names in multiple locales" do + original_count = PublicBody.count + + csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") + errors, notes = PublicBody.import_csv(csv_contents, 'fake', false, 'someadmin', ['es']) + errors.should == [] + notes.size.should == 6 + notes.should == [ + "line 2: new authority 'North West Fake Authority' with email north_west_foi@localhost", + "line 2: (aka 'Autoridad del Nordeste' in locale es)", + "line 3: new authority 'Scottish Fake Authority' with email scottish_foi@localhost", + "line 3: (aka 'Autoridad Escocesa' in locale es)", + "line 4: new authority 'Fake Authority of Northern Ireland' with email ni_foi@localhost", + "line 4: (aka 'Autoridad Irlandesa' in locale es)"] + + PublicBody.count.should == original_count + 3 + + # XXX Not sure why trying to do a PublicBody.with_locale fails here. Seems related to + # the way categories are loaded every time from the PublicBody class. For now we just + # test some translation was done. + body = PublicBody.find_by_name('North West Fake Authority') + body.translated_locales.map{|l|l.to_s}.sort.should == ["en", "es"] + end + + it "should not fail if a locale is not found in the input file" do + original_count = PublicBody.count + csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") + errors, notes = PublicBody.import_csv(csv_contents, 'fake', true, 'someadmin', ['xx']) # true means dry run + errors.should == [] + notes.size.should == 3 + notes.should == ["line 2: new authority 'North West Fake Authority' with email north_west_foi@localhost", + "line 3: new authority 'Scottish Fake Authority' with email scottish_foi@localhost", + "line 4: new authority 'Fake Authority of Northern Ireland' with email ni_foi@localhost"] + PublicBody.count.should == original_count + end +end |