Sha256: 050a417e4ae6d60cd614b27608cd764703597446bce9b7e9c4fd5684bebbe72b

Contents?: true

Size: 936 Bytes

Versions: 3

Compression:

Stored size: 936 Bytes

Contents

require File.expand_path('../spec_helper', __FILE__)

describe ActiveRecord::Duplicate do
  let(:klass) { Class.new(ActiveRecord::Base) { self.table_name = 'records' } }


  describe :attr_duplicatable do
    it 'allows you to whitelist attributes' do
      klass.attr_duplicatable(:created_at, :updated_at)
    end


    it 'returns whitelisted attributes if called without arguments' do
      klass.attr_duplicatable(:created_at, :updated_at)
      
      klass.attr_duplicatable.must_equal([:created_at, :updated_at])
    end
  end


  describe :duplicatable do
    it 'marks associations as non-duplicatable' do
      klass.duplicatable = false
      
      klass.duplicatable.must_equal(false)
    end
  end


  describe :duplicate do
    it 'duplicates records' do
      record = klass.create
      duplicate = record.duplicate
      
      duplicate.must_be_instance_of(klass)
      duplicate.wont_equal(record)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-duplicate-0.4.2 spec/acts_as_duplicator_spec.rb
activerecord-duplicate-0.4.1 spec/acts_as_duplicator_spec.rb
activerecord-duplicate-0.4.0 spec/acts_as_duplicator_spec.rb