Skip to content

Instantly share code, notes, and snippets.

@stiff
Created February 10, 2015 20:46
Show Gist options
  • Save stiff/4d435d5744ed83d7e6ed to your computer and use it in GitHub Desktop.
Save stiff/4d435d5744ed83d7e6ed to your computer and use it in GitHub Desktop.
ruby-419-issue-12753-test
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.9'
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', database: 'test', username: 'stiff', socket: '/var/run/postgresql/.s.PGSQL.5432')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :accounts, :force => true do |t|
end
create_table :employees, :force => true do |t|
t.integer :account_id
end
create_table :notes, :force => true do |t|
t.integer :account_id
t.integer :employee_id
end
end
class Account < ActiveRecord::Base
has_many :employees
has_many :notes
end
class Employee < ActiveRecord::Base
belongs_to :account
has_many :notes
end
class Note < ActiveRecord::Base
belongs_to :account
belongs_to :employee
end
class BugTest < Minitest::Test
def test_where_relation
acc = Account.create
begin
acc.notes.where.not(:employee_id => acc.employees.all).load
pass
rescue
flunk 'Nothing should be raised'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment