Created
May 8, 2014 09:49
-
-
Save senny/ac4237a3747f45e2b147 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
require 'bundler' | |
Bundler.setup(:default) | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'test123') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :movies, force: true do |t| | |
end | |
create_table :languages, force: true do |t| | |
end | |
create_table :shows, force: true do |t| | |
t.references :language | |
t.references :movie | |
end | |
create_table :schedules, force: true do |t| | |
t.references :show | |
t.datetime :schedule_time | |
t.references :theatre | |
end | |
end | |
class Movie < ActiveRecord::Base | |
has_many :schedules, through: :shows | |
has_many :shows | |
end | |
class Schedule < ActiveRecord::Base | |
belongs_to :show | |
belongs_to :theatre | |
end | |
class Show < ActiveRecord::Base | |
has_many :schedules | |
belongs_to :language | |
belongs_to :movie | |
end | |
class Language < ActiveRecord::Base | |
has_many :shows | |
end | |
class BugTest < Minitest::Test | |
def test_nested_includes | |
movie = Movie.create! | |
schedules = Movie.first.schedules.eager_load(show: [:language]).to_a | |
# HINT: Perhaps you meant to reference the table alias "shows_schedules". | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment