Sha256: 4723bdd11da455846be0726763c56e5f49c35ee0d9186c399685d8e738e62aa8

Contents?: true

Size: 1.04 KB

Versions: 27

Compression:

Stored size: 1.04 KB

Contents

require 'test_helper'

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

    %w(before_validation after_validation 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 ['before_validation', 'after_validation', 'after_save', 'after_create'], issue.callback_history
  end

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

    issue.update_attribute :description, 'foo'

    assert_equal ['after_save', 'after_update'], 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

27 entries across 27 versions & 2 rubygems

Version Path
gotime-cassandra_object-4.12.2 test/unit/callbacks_test.rb
gotime-cassandra_object-4.12.1 test/unit/callbacks_test.rb
gotime-cassandra_object-4.12.0 test/unit/callbacks_test.rb
gotime-cassandra_object-4.11.6 test/unit/callbacks_test.rb
gotime-cassandra_object-4.11.5 test/unit/callbacks_test.rb
gotime-cassandra_object-4.11.4 test/unit/callbacks_test.rb
gotime-cassandra_object-4.11.3 test/unit/callbacks_test.rb
gotime-cassandra_object-4.11.2 test/unit/callbacks_test.rb
gotime-cassandra_object-4.11.1 test/unit/callbacks_test.rb
gotime-cassandra_object-4.11.0 test/unit/callbacks_test.rb
gotime-cassandra_object-4.10.5 test/unit/callbacks_test.rb
gotime-cassandra_object-4.10.4 test/unit/callbacks_test.rb
gotime-cassandra_object-4.10.3 test/unit/callbacks_test.rb
gotime-cassandra_object-4.10.2 test/unit/callbacks_test.rb
gotime-cassandra_object-4.10.1 test/unit/callbacks_test.rb
cassandra_object_rails-0.0.1 test/unit/callbacks_test.rb
gotime-cassandra_object-4.10.0 test/unit/callbacks_test.rb
gotime-cassandra_object-4.9.2 test/unit/callbacks_test.rb
gotime-cassandra_object-4.9.1 test/unit/callbacks_test.rb
gotime-cassandra_object-4.9.0 test/unit/callbacks_test.rb