Last active
March 4, 2016 01:46
-
-
Save msbit/9b96c60c7ac4735e6c39 to your computer and use it in GitHub Desktop.
ActiveRecord::QueryMethods#includes has_many through with ordering on through model
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
Fetching gem metadata from https://rubygems.org/........... | |
Fetching version metadata from https://rubygems.org/.. | |
Resolving dependencies... | |
Using i18n 0.7.0 | |
Using json 1.8.3 | |
Using minitest 5.8.4 | |
Using thread_safe 0.3.5 | |
Using builder 3.2.2 | |
Using arel 6.0.3 | |
Using sqlite3 1.3.11 | |
Using bundler 1.11.2 | |
Using tzinfo 1.2.2 | |
Using activesupport 4.2.5.2 | |
Using activemodel 4.2.5.2 | |
Using activerecord 4.2.5.2 | |
-- create_table(:test_definitions, {:force=>true}) | |
D, [2016-03-04T12:44:18.076247 #36558] DEBUG -- : [1m[36m (0.2ms)[0m [1mCREATE TABLE "test_definitions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL) [0m | |
-> 0.0035s | |
-- create_table(:module_test_definitions, {:force=>true}) | |
D, [2016-03-04T12:44:18.076764 #36558] DEBUG -- : [1m[35m (0.1ms)[0m CREATE TABLE "module_test_definitions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "module_definition_id" integer, "test_definition_id" integer, "order" integer) | |
-> 0.0004s | |
-- create_table(:module_definitions, {:force=>true}) | |
D, [2016-03-04T12:44:18.077152 #36558] DEBUG -- : [1m[36m (0.1ms)[0m [1mCREATE TABLE "module_definitions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL) [0m | |
-> 0.0004s | |
Run options: --seed 25906 | |
# Running: | |
D, [2016-03-04T12:44:18.102850 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.104473 #36558] DEBUG -- : [1m[36mSQL (0.1ms)[0m [1mINSERT INTO "test_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:18.104711 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.105771 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.106131 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_definitions" DEFAULT VALUES | |
D, [2016-03-04T12:44:18.106301 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.106422 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.106670 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:18.106829 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.106950 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.107229 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_definitions" DEFAULT VALUES | |
D, [2016-03-04T12:44:18.107419 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.112386 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.114077 #36558] DEBUG -- : [1m[36mSQL (0.1ms)[0m [1mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 2], ["test_definition_id", 1], ["order", 1]] | |
D, [2016-03-04T12:44:18.114283 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.114515 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.115410 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?) [["module_definition_id", 3], ["test_definition_id", 1], ["order", 2]] | |
D, [2016-03-04T12:44:18.115603 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.115814 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.116218 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 1], ["test_definition_id", 1], ["order", 3]] | |
D, [2016-03-04T12:44:18.116407 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.118846 #36558] DEBUG -- : [1m[36mTestDefinition Load (0.1ms)[0m [1mSELECT "test_definitions".* FROM "test_definitions" WHERE "test_definitions"."id" = ? LIMIT 1[0m [["id", 1]] | |
D, [2016-03-04T12:44:18.130700 #36558] DEBUG -- : [1m[35mModuleTestDefinition Load (0.1ms)[0m SELECT "module_test_definitions".* FROM "module_test_definitions" WHERE "module_test_definitions"."test_definition_id" IN (1) ORDER BY "module_test_definitions"."order" ASC | |
D, [2016-03-04T12:44:18.133675 #36558] DEBUG -- : [1m[36mModuleDefinition Load (0.1ms)[0m [1mSELECT "module_definitions".* FROM "module_definitions" WHERE "module_definitions"."id" IN (2, 3, 1)[0m | |
FD, [2016-03-04T12:44:18.143812 #36558] DEBUG -- : [1m[35m (0.1ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.144580 #36558] DEBUG -- : [1m[36mSQL (0.1ms)[0m [1mINSERT INTO "test_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:18.144893 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.145095 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.145412 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_definitions" DEFAULT VALUES | |
D, [2016-03-04T12:44:18.145616 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.145755 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.146011 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:18.146175 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.146304 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.146560 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_definitions" DEFAULT VALUES | |
D, [2016-03-04T12:44:18.146728 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.147032 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.147576 #36558] DEBUG -- : [1m[36mSQL (0.1ms)[0m [1mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 5], ["test_definition_id", 2], ["order", 1]] | |
D, [2016-03-04T12:44:18.147765 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.147969 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.148375 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?) [["module_definition_id", 6], ["test_definition_id", 2], ["order", 2]] | |
D, [2016-03-04T12:44:18.148545 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.148742 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.149144 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 4], ["test_definition_id", 2], ["order", 3]] | |
D, [2016-03-04T12:44:18.149310 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.150861 #36558] DEBUG -- : [1m[36mTestDefinition Load (0.1ms)[0m [1mSELECT "test_definitions".* FROM "test_definitions" WHERE "test_definitions"."id" = ? LIMIT 1[0m [["id", 2]] | |
D, [2016-03-04T12:44:18.154786 #36558] DEBUG -- : [1m[35mModuleDefinition Load (0.1ms)[0m SELECT "module_definitions".* FROM "module_definitions" INNER JOIN "module_test_definitions" ON "module_definitions"."id" = "module_test_definitions"."module_definition_id" WHERE "module_test_definitions"."test_definition_id" = ? ORDER BY "module_test_definitions"."order" ASC [["test_definition_id", 2]] | |
.D, [2016-03-04T12:44:18.155220 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.155649 #36558] DEBUG -- : [1m[35mSQL (0.1ms)[0m INSERT INTO "test_definitions" DEFAULT VALUES | |
D, [2016-03-04T12:44:18.155868 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.156045 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.156352 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:18.156527 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.156658 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.156919 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_definitions" DEFAULT VALUES | |
D, [2016-03-04T12:44:18.157097 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.157211 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.157455 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:18.157619 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.157873 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.158323 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?) [["module_definition_id", 8], ["test_definition_id", 3], ["order", 1]] | |
D, [2016-03-04T12:44:18.158503 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.158703 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.159106 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 9], ["test_definition_id", 3], ["order", 2]] | |
D, [2016-03-04T12:44:18.159278 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.159482 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.159872 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?) [["module_definition_id", 7], ["test_definition_id", 3], ["order", 3]] | |
D, [2016-03-04T12:44:18.160044 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.160405 #36558] DEBUG -- : [1m[35mTestDefinition Load (0.0ms)[0m SELECT "test_definitions".* FROM "test_definitions" WHERE "test_definitions"."id" = ? LIMIT 1 [["id", 3]] | |
D, [2016-03-04T12:44:18.161212 #36558] DEBUG -- : [1m[36mModuleTestDefinition Load (0.1ms)[0m [1mSELECT "module_test_definitions".* FROM "module_test_definitions" WHERE "module_test_definitions"."test_definition_id" IN (3) ORDER BY "module_test_definitions"."order" ASC[0m | |
D, [2016-03-04T12:44:18.162209 #36558] DEBUG -- : [1m[35mModuleDefinition Load (0.1ms)[0m SELECT "module_definitions".* FROM "module_definitions" WHERE "module_definitions"."id" IN (8, 9, 7) | |
FD, [2016-03-04T12:44:18.169321 #36558] DEBUG -- : [1m[36m (0.1ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.170067 #36558] DEBUG -- : [1m[35mSQL (0.1ms)[0m INSERT INTO "test_definitions" DEFAULT VALUES | |
D, [2016-03-04T12:44:18.170355 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.170535 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.170857 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:18.171037 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.171163 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.171431 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_definitions" DEFAULT VALUES | |
D, [2016-03-04T12:44:18.171600 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.171729 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.171998 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:18.172160 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.172459 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.172977 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?) [["module_definition_id", 11], ["test_definition_id", 4], ["order", 1]] | |
D, [2016-03-04T12:44:18.173163 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.173363 #36558] DEBUG -- : [1m[35m (0.0ms)[0m begin transaction | |
D, [2016-03-04T12:44:18.173766 #36558] DEBUG -- : [1m[36mSQL (0.0ms)[0m [1mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 12], ["test_definition_id", 4], ["order", 2]] | |
D, [2016-03-04T12:44:18.173938 #36558] DEBUG -- : [1m[35m (0.0ms)[0m commit transaction | |
D, [2016-03-04T12:44:18.174276 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mbegin transaction[0m | |
D, [2016-03-04T12:44:18.174730 #36558] DEBUG -- : [1m[35mSQL (0.0ms)[0m INSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?) [["module_definition_id", 10], ["test_definition_id", 4], ["order", 3]] | |
D, [2016-03-04T12:44:18.174909 #36558] DEBUG -- : [1m[36m (0.0ms)[0m [1mcommit transaction[0m | |
D, [2016-03-04T12:44:18.177292 #36558] DEBUG -- : [1m[35mSQL (0.1ms)[0m SELECT DISTINCT "test_definitions"."id" FROM "test_definitions" LEFT OUTER JOIN "module_test_definitions" ON "module_test_definitions"."test_definition_id" = "test_definitions"."id" LEFT OUTER JOIN "module_definitions" ON "module_definitions"."id" = "module_test_definitions"."module_definition_id" WHERE "test_definitions"."id" = ? LIMIT 1 [["id", 4]] | |
D, [2016-03-04T12:44:18.178290 #36558] DEBUG -- : [1m[36mSQL (0.1ms)[0m [1mSELECT "test_definitions"."id" AS t0_r0, "module_definitions"."id" AS t1_r0 FROM "test_definitions" LEFT OUTER JOIN "module_test_definitions" ON "module_test_definitions"."test_definition_id" = "test_definitions"."id" LEFT OUTER JOIN "module_definitions" ON "module_definitions"."id" = "module_test_definitions"."module_definition_id" WHERE "test_definitions"."id" = ? AND "test_definitions"."id" IN (4)[0m [["id", 4]] | |
. | |
Finished in 0.080107s, 49.9334 runs/s, 49.9334 assertions/s. | |
1) Failure: | |
BugTest#test_preloaded_through_with_order_on_through_model [active_record_gem.rb:92]: | |
--- expected | |
+++ actual | |
@@ -1 +1 @@ | |
-[#<ModuleDefinition id: 2>, #<ModuleDefinition id: 3>, #<ModuleDefinition id: 1>] | |
+[#<ModuleDefinition id: 1>, #<ModuleDefinition id: 2>, #<ModuleDefinition id: 3>] | |
2) Failure: | |
BugTest#test_included_through_with_order_on_through_model [active_record_gem.rb:97]: | |
--- expected | |
+++ actual | |
@@ -1 +1 @@ | |
-[#<ModuleDefinition id: 8>, #<ModuleDefinition id: 9>, #<ModuleDefinition id: 7>] | |
+[#<ModuleDefinition id: 7>, #<ModuleDefinition id: 8>, #<ModuleDefinition id: 9>] | |
4 runs, 4 assertions, 2 failures, 0 errors, 0 skips |
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
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.5.2' | |
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 :test_definitions, force: true do |t| | |
end | |
create_table :module_test_definitions, force: true do |t| | |
t.integer :module_definition_id | |
t.integer :test_definition_id | |
t.integer :order | |
end | |
create_table :module_definitions, force: true do |t| | |
end | |
end | |
class TestDefinition < ActiveRecord::Base | |
has_many :module_test_definitions, -> { order(order: :asc) } | |
has_many :module_definitions, through: :module_test_definitions | |
end | |
class ModuleTestDefinition < ActiveRecord::Base | |
belongs_to :module_definition | |
belongs_to :test_definition | |
end | |
class ModuleDefinition < ActiveRecord::Base | |
has_many :module_test_definitions | |
end | |
class BugTest < Minitest::Test | |
def setup | |
@td = TestDefinition.create | |
@md_1 = ModuleDefinition.create | |
@md_2 = ModuleDefinition.create | |
@md_3 = ModuleDefinition.create | |
ModuleTestDefinition.create do |mtd| | |
mtd.module_definition = @md_2 | |
mtd.test_definition = @td | |
mtd.order = 1 | |
end | |
ModuleTestDefinition.create do |mtd| | |
mtd.module_definition = @md_3 | |
mtd.test_definition = @td | |
mtd.order = 2 | |
end | |
ModuleTestDefinition.create do |mtd| | |
mtd.module_definition = @md_1 | |
mtd.test_definition = @td | |
mtd.order = 3 | |
end | |
end | |
def test_lazy_loaded_through_with_order_on_through_model | |
lazy_loaded_module_definitions = TestDefinition.find(@td.id).module_definitions | |
assert_equal([@md_2, @md_3, @md_1], lazy_loaded_module_definitions.to_a) | |
end | |
def test_eager_loaded_through_with_order_on_through_model | |
eager_loaded_module_definitions = TestDefinition.eager_load(:module_definitions).find(@td.id).module_definitions | |
assert_equal([@md_2, @md_3, @md_1], eager_loaded_module_definitions.to_a) | |
end | |
def test_preloaded_through_with_order_on_through_model | |
preloaded_module_definitions = TestDefinition.preload(:module_definitions).find(@td.id).module_definitions | |
assert_equal([@md_2, @md_3, @md_1], preloaded_module_definitions.to_a) | |
end | |
def test_included_through_with_order_on_through_model | |
included_module_definitions = TestDefinition.includes(:module_definitions).find(@td.id).module_definitions | |
assert_equal([@md_2, @md_3, @md_1], included_module_definitions.to_a) | |
end | |
end |
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
Fetching git://github.com/rails/rails.git | |
Fetching gem metadata from https://rubygems.org/......... | |
Fetching version metadata from https://rubygems.org/.. | |
Resolving dependencies.... | |
Using rake 10.5.0 | |
Using concurrent-ruby 1.0.1 | |
Using i18n 0.7.0 | |
Using minitest 5.8.4 | |
Using thread_safe 0.3.5 | |
Using builder 3.2.2 | |
Using erubis 2.7.0 | |
Using mini_portile2 2.0.0 | |
Using json 1.8.3 | |
Using nio4r 1.2.1 | |
Using websocket-extensions 0.1.2 | |
Using mime-types 2.99.1 | |
Using arel 7.0.0 | |
Using bundler 1.11.2 | |
Using method_source 0.8.2 | |
Using thor 0.19.1 | |
Using sqlite3 1.3.11 | |
Using tzinfo 1.2.2 | |
Using nokogiri 1.6.7.2 | |
Using rack 2.0.0.alpha | |
Using websocket-driver 0.6.3 | |
Using mail 2.6.3 | |
Using activesupport 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using loofah 2.0.3 | |
Using rack-test 0.6.3 | |
Using sprockets 3.5.2 | |
Using rails-deprecated_sanitizer 1.0.3 | |
Using globalid 0.3.6 | |
Using activemodel 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using rails-html-sanitizer 1.0.3 | |
Using rails-dom-testing 1.0.7 | |
Using activejob 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using activerecord 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using actionview 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using actionpack 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using actioncable 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using actionmailer 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using railties 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
Using sprockets-rails 3.0.4 | |
Using rails 5.0.0.beta3 from git://github.com/rails/rails.git (at master@f8ec3a1) | |
-- create_table(:test_definitions, {:force=>true}) | |
D, [2016-03-04T12:44:54.463616 #36577] DEBUG -- : [1m[35m (0.2ms)[0m [1m[35mCREATE TABLE "test_definitions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL) [0m | |
-> 0.0200s | |
-- create_table(:module_test_definitions, {:force=>true}) | |
D, [2016-03-04T12:44:54.464148 #36577] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE TABLE "module_test_definitions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "module_definition_id" integer, "test_definition_id" integer, "order" integer) [0m | |
-> 0.0005s | |
-- create_table(:module_definitions, {:force=>true}) | |
D, [2016-03-04T12:44:54.464491 #36577] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE TABLE "module_definitions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL) [0m | |
-> 0.0003s | |
D, [2016-03-04T12:44:54.467757 #36577] DEBUG -- : [1m[35m (0.1ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m | |
D, [2016-03-04T12:44:54.474436 #36577] DEBUG -- : [1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" ORDER BY "ar_internal_metadata"."key" ASC LIMIT ?[0m [["LIMIT", 1]] | |
D, [2016-03-04T12:44:54.479474 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.480325 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "development"], ["created_at", 2016-03-04 01:44:54 UTC], ["updated_at", 2016-03-04 01:44:54 UTC]] | |
D, [2016-03-04T12:44:54.480563 #36577] DEBUG -- : [1m[35m (0.1ms)[0m [1m[36mcommit transaction[0m | |
Run options: --seed 40123 | |
# Running: | |
D, [2016-03-04T12:44:54.507781 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.508450 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "test_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.508643 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.510107 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.510503 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.510662 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.510805 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.511084 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.511216 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.511355 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.511629 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.511759 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.517480 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.518155 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 2], ["test_definition_id", 1], ["order", 1]] | |
D, [2016-03-04T12:44:54.518325 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.518530 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.518935 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 3], ["test_definition_id", 1], ["order", 2]] | |
D, [2016-03-04T12:44:54.519067 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.519259 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.519649 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 1], ["test_definition_id", 1], ["order", 3]] | |
D, [2016-03-04T12:44:54.519780 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.520977 #36577] DEBUG -- : [1m[36mTestDefinition Load (0.1ms)[0m [1m[34mSELECT "test_definitions".* FROM "test_definitions" WHERE "test_definitions"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]] | |
D, [2016-03-04T12:44:54.533175 #36577] DEBUG -- : [1m[36mModuleDefinition Load (0.2ms)[0m [1m[34mSELECT "module_definitions".* FROM "module_definitions" INNER JOIN "module_test_definitions" ON "module_definitions"."id" = "module_test_definitions"."module_definition_id" WHERE "module_test_definitions"."test_definition_id" = ? ORDER BY "module_test_definitions"."order" ASC[0m [["test_definition_id", 1]] | |
.D, [2016-03-04T12:44:54.533938 #36577] DEBUG -- : [1m[35m (0.1ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.534507 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "test_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.534710 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.534933 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.535316 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.535488 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.535659 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.535999 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.536159 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.536334 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.536683 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.536841 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.537142 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.537707 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 5], ["test_definition_id", 2], ["order", 1]] | |
D, [2016-03-04T12:44:54.537869 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.538095 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.538615 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 6], ["test_definition_id", 2], ["order", 2]] | |
D, [2016-03-04T12:44:54.538776 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.538999 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.539479 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 4], ["test_definition_id", 2], ["order", 3]] | |
D, [2016-03-04T12:44:54.539639 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.540129 #36577] DEBUG -- : [1m[36mTestDefinition Load (0.0ms)[0m [1m[34mSELECT "test_definitions".* FROM "test_definitions" WHERE "test_definitions"."id" = ? LIMIT ?[0m [["id", 2], ["LIMIT", 1]] | |
D, [2016-03-04T12:44:54.543413 #36577] DEBUG -- : [1m[36mModuleTestDefinition Load (0.1ms)[0m [1m[34mSELECT "module_test_definitions".* FROM "module_test_definitions" WHERE "module_test_definitions"."test_definition_id" = 2 ORDER BY "module_test_definitions"."order" ASC[0m | |
D, [2016-03-04T12:44:54.544966 #36577] DEBUG -- : [1m[36mModuleDefinition Load (0.1ms)[0m [1m[34mSELECT "module_definitions".* FROM "module_definitions" WHERE "module_definitions"."id" IN (5, 6, 4)[0m | |
.D, [2016-03-04T12:44:54.546039 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.546467 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "test_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.546625 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.546793 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.547102 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.547237 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.547380 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.547653 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.547784 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.547926 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.548195 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.548324 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.548552 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.549020 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 8], ["test_definition_id", 3], ["order", 1]] | |
D, [2016-03-04T12:44:54.549160 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.549345 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.549739 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 9], ["test_definition_id", 3], ["order", 2]] | |
D, [2016-03-04T12:44:54.549876 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.550056 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.550451 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 7], ["test_definition_id", 3], ["order", 3]] | |
D, [2016-03-04T12:44:54.550582 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.550926 #36577] DEBUG -- : [1m[36mTestDefinition Load (0.0ms)[0m [1m[34mSELECT "test_definitions".* FROM "test_definitions" WHERE "test_definitions"."id" = ? LIMIT ?[0m [["id", 3], ["LIMIT", 1]] | |
D, [2016-03-04T12:44:54.551562 #36577] DEBUG -- : [1m[36mModuleTestDefinition Load (0.1ms)[0m [1m[34mSELECT "module_test_definitions".* FROM "module_test_definitions" WHERE "module_test_definitions"."test_definition_id" = 3 ORDER BY "module_test_definitions"."order" ASC[0m | |
D, [2016-03-04T12:44:54.552261 #36577] DEBUG -- : [1m[36mModuleDefinition Load (0.1ms)[0m [1m[34mSELECT "module_definitions".* FROM "module_definitions" WHERE "module_definitions"."id" IN (8, 9, 7)[0m | |
.D, [2016-03-04T12:44:54.553186 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.553548 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "test_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.553697 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.553856 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.554159 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.554389 #36577] DEBUG -- : [1m[35m (0.1ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.554573 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.554859 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.554994 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.555148 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.555432 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_definitions" DEFAULT VALUES[0m | |
D, [2016-03-04T12:44:54.555564 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.555792 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.556243 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 11], ["test_definition_id", 4], ["order", 1]] | |
D, [2016-03-04T12:44:54.556374 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.556561 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.556958 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 12], ["test_definition_id", 4], ["order", 2]] | |
D, [2016-03-04T12:44:54.557096 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.557277 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m | |
D, [2016-03-04T12:44:54.557670 #36577] DEBUG -- : [1m[35mSQL (0.0ms)[0m [1m[32mINSERT INTO "module_test_definitions" ("module_definition_id", "test_definition_id", "order") VALUES (?, ?, ?)[0m [["module_definition_id", 10], ["test_definition_id", 4], ["order", 3]] | |
D, [2016-03-04T12:44:54.557800 #36577] DEBUG -- : [1m[35m (0.0ms)[0m [1m[36mcommit transaction[0m | |
D, [2016-03-04T12:44:54.560061 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[34mSELECT DISTINCT "test_definitions"."id" FROM "test_definitions" LEFT OUTER JOIN "module_test_definitions" ON "module_test_definitions"."test_definition_id" = "test_definitions"."id" LEFT OUTER JOIN "module_definitions" ON "module_definitions"."id" = "module_test_definitions"."module_definition_id" WHERE "test_definitions"."id" = ? LIMIT ?[0m [["id", 4], ["LIMIT", 1]] | |
D, [2016-03-04T12:44:54.561163 #36577] DEBUG -- : [1m[35mSQL (0.1ms)[0m [1m[34mSELECT "test_definitions"."id" AS t0_r0, "module_definitions"."id" AS t1_r0 FROM "test_definitions" LEFT OUTER JOIN "module_test_definitions" ON "module_test_definitions"."test_definition_id" = "test_definitions"."id" LEFT OUTER JOIN "module_definitions" ON "module_definitions"."id" = "module_test_definitions"."module_definition_id" WHERE "test_definitions"."id" = ? AND "test_definitions"."id" = 4[0m [["id", 4]] | |
. | |
Finished in 0.057964s, 69.0083 runs/s, 69.0083 assertions/s. | |
4 runs, 4 assertions, 0 failures, 0 errors, 0 skips |
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
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 'rails', github: 'rails/rails' | |
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 :test_definitions, force: true do |t| | |
end | |
create_table :module_test_definitions, force: true do |t| | |
t.integer :module_definition_id | |
t.integer :test_definition_id | |
t.integer :order | |
end | |
create_table :module_definitions, force: true do |t| | |
end | |
end | |
class TestDefinition < ActiveRecord::Base | |
has_many :module_test_definitions, -> { order(order: :asc) } | |
has_many :module_definitions, through: :module_test_definitions | |
end | |
class ModuleTestDefinition < ActiveRecord::Base | |
belongs_to :module_definition | |
belongs_to :test_definition | |
end | |
class ModuleDefinition < ActiveRecord::Base | |
has_many :module_test_definitions | |
end | |
class BugTest < Minitest::Test | |
def setup | |
@td = TestDefinition.create | |
@md_1 = ModuleDefinition.create | |
@md_2 = ModuleDefinition.create | |
@md_3 = ModuleDefinition.create | |
ModuleTestDefinition.create do |mtd| | |
mtd.module_definition = @md_2 | |
mtd.test_definition = @td | |
mtd.order = 1 | |
end | |
ModuleTestDefinition.create do |mtd| | |
mtd.module_definition = @md_3 | |
mtd.test_definition = @td | |
mtd.order = 2 | |
end | |
ModuleTestDefinition.create do |mtd| | |
mtd.module_definition = @md_1 | |
mtd.test_definition = @td | |
mtd.order = 3 | |
end | |
end | |
def test_lazy_loaded_through_with_order_on_through_model | |
lazy_loaded_module_definitions = TestDefinition.find(@td.id).module_definitions | |
assert_equal([@md_2, @md_3, @md_1], lazy_loaded_module_definitions.to_a) | |
end | |
def test_eager_loaded_through_with_order_on_through_model | |
eager_loaded_module_definitions = TestDefinition.eager_load(:module_definitions).find(@td.id).module_definitions | |
assert_equal([@md_2, @md_3, @md_1], eager_loaded_module_definitions.to_a) | |
end | |
def test_preloaded_through_with_order_on_through_model | |
preloaded_module_definitions = TestDefinition.preload(:module_definitions).find(@td.id).module_definitions | |
assert_equal([@md_2, @md_3, @md_1], preloaded_module_definitions.to_a) | |
end | |
def test_included_through_with_order_on_through_model | |
included_module_definitions = TestDefinition.includes(:module_definitions).find(@td.id).module_definitions | |
assert_equal([@md_2, @md_3, @md_1], included_module_definitions.to_a) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment