Sha256: 2c495973eff70993e4760c3a399ee978dacfe47795c8d079fabede574d1d5bd4

Contents?: true

Size: 785 Bytes

Versions: 20

Compression:

Stored size: 785 Bytes

Contents

require File.expand_path('../abstract_unit', __FILE__)

class TestCounterCache < ActiveSupport::TestCase
  fixtures :dorms, :rooms, :tariffs

  def test_update_counter
    tariff = tariffs(:flat)
    assert_equal(50, tariff.amount)
    Tariff.update_counters(tariff.id, :amount => 1)
    tariff.reload
    assert_equal(51, tariff.amount)
  end

  def test_increment_counter
    tariff = tariffs(:flat)
    assert_equal(50, tariff.amount)
    Tariff.increment_counter(:amount, tariff.id)

    tariff.reload
    assert_equal(51, tariff.amount)
  end

  def test_decrement_counter
    tariff = tariffs(:flat)
    assert_equal(50, tariff.amount)
    Tariff.decrement_counter(:amount, tariff.id)

    tariff.reload
    assert_equal(49, tariff.amount)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
composite_primary_keys-13.0.1 test/test_counter_cache.rb
composite_primary_keys-13.0.0 test/test_counter_cache.rb
composite_primary_keys-12.0.10 test/test_counter_cache.rb
composite_primary_keys-12.0.9 test/test_counter_cache.rb
composite_primary_keys-12.0.8 test/test_counter_cache.rb
composite_primary_keys-12.0.6 test/test_counter_cache.rb
composite_primary_keys-12.0.5 test/test_counter_cache.rb
composite_primary_keys-12.0.4 test/test_counter_cache.rb
composite_primary_keys-12.0.3 test/test_counter_cache.rb
composite_primary_keys-12.0.2 test/test_counter_cache.rb
composite_primary_keys-11.3.1 test/test_counter_cache.rb
composite_primary_keys-12.0.1 test/test_counter_cache.rb
composite_primary_keys-12.0.0 test/test_counter_cache.rb
composite_primary_keys-12.0.0.rc5 test/test_counter_cache.rb
composite_primary_keys-12.0.0.rc4 test/test_counter_cache.rb
composite_primary_keys-12.0.0.rc3 test/test_counter_cache.rb
composite_primary_keys-12.0.0.rc2 test/test_counter_cache.rb
composite_primary_keys-12.0.0.rc1 test/test_counter_cache.rb
composite_primary_keys-11.2.0 test/test_counter_cache.rb
composite_primary_keys-11.1.0 test/test_counter_cache.rb