Skip to content

Instantly share code, notes, and snippets.

@nathansamson
Last active October 10, 2016 09:32
Show Gist options
  • Save nathansamson/a911b3f33f05cf04df3f282a7cb595e8 to your computer and use it in GitHub Desktop.
Save nathansamson/a911b3f33f05cf04df3f282a7cb595e8 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"
# Activate the gem you are reporting the issue against.
gem "mail", '2.6.4'
gem "activesupport", "4.2.7"
end
require 'mail'
require "active_support/all"
require "minitest/autorun"
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
class BugTest < Minitest::Test
def test_stuff
mail = Mail.new do
to 'example@example.org'
from 'example@example.net'
subject 'to_json with (JPG) attachment'
end
mail.add_file("example.jpg")
assert mail.to_json.is_a?(String) # Crash and burn
assert_equal Encoding::UTF_8, mail.to_json.encoding
end
end
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"
# Activate the gem you are reporting the issue against.
gem "mail", '2.6.4'
gem "json", "1.8.3"
gem 'minitest'
end
require 'mail'
require "json"
require "minitest/autorun"
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
class BugTest < Minitest::Test
def test_stuff
mail = Mail.new do
to 'example@example.org'
from 'example@example.net'
subject 'to_json with (JPG) attachment'
end
mail.add_file("example.jpg")
assert mail.to_json.is_a?(String) # Crash and burn
assert_equal Encoding::UTF_8, mail.to_json.encoding
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment