Sha256: 8c6dc0f7767252b72dc0bb96604d14e4808d5e8a8fdd23cac7ddfe3541a5f158

Contents?: true

Size: 845 Bytes

Versions: 14

Compression:

Stored size: 845 Bytes

Contents

# Test cases devised by Santiago that broke the Composite Primary Keys
# code at one point in time. But no more!!!
require File.expand_path('../abstract_unit', __FILE__)

class TestTouch < ActiveSupport::TestCase
  fixtures :products, :tariffs

  def test_touching_a_record_updates_its_timestamp
    tariff                = tariffs(:flat)
    previous_amount       = tariff.amount
    previously_updated_at = tariff.updated_at

    tariff.amount         = previous_amount + 1
    tariff.touch
    sleep 0.1
    assert_not_equal previously_updated_at, tariff.updated_at
    assert_equal previous_amount + 1, tariff.amount
    assert tariff.amount_changed?, 'tarif amount should have changed'
    assert tariff.changed?, 'tarif should be marked as changed'
    tariff.reload
    assert_not_equal previously_updated_at, tariff.updated_at
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
composite_primary_keys-6.0.8 test/test_touch.rb
composite_primary_keys-6.0.7 test/test_touch.rb
composite_primary_keys-7.0.2 test/test_touch.rb
composite_primary_keys-7.0.1 test/test_touch.rb
composite_primary_keys-7.0.0 test/test_touch.rb
composite_primary_keys-6.0.6 test/test_touch.rb
composite_primary_keys-6.0.5 test/test_touch.rb
composite_primary_keys-6.0.3 test/test_touch.rb
composite_primary_keys-5.0.14 test/test_touch.rb
composite_primary_keys-6.0.1 test/test_touch.rb
composite_primary_keys-6.0.0 test/test_touch.rb
composite_primary_keys-5.0.13 test/test_touch.rb
composite_primary_keys-5.0.12 test/test_touch.rb
composite_primary_keys-5.0.11 test/test_touch.rb