Sha256: 79ba2aa51e415d81e836b0f7642a900c3f81d8a5a6af6f069164a67078c4d4f9
Contents?: true
Size: 780 Bytes
Versions: 11
Compression:
Stored size: 780 Bytes
Contents
require_relative 'helper/copyable_spec_helper' describe 'copyable:after_copy' do before(:each) do undefine_copyable_in CopyableCoin class CopyableCoin < ActiveRecord::Base copyable do disable_all_callbacks_and_observers_except_validate columns({ kind: lambda { |orig| "Copy of #{orig.kind}" }, year: :copy, }) associations({ }) after_copy do |original_model, new_model| raise "#{original_model.kind} #{new_model.kind}" end end end end it 'should execute the after_copy block after copying' do coin = CopyableCoin.create!(kind: 'nickel', year: 1883) expect { coin.create_copy! }.to raise_error(RuntimeError, "nickel Copy of nickel") end end
Version data entries
11 entries across 11 versions & 1 rubygems