Skip to content

Instantly share code, notes, and snippets.

@pixeltrix
Forked from awilliams/ar_mysql2_bug.rb
Created July 16, 2013 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pixeltrix/6009171 to your computer and use it in GitHub Desktop.
Save pixeltrix/6009171 to your computer and use it in GitHub Desktop.
# Must have mysql installed with database 'activerecord_unittest' and user 'rails'
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'mysql2'
GEMFILE
system 'bundle'
end
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'mysql2', user: 'rails', database: 'activerecord_unittest')
ActiveRecord::Base.logger = Logger.new(STDOUT)
class BugTest < MiniTest::Unit::TestCase
def test_association_stuff
conn = ActiveRecord::Base.connection
c = ActiveRecord::ConnectionAdapters::Mysql2Adapter::Column.new(nil, 1, 'boolean')
assert_equal 1, conn.type_cast(true, c)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment