loading through base class
This commit is contained in:
@@ -38,7 +38,7 @@ RSpec.describe HasAuxTable do
|
||||
end
|
||||
|
||||
t.create_aux :boat do |t|
|
||||
t.string :boat_type
|
||||
t.boolean :only_freshwater
|
||||
end
|
||||
end
|
||||
|
||||
@@ -771,6 +771,23 @@ RSpec.describe HasAuxTable do
|
||||
end
|
||||
end
|
||||
|
||||
it "loads the aux data separately when loaded from main class" do
|
||||
car =
|
||||
Car.create!(name: "Honda Civic", fuel_type: "gasoline", engine_size: 2.0)
|
||||
boat = Boat.create!(name: "Yacht", only_freshwater: true)
|
||||
expect(Vehicle.count).to eq(2)
|
||||
expect(Car.count).to eq(1)
|
||||
expect(Boat.count).to eq(1)
|
||||
|
||||
expect(count_queries { car = Vehicle.find(car.id) }).to eq(1)
|
||||
expect(car.fuel_type).to eq("gasoline")
|
||||
expect(car.engine_size).to eq(2.0)
|
||||
expect(car.name).to eq("Honda Civic")
|
||||
|
||||
expect(count_queries { boat = Vehicle.find(boat.id) }).to eq(1)
|
||||
expect(boat.only_freshwater).to eq(true)
|
||||
end
|
||||
|
||||
describe "namespaced models" do
|
||||
it "works with namespaced models" do
|
||||
fork1 =
|
||||
|
||||
Reference in New Issue
Block a user