Sha256: 98ec2fe0eb86ce47e910d8f6d5646bc6da45b3f51b924ec58d88d7aac8e81764

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

require 'test_helper'

class CassandraObject::CoreTest < CassandraObject::TestCase
  test 'initialiaze' do
    issue = Issue.new

    assert issue.new_record?
    assert !issue.destroyed?
  end

  test 'initialize yields self' do
    issue = Issue.new { |i| i.description = 'bar' }
    assert_equal 'bar', issue.description
  end

  test 'dup' do
    issue = Issue.create description: 'foo'

    dup_issue = issue.dup

    assert dup_issue.new_record?
    assert_not_equal issue.id, dup_issue.id
    assert_nil dup_issue.created_at
    assert_nil dup_issue.updated_at
    assert_equal 'foo', issue.description
  end

  test 'equality of new records' do
    assert_not_equal Issue.new, Issue.new
  end

  test 'equality' do
    first_issue = Issue.create
    second_issue = Issue.create

    assert_equal first_issue, first_issue
    assert_equal first_issue, Issue.find(first_issue.id)
    assert_not_equal first_issue, second_issue
  end

  test 'to_param' do
    issue = Issue.new
    assert_equal issue.id, issue.to_param
  end

  test 'hash' do
    issue = Issue.create
    assert_equal issue.id.hash, issue.hash
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.9.0 test/unit/core_test.rb
gotime-cassandra_object-4.8.1 test/unit/core_test.rb
gotime-cassandra_object-4.8.0 test/unit/core_test.rb
gotime-cassandra_object-4.7.3 test/unit/core_test.rb
gotime-cassandra_object-4.7.2 test/unit/core_test.rb
gotime-cassandra_object-4.7.1 test/unit/core_test.rb
gotime-cassandra_object-4.7.0 test/unit/core_test.rb
gotime-cassandra_object-4.6.0 test/unit/core_test.rb