Created
September 7, 2016 06:04
-
-
Save prathamesh-sonpatki/a7df922273473a77dfbc742a4be4b618 to your computer and use it in GitHub Desktop.
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 "rails", github: "rails/rails" | |
# gem "activerecord", "5.0.0" | |
# gem "activerecord", "4.2.7" | |
gem "sqlite3" | |
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: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :posts, force: true do |t| | |
t.string :title | |
end | |
create_table :comments, force: true do |t| | |
t.string :content | |
t.integer :post_id | |
end | |
end | |
class Post < ActiveRecord::Base | |
has_many :comments | |
end | |
class Comment < ActiveRecord::Base | |
belongs_to :post | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
post = Post.create! title: "Rails is so awesome" | |
post.comments << Comment.create!(content: "Sure it is") | |
post.comments << Comment.create!(content: "One hundred percent!!") | |
p post.comments.select { |c| c.content =~ /Sure/ } | |
p post.comments.select(:content) { |c| c.content =~ /Sure/ } | |
end | |
end | |
# Failure on Rails master, passes on Rails 4.2.7 and Rails 5.0.0 | |
# 1) Error: | |
# BugTest#test_association_stuff: | |
# ArgumentError: wrong number of arguments (given 1, expected 0) | |
# /Users/prathamesh/.rbenv/versions/ruby-dev/lib/ruby/gems/2.4.0/bundler/gems/rails-06658f1d9db5/activerecord/lib/active_record/relation/query_methods.rb:245:in `select' | |
# /Users/prathamesh/.rbenv/versions/ruby-dev/lib/ruby/gems/2.4.0/bundler/gems/rails-06658f1d9db5/activerecord/lib/active_record/relation/query_methods.rb:245:in `select' | |
# select_regression.rb:54:in `test_association_stuff' | |
# 1 runs, 0 assertions, 0 failures, 1 errors, 0 skips |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment