Sha256: 3bd652cf05b245fddf4c2af2a48a75a023160db818295e02269a4f3cf884c4b2

Contents?: true

Size: 755 Bytes

Versions: 16

Compression:

Stored size: 755 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

16 entries across 16 versions & 1 rubygems

Version Path
composite_primary_keys-14.0.9 test/test_counter_cache.rb
composite_primary_keys-14.0.8 test/test_counter_cache.rb
composite_primary_keys-13.0.8 test/test_counter_cache.rb
composite_primary_keys-14.0.7 test/test_counter_cache.rb
composite_primary_keys-14.0.6 test/test_counter_cache.rb
composite_primary_keys-13.0.7 test/test_counter_cache.rb
composite_primary_keys-13.0.6 test/test_counter_cache.rb
composite_primary_keys-14.0.5 test/test_counter_cache.rb
composite_primary_keys-13.0.5 test/test_counter_cache.rb
composite_primary_keys-13.0.4 test/test_counter_cache.rb
composite_primary_keys-14.0.4 test/test_counter_cache.rb
composite_primary_keys-14.0.3 test/test_counter_cache.rb
composite_primary_keys-13.0.3 test/test_counter_cache.rb
composite_primary_keys-14.0.2 test/test_counter_cache.rb
composite_primary_keys-13.0.2 test/test_counter_cache.rb
composite_primary_keys-14.0.1 test/test_counter_cache.rb