diff --git a/activerecord/lib/active_record/fixture_set/table_row.rb b/activerecord/lib/active_record/fixture_set/table_row.rb index 67154af74b..6b4c7a935f 100644 --- a/activerecord/lib/active_record/fixture_set/table_row.rb +++ b/activerecord/lib/active_record/fixture_set/table_row.rb @@ -35,7 +35,7 @@ module ActiveRecord end def timestamp_column_names - ModelMetadata.new(@association.through_reflection.klass).timestamp_column_names + @association.through_reflection.klass.all_timestamp_attributes_in_model end end diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index df415daad9..7f56fea4aa 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -19,8 +19,6 @@ require "models/developer" require "models/dog" require "models/doubloon" require "models/joke" -require "models/loot" -require "models/loot_parrot" require "models/matey" require "models/other_dog" require "models/parrot" @@ -1103,8 +1101,7 @@ class FoxyFixturesTest < ActiveRecord::TestCase # Set to false to blow away fixtures cache and ensure our fixtures are loaded self.use_transactional_tests = false fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers, - :developers, :"admin/accounts", :"admin/users", :live_parrots, :dead_parrots, :books, - :loots + :developers, :"admin/accounts", :"admin/users", :live_parrots, :dead_parrots, :books if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" require "models/uuid_parent" @@ -1193,11 +1190,15 @@ class FoxyFixturesTest < ActiveRecord::TestCase end def test_supports_timestamps_in_join_tables - assert_not_nil parrots(:looter).created_at - assert_not_nil loots(:bounty).created_at - assert_equal loots(:bounty), parrots(:looter).loots.first - assert_equal loots(:bounty), parrots(:looter).loot_parrots.first.loot - assert_not_nil parrots(:looter).loot_parrots.first.created_at + assert_not_nil developers(:david).created_at + assert_not_nil computers(:laptop).created_at + + klass = Class.new(ActiveRecord::Base) do + self.table_name = "computers_developers" + end + + computers_developers = klass.find_by(developer_id: developers(:david), computer_id: computers(:laptop)) + assert_not_nil computers_developers.created_at end def test_supports_inline_habtm diff --git a/activerecord/test/fixtures/loots.yml b/activerecord/test/fixtures/loots.yml deleted file mode 100644 index cbdd7f2943..0000000000 --- a/activerecord/test/fixtures/loots.yml +++ /dev/null @@ -1,2 +0,0 @@ -bounty: - value: 123.45 diff --git a/activerecord/test/fixtures/parrots.yml b/activerecord/test/fixtures/parrots.yml index 554d6b63a9..4f0a090e03 100644 --- a/activerecord/test/fixtures/parrots.yml +++ b/activerecord/test/fixtures/parrots.yml @@ -25,9 +25,6 @@ polly: treasures: sapphire, ruby <<: *DEAD_PARROT -looter: - loots: bounty - DEFAULTS: &DEFAULTS treasures: sapphire, ruby parrot_sti_class: LiveParrot diff --git a/activerecord/test/models/loot.rb b/activerecord/test/models/loot.rb deleted file mode 100644 index 19c10e277a..0000000000 --- a/activerecord/test/models/loot.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class Loot < ActiveRecord::Base - has_many :loot_parrots, class_name: "LootParrot" - has_many :parrots, through: :loot_parrots -end diff --git a/activerecord/test/models/loot_parrot.rb b/activerecord/test/models/loot_parrot.rb deleted file mode 100644 index a0d0ef0f13..0000000000 --- a/activerecord/test/models/loot_parrot.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class LootParrot < ActiveRecord::Base - belongs_to :parrot - belongs_to :loot -end diff --git a/activerecord/test/models/parrot.rb b/activerecord/test/models/parrot.rb index 59d6cb2777..addeb3eea8 100644 --- a/activerecord/test/models/parrot.rb +++ b/activerecord/test/models/parrot.rb @@ -5,8 +5,7 @@ class Parrot < ActiveRecord::Base has_and_belongs_to_many :pirates has_and_belongs_to_many :treasures - has_many :loot_parrots, class_name: "LootParrot" - has_many :loots, through: :loot_parrots + has_many :loots, as: :looter, class_name: "Treasure" alias_attribute :title, :name validates_presence_of :name diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index 47c0fe5374..f72cda1e3c 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -267,11 +267,13 @@ ActiveRecord::Schema.define do t.integer :developer, null: false t.integer :extendedWarranty, null: false t.integer :timezone + t.timestamps end create_table :computers_developers, id: false, force: true do |t| t.references :computer t.references :developer + t.timestamps end create_table :contracts, force: true do |t| @@ -562,17 +564,6 @@ ActiveRecord::Schema.define do t.timestamps null: true end - create_table :loots, force: true do |t| - t.float :value - t.timestamps - end - - create_table :loot_parrots, force: true do |t| - t.references :loot, null: false - t.references :parrot, null: false - t.timestamps - end - create_table :magazines, force: true do |t| end