Skip to content

Instantly share code, notes, and snippets.

@maltoe
Created June 2, 2016 12:30
Show Gist options
  • Save maltoe/a1b9bfc83be1c0eaef208ade9cbdfdad to your computer and use it in GitHub Desktop.
Save maltoe/a1b9bfc83be1c0eaef208ade9cbdfdad to your computer and use it in GitHub Desktop.
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
end
require 'action_controller/railtie'
require 'minitest/autorun'
require 'rack/test'
class BugTest < ActiveSupport::TestCase
include Rack::Test::Methods
def test_to_json_with_non_ascii_data
t = Tempfile.new 'foo'
t.binmode # This is not even necessary, but AFAIK is set for our uploads.
t.puts "\x80".force_encoding('ASCII-8BIT')
t.rewind
uf = ActionDispatch::Http::UploadedFile.new(tempfile: t)
assert_nothing_raised { uf.to_json }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment