Created
April 26, 2020 17:51
-
-
Save haohaolee/b0ebc426502dcbf0b6b35f53537581d8 to your computer and use it in GitHub Desktop.
reproduce an rails issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 'activerecord', '~> 5.0.7' | |
gem 'activerecord-jdbcpostgresql-adapter' | |
end | |
require 'active_record' | |
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: 'postgresql', port: 5432, | |
host: 'localhost', | |
username: 'postgres', password: 'change_to_whatever_you_use') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :posts, force: true do |t| | |
t.date :post_date | |
end | |
end | |
class Post < ActiveRecord::Base | |
validates_uniqueness_of :post_date | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
post = Post.create!(post_date: Date.new(2001,1,1)) | |
assert post.valid? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment