Sha256: e2f1ac43e1c3f209efe8cb4adff891ffe9de26be35835726a2591c422f7ec038

Contents?: true

Size: 1.03 KB

Versions: 13

Compression:

Stored size: 1.03 KB

Contents

# -*- encoding : utf-8 -*-
require 'test_helper'

class PersistenceTest < ActiveSupport::TestCase
  def setup
    @user = User.create :name => 'csdn', :email => 'test@csdn.com'
    @topic = Topic.create :title => "csdn"
  end

  def test_should_reload_object
    User.where(id: @user.id).update_all(email: 'different@csdn.com')
    assert_equal 'different@csdn.com', @user.reload.email
  end

  def test_should_reload_object_associations
    User.increment_counter :books_count, @user.id
    assert_equal 0, @user.books_count
    assert_equal 1, @user.reload.books_count
  end

  def test_should_update_cache_after_touch
    old_updated_time = @user.updated_at
    @user.touch
    assert !(old_updated_time == @user.updated_at)
    new_user = User.find @user.id
    assert_equal new_user, @user
  end

  def test_should_update_cache_after_update_column
    @user.update_column :name, "new_name"
    new_user = User.find @user.id
    assert_equal new_user, @user
  end

  def test_should_return_true_if_touch_ok
    assert @topic.touch == true
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
second_level_cache-2.1.16 test/persistence_test.rb
second_level_cache-2.1.15 test/persistence_test.rb
second_level_cache-2.1.14 test/persistence_test.rb
second_level_cache-2.1.13 test/persistence_test.rb
second_level_cache-2.1.10 test/persistence_test.rb
second_level_cache-2.1.9 test/persistence_test.rb
second_level_cache-2.1.8 test/persistence_test.rb
second_level_cache-2.1.7 test/persistence_test.rb
second_level_cache-2.1.6 test/persistence_test.rb
second_level_cache-2.1.5 test/persistence_test.rb
second_level_cache-2.1.2 test/persistence_test.rb
second_level_cache-2.1.1 test/persistence_test.rb
second_level_cache-2.1.0 test/persistence_test.rb