class CounterCacheTest

Private Instance Methods

assert_touching(record, *attributes) { || ... } click to toggle source
# File activerecord/test/cases/counter_cache_test.rb, line 357
def assert_touching(record, *attributes)
  record.update_columns attributes.map { |attr| [ attr, 5.minutes.ago ] }.to_h
  touch_times = attributes.map { |attr| [ attr, record.public_send(attr) ] }.to_h

  yield

  touch_times.each do |attr, previous_touch_time|
    assert_operator previous_touch_time, :<, record.reload.public_send(attr)
  end
end