diff options
-rw-r--r-- | app/models/public_body.rb | 4 | ||||
-rw-r--r-- | spec/models/public_body_spec.rb | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 80646084e..ab836657b 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -392,7 +392,7 @@ class PublicBody < ActiveRecord::Base PublicBody.with_locale(locale) do changed = {} field_list.each do |field_name| - localized_field_name = (locale === I18n.default_locale) ? field_name : "#{field_name}.#{locale}" + localized_field_name = (locale.to_s == I18n.default_locale.to_s) ? field_name : "#{field_name}.#{locale}" localized_value = field_names[localized_field_name] && row[field_names[localized_field_name]] # Tags are a special case, as we support adding to the field, not just setting a new value @@ -427,7 +427,7 @@ class PublicBody < ActiveRecord::Base PublicBody.with_locale(locale) do changed = {} field_list.each do |field_name| - localized_field_name = (locale === I18n.default_locale) ? field_name : "#{field_name}.#{locale}" + localized_field_name = (locale.to_s == I18n.default_locale.to_s) ? field_name : "#{field_name}.#{locale}" localized_value = field_names[localized_field_name] && row[field_names[localized_field_name]] if localized_field_name == 'tag_string' and tag_behaviour == 'add' diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 96a783743..33ab8ffdb 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -377,7 +377,10 @@ describe PublicBody, " when loading CSV files" do original_count = PublicBody.count csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") - errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin', [:en, :xx]) # true means dry run + # Depending on the runtime environment (Ruby version? OS?) the list of available locales + # is made of strings or symbols, so we use 'en' here as a string to test both scenarios. + # See https://github.com/sebbacon/alaveteli/issues/193 + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin', ['en', :xx]) # true means dry run errors.should == [] notes.size.should == 4 notes.should == [ |