diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-05-07 11:41:12 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-05-07 12:17:12 +0100 |
commit | 824771a4fb7846bec13e395e44f14718ff30d17d (patch) | |
tree | d565f6c430c126a56f1bb889383c7199d11a0c17 /spec/models/info_request_event_spec.rb | |
parent | 751bd3df3b6b28275e0ac9f6b1663c1df84d007f (diff) |
Force the encoding of values returned from YAML.
This is a workaround for an issue where YAML in ruby 1.8 tags UTF-8
heavy strings as binary, resulting in them being retrieved under 1.9
as ASCII-8BIT which can't be concatenated with UTF-8.
Described as "Deep deep YAML oddness" in
https://www.zendesk.com/blog/upgrade-the-road-to-1-9/.
Diffstat (limited to 'spec/models/info_request_event_spec.rb')
-rw-r--r-- | spec/models/info_request_event_spec.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb index 53c83bd46..1299dfb63 100644 --- a/spec/models/info_request_event_spec.rb +++ b/spec/models/info_request_event_spec.rb @@ -30,6 +30,12 @@ describe InfoRequestEvent do ire.params.should == example_params end + it "should restore UTF8-heavy params stored under ruby 1.8 as UTF-8" do + ire = InfoRequestEvent.new + utf8_params = "--- \n:foo: !binary |\n 0KLQvtCz0LDRiCDR\n" + ire.params_yaml = utf8_params + ire.params[:foo].encoding.to_s.should == 'UTF-8' if ire.params[:foo].respond_to?(:encoding) + end end describe 'when deciding if it is indexed by search' do |