Last active
August 29, 2015 14:00
-
-
Save eric-chahin/7eaba60b98ce20e068b9 to your computer and use it in GitHub Desktop.
Trying to reproduce bug in #14824
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
gem 'rails', :path => '/Users/EricChahin/Documents/Cornell/Semester 6/CS 5152/rails/' | |
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: 'bug14824') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
execute 'DROP SCHEMA IF EXISTS music CASCADE;' | |
execute 'CREATE SCHEMA music;' | |
execute 'SET search_path TO music' | |
create_table :albums do |t| | |
end | |
create_table :songs do |t| | |
end | |
create_table :albums_songs do |t| | |
t.belongs_to :album | |
t.belongs_to :song | |
end | |
execute 'SET search_path TO public' | |
end | |
module Music | |
class Song < ActiveRecord::Base | |
self.table_name = "music.songs" | |
has_and_belongs_to_many :albums | |
end | |
class Album < ActiveRecord::Base | |
self.table_name = "music.albums" | |
has_and_belongs_to_many :songs | |
end | |
end | |
class BugTest < Minitest::Test | |
def test_habtm | |
song = Music::Song.create | |
album = Music::Album.create | |
Music::Song.includes(:albums).references(:albums).first | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment