Sha256: 1f235946b5d30973e840e59f553c539cd32f6ebbd19d794dfb3c4a822034ebf7

Contents?: true

Size: 1.16 KB

Versions: 11

Compression:

Stored size: 1.16 KB

Contents

require 'helper'

class TestActiveRecordCallbacHooks < Test::Unit::TestCase
  should "have all callbacks functioning properly" do
    book = Book.new(:name => "set cleo id", :author => "Rob Meyer")
    assert_nil book.cleo_id
    assert_nil Cleo::Reference.find(:first, :conditions => ["record_type = ? and record_id = ?", "Book", book.id])

    assert book.save!
    book_id = book.id

    assert book.cleo_id
    ref = Cleo::Reference.find(:first, :conditions => ["record_type = ? and record_id = ?", "Book", book_id])
    assert_not_nil ref

    assert book.destroy
    assert_nil Cleo::Reference.find(:first, :conditions => ["record_type = ? and record_id = ?", "Book", book_id])
    assert_nil Cleo.find(ref.id)
  end

  should "update cleo on record update" do
    book = Book.new(:name => "update cleo", :author => "Rob Meyer")
    assert book.save!
    cleo_record = Cleo.find(book.cleo_id)
    assert_not_nil cleo_record
    book.name = "Updated my Cleo"
    assert book.save!

    updated_cleo_record = Cleo.find(book.cleo_id)
    assert_equal book.name, updated_cleo_record.name
    assert_not_equal cleo_record.name, updated_cleo_record.name

    assert book.destroy
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
acts_as_cleo-2.3.0 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-2.2.1 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-2.2.0 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-2.1.2 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-2.1.1 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-2.1.0 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-2.0.1 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-2.0.0 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-1.2.0 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-1.1.0 test/unit/test_active_record_callback_hooks.rb
acts_as_cleo-1.0.0 test/unit/test_active_record_callback_hooks.rb