class HasManyThroughFixture
Public Instance Methods
load_has_and_belongs_to_many()
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 386 def load_has_and_belongs_to_many parrot = make_model "Parrot" parrot.has_and_belongs_to_many :treasures parrots = File.join FIXTURES_ROOT, "parrots" fs = ActiveRecord::FixtureSet.new parrot.connection, "parrots", parrot, parrots fs.table_rows end
make_model(name)
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 345 def make_model(name) Class.new(ActiveRecord::Base) { define_singleton_method(:name) { name } } end
test_has_many_through_with_default_table_name()
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 349 def test_has_many_through_with_default_table_name pt = make_model "ParrotTreasure" parrot = make_model "Parrot" treasure = make_model "Treasure" pt.table_name = "parrots_treasures" pt.belongs_to :parrot, anonymous_class: parrot pt.belongs_to :treasure, anonymous_class: treasure parrot.has_many :parrot_treasures, anonymous_class: pt parrot.has_many :treasures, through: :parrot_treasures parrots = File.join FIXTURES_ROOT, "parrots" fs = ActiveRecord::FixtureSet.new parrot.connection, "parrots", parrot, parrots rows = fs.table_rows assert_equal load_has_and_belongs_to_many["parrots_treasures"], rows["parrots_treasures"] end
test_has_many_through_with_renamed_table()
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 368 def test_has_many_through_with_renamed_table pt = make_model "ParrotTreasure" parrot = make_model "Parrot" treasure = make_model "Treasure" pt.belongs_to :parrot, anonymous_class: parrot pt.belongs_to :treasure, anonymous_class: treasure parrot.has_many :parrot_treasures, anonymous_class: pt parrot.has_many :treasures, through: :parrot_treasures parrots = File.join FIXTURES_ROOT, "parrots" fs = ActiveRecord::FixtureSet.new parrot.connection, "parrots", parrot, parrots rows = fs.table_rows assert_equal load_has_and_belongs_to_many["parrots_treasures"], rows["parrot_treasures"] end