Sha256: b94150b54f9f95e9a3676b13e181e5173ed455a83c2d1e3059d61b2e38e6fe25
Contents?: true
Size: 813 Bytes
Versions: 22
Compression:
Stored size: 813 Bytes
Contents
require 'spec_helper' describe RailsCoreExtensions::TransferRecords do class Parent < ActiveRecord::Base has_many :children, dependent: :destroy def transfer_children_from(old_parent) RailsCoreExtensions::TransferRecords.new(self, Child).transfer_from([old_parent]) end end class Child < ActiveRecord::Base belongs_to :parent end let(:old) { Parent.create! } let(:new) { Parent.create! } before do connect_to_sqlite new.children.create! old.children.create! end after do old.destroy new.destroy end it 'should transfer records' do expect(new.children.size).to eq 1 expect(old.children.size).to eq 1 new.transfer_children_from(old) expect(new.reload.children.size).to eq 2 expect(old.reload.children.size).to eq 0 end end
Version data entries
22 entries across 22 versions & 1 rubygems