Created
June 28, 2015 00:04
-
-
Save felixbuenemann/21dc7e7496839ae06e07 to your computer and use it in GitHub Desktop.
This file contains hidden or 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', '4.2.3' | |
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.boolean :published | |
end | |
end | |
class Post < ActiveRecord::Base | |
scope :published, -> { where(published: true) } | |
end | |
class BugTest < Minitest::Test | |
def test_unscope_should_not_modify_source_relation | |
Post.create! published: false | |
Post.create! published: true | |
published_posts = Post.published | |
assert_equal 1, published_posts.count | |
all_posts = published_posts.unscope(where: :published) | |
assert_equal 2, all_posts.count | |
assert_equal 1, published_posts.count | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This bug has been fixed in rails 4.2.4.