aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2013-11-19 10:26:18 +0000
committerMark Longair <mhl@pobox.com>2013-11-19 10:31:13 +0000
commit9fc152f2fc0e4c57996710f060bca01cd63f8349 (patch)
tree57c0691f12f6fdefd075e4b80765218d817855c5
parentb4613023a935331af2dd27c2b162e43168719cbf (diff)
Fix construction of example public bodies for upstream globalize
We're trying to switch to an upstream version of globalize, which now has Henare's change to allowed blank values without them being converted to nil - however, there is another intermediate change that was introduced which means that the name is only written back to the original table if the locale matches the default locale. This is described in more depth here: https://github.com/globalize/globalize/pull/183 This change broke the make_single_language_example helper, but this commit fixes that by also setting the default locale before creating the example public bodies.
-rw-r--r--spec/controllers/public_body_controller_spec.rb30
1 files changed, 16 insertions, 14 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 908827305..0e0b0a575 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -82,21 +82,23 @@ describe PublicBodyController, "when listing bodies" do
def make_single_language_example(locale)
result = nil
- I18n.with_locale(locale) do
- case locale
- when :en
- result = PublicBody.new(:name => 'English only',
- :short_name => 'EO')
- when :es
- result = PublicBody.new(:name => 'Español Solamente',
- :short_name => 'ES')
- else
- raise StandardError.new "Unknown locale #{locale}"
+ with_default_locale(locale) do
+ I18n.with_locale(locale) do
+ case locale
+ when :en
+ result = PublicBody.new(:name => 'English only',
+ :short_name => 'EO')
+ when :es
+ result = PublicBody.new(:name => 'Español Solamente',
+ :short_name => 'ES')
+ else
+ raise StandardError.new "Unknown locale #{locale}"
+ end
+ result.request_email = "#{locale}@example.org"
+ result.last_edit_editor = 'test'
+ result.last_edit_comment = ''
+ result.save
end
- result.request_email = "#{locale}@example.org"
- result.last_edit_editor = 'test'
- result.last_edit_comment = ''
- result.save
end
result
end