Sha256: 2a190a91fc8aa5ccf889afe1d6406d410fccbd7f709ebe0ce4f4440ee0ecf686

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require 'test_helper'
require "cassandra_object/railties/controller_runtime"

class CassandraObject::Railties::ControllerRuntimeTest < MiniTest::Unit::TestCase
  class TestRuntime
    def self.log_process_action(payload)
      ['sweet']
    end

    def cleanup_view_runtime
      12
    end

    def append_info_to_payload(payload)
      payload[:foo] = 42
    end
  end

  class CassandraRuntime < TestRuntime
    include CassandraObject::Railties::ControllerRuntime
  end

  def test_cleanup_view_runtime
    runtime = CassandraRuntime.new
    CassandraObject::LogSubscriber.runtime = 10

    runtime.cleanup_view_runtime

    assert_equal 0, CassandraObject::LogSubscriber.runtime
  end

  def test_append_info_to_payload
    runtime = CassandraRuntime.new
    payload = {}
    runtime.append_info_to_payload(payload)

    assert_equal 42, payload[:foo]
    assert payload.key?(:cassandra_object_runtime)
  end

  def test_log_process_action
    payload = {cassandra_object_runtime: 12.3}
    messages = CassandraRuntime.log_process_action(payload)

    assert_equal 2, messages.size
    assert_equal "CassandraObject: 12.3ms", messages.last
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.12.2 test/unit/railties/controller_runtime_test.rb
gotime-cassandra_object-4.12.1 test/unit/railties/controller_runtime_test.rb
gotime-cassandra_object-4.12.0 test/unit/railties/controller_runtime_test.rb
gotime-cassandra_object-4.11.6 test/unit/railties/controller_runtime_test.rb