Sha256: 55cae6c0ff69a7ed7082b095a091043adf1e06ed2e0e21f5743554d94f7a4bc7

Contents?: true

Size: 769 Bytes

Versions: 6

Compression:

Stored size: 769 Bytes

Contents

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

class TestCalculations < ActiveSupport::TestCase
  fixtures :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

6 entries across 6 versions & 1 rubygems

Version Path
composite_primary_keys-8.1.8 test/test_counter_cache.rb
composite_primary_keys-8.1.7 test/test_counter_cache.rb
composite_primary_keys-10.0.5 test/test_counter_cache.rb
composite_primary_keys-9.0.10 test/test_counter_cache.rb
composite_primary_keys-10.0.4 test/test_counter_cache.rb
composite_primary_keys-9.0.9 test/test_counter_cache.rb