-
-
Save zarqman/d307ecf40a65fbe1b0fc71ea0d36ac69 to your computer and use it in GitHub Desktop.
Mongoid 7.0.2 regression in class_name detection
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 | |
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" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
# Activate the gem you are reporting the issue against. | |
gem "activemodel", "5.2.1" | |
gem "openssl", "2.1.2" | |
gem "mongoid", "7.0.2" | |
# gem "mongoid", "7.0.1" | |
end | |
require "active_model" | |
require "mongoid" | |
require "minitest/autorun" | |
require "logger" | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
class Other | |
include Mongoid::Document | |
end | |
class Space | |
include Mongoid::Document | |
end | |
class Space::Child < Space | |
belongs_to :other | |
# belongs_to :other, class_name: 'Other' # workaround for 7.0.2 | |
end | |
class BugTest < Minitest::Test | |
def test_mongoid | |
other = Other.new | |
assert other.valid? | |
child = Space::Child.new other: other | |
assert child.valid? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment