Skip to content

Instantly share code, notes, and snippets.

@alpaca-tc
Created February 14, 2019 09:54
Show Gist options
  • Save alpaca-tc/eb7eeb419b71a852dafdc51c0edec51f to your computer and use it in GitHub Desktop.
Save alpaca-tc/eb7eeb419b71a852dafdc51c0edec51f to your computer and use it in GitHub Desktop.
begin
require 'bundler/inline'
rescue LoadError
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
gem 'pry'
end
require 'active_record'
require 'pry'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, force: true
end
class Post < ActiveRecord::Base
attribute :user_defined_date, :date
end
class BugTest < Minitest::Test
def test_without_transaction
post = Post.new
assert_equal post.user_defined_date?, false
post.user_defined_date = Date.today
assert_equal post.user_defined_date?, true
# NoMethodError: undefined method `to_i' for Thu, 14 Feb 2019:Date
# Did you mean? to_s
# from /Users/ishii.hiroyuki/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems/rails-e53430fa9af2/activerecord/lib/active_record/attribute_methods/query.rb:22:in `query_attribute'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment