Created
April 24, 2020 09:56
-
-
Save trushkevich/9d8cdc3c7466e7bc793ae7075534db4f 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
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", github: "rails/rails" | |
gem "sqlite3" | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
# 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| | |
end | |
end | |
class Post < ActiveRecord::Base | |
end | |
class BugTest < Minitest::Test | |
def test_ok | |
posts = (0..10).to_a.map { |i| Post.where(id: i) }.inject { |res, scope| res.or(scope) } | |
assert_equal posts.count, 0 | |
end | |
def test_parser_stack_overflow | |
posts = (0..100).to_a.map { |i| Post.where(id: i) }.inject { |res, scope| res.or(scope) } | |
assert_equal posts.count, 0 | |
end | |
def test_stack_level_too_deep | |
posts = (0..1000).to_a.map { |i| Post.where(id: i) }.inject { |res, scope| res.or(scope) } | |
assert_equal posts.count, 0 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment