Sha256: a6a0df1a689c470777b05dcddbcb3e80380ac2c52a446a284e1dc5f2e4af1e14

Contents?: true

Size: 1002 Bytes

Versions: 39

Compression:

Stored size: 1002 Bytes

Contents

require 'test_helper'

class CassandraObject::CallbacksTest < CassandraObject::TestCase
  class TestIssue < CassandraObject::Base
    self.column_family = 'Issues'
    key :uuid
    string :description

    %w(after_save after_create after_update after_destroy).each do |method|
      send(method) do
        callback_history << method
      end
    end

    def reset_callback_history
      @callback_history = []
    end

    def callback_history
      @callback_history ||= []
    end
  end

  test 'create' do
    issue = TestIssue.create

    assert_equal ['after_create', 'after_save'], issue.callback_history
  end

  test 'update' do
    issue = TestIssue.create
    issue.reset_callback_history

    issue.update_attribute :description, 'foo'

    assert_equal ['after_update', 'after_save'], issue.callback_history
  end

  test 'destroy' do
    issue = TestIssue.create
    issue.reset_callback_history

    issue.destroy

    assert_equal ['after_destroy'], issue.callback_history
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
gotime-cassandra_object-2.10.9 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.8 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.7 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.6 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.5 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.4 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.3 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.2 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.1 test/unit/callbacks_test.rb
gotime-cassandra_object-2.10.0 test/unit/callbacks_test.rb
gotime-cassandra_object-2.9.2 test/unit/callbacks_test.rb
gotime-cassandra_object-2.9.1 test/unit/callbacks_test.rb
gotime-cassandra_object-2.9.0 test/unit/callbacks_test.rb
gotime-cassandra_object-2.8.6 test/unit/callbacks_test.rb
gotime-cassandra_object-2.8.5 test/unit/callbacks_test.rb
gotime-cassandra_object-2.8.4 test/callbacks_test.rb
gotime-cassandra_object-2.8.3 test/callbacks_test.rb
gotime-cassandra_object-2.8.2 test/callbacks_test.rb
gotime-cassandra_object-2.8.1 test/callbacks_test.rb
gotime-cassandra_object-2.8.0 test/callbacks_test.rb