Sha256: d859e18bc1ce04a704115643eb7b526292409030f1d315c4f6f7e814def2e1ee

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

require "cases/helper"
require 'models/topic'

module ActiveRecord
  class CloneTest < ActiveRecord::TestCase
    fixtures :topics

    def test_persisted
      topic = Topic.order(:id).first
      cloned = topic.clone
      assert topic.persisted?, 'topic persisted'
      assert cloned.persisted?, 'topic persisted'
      assert !cloned.new_record?, 'topic is not new'
    end

    def test_stays_frozen
      topic = Topic.order(:id).first
      topic.freeze

      cloned = topic.clone
      assert cloned.persisted?, 'topic persisted'
      assert !cloned.new_record?, 'topic is not new'
      assert cloned.frozen?, 'topic should be frozen'
    end

    def test_shallow
      topic = Topic.order(:id).first
      cloned = topic.clone
      topic.author_name = 'Aaron'
      assert_equal 'Aaron', cloned.author_name
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-nuodb-adapter-2.0.3 test/cases/clone_test.rb
activerecord-nuodb-adapter-2.0 test/cases/clone_test.rb