Sha256: 16e25c47f5b258e5cd040b9a53d5abf417a4f95dcb1f4a246038809dbdedf212
Contents?: true
Size: 1.03 KB
Versions: 29
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require 'spec_helper' require_relative './reverse_population_spec_models' describe 'Association reverse population' do describe 'has_many/belongs_to' do it 'populates child in parent' do company = ReversePopulationSpec::Company.create! email = ReversePopulationSpec::Email.create!(company: company) expect(company.emails).to eq([email]) end end describe 'has_one/belongs_to' do it 'populates child in parent' do company = ReversePopulationSpec::Company.create! founder = ReversePopulationSpec::Founder.create!(company: company) expect(company.founder).to eq(founder) end end describe 'has_and_belongs_to_many' do it 'persists association on the other side' do animal = ReversePopulationSpec::Animal.create! zoo = ReversePopulationSpec::Zoo.create! animal.zoos << zoo animal.save! expect(zoo.animals).to eq([animal]) zoo = ReversePopulationSpec::Zoo.find(zoo.id) expect(zoo.animals).to eq([animal]) end end end
Version data entries
29 entries across 29 versions & 1 rubygems