spec: fix encodings in tests

ruby 2.1 defaults to utf-8 for string literals, where 1.9 defaulted to
binary, so these tests need to explicitly force binary for 2.1
compatibility.

This change should only be necessary in the specs, the encoding of the
body strings coming from real data won't change with 2.1, since they
aren't string literals.

fixes CNVS-16261

Change-Id: Ifd127d077e47ab56b76620ef0974932563826cc2
Reviewed-on: https://gerrit.instructure.com/42734
Reviewed-by: Bryan Madsen <bryan@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
Brian Palmer 2014-10-14 11:09:22 -06:00 committed by Jon Jensen
parent 9cac5ddaf7
commit e53dec0894
1 changed files with 2 additions and 2 deletions

View File

@ -128,7 +128,7 @@ describe IncomingMailProcessor::IncomingMessageProcessor do
describe "#process_single" do describe "#process_single" do
it "should not choke on invalid UTF-8" do it "should not choke on invalid UTF-8" do
IncomingMessageProcessor.new(message_handler, error_reporter).process_single(Mail.new { body "he\xffllo" }, '') IncomingMessageProcessor.new(message_handler, error_reporter).process_single(Mail.new { body "he\xffllo".force_encoding(Encoding::BINARY) }, '')
message_handler.body.should == "hello" message_handler.body.should == "hello"
message_handler.html_body.should == "hello" message_handler.html_body.should == "hello"
@ -137,7 +137,7 @@ describe IncomingMailProcessor::IncomingMessageProcessor do
it "should convert another charset to UTF-8" do it "should convert another charset to UTF-8" do
IncomingMessageProcessor.new(message_handler, error_reporter).process_single(Mail.new { IncomingMessageProcessor.new(message_handler, error_reporter).process_single(Mail.new {
content_type 'text/plain; charset=Shift-JIS' content_type 'text/plain; charset=Shift-JIS'
body "\x83\x40" body "\x83\x40".force_encoding(Encoding::BINARY)
}, '') }, '')
comparison_string = "\xe3\x82\xa1" comparison_string = "\xe3\x82\xa1"