Sha256: 1363fed1037fc39959d53c66b48372647507ab8cee9461ad34c13e607e283ae3

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

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

class HasOneAssociationTest < ActiveSupport::TestCase
  def setup
    @user = User.create :name => 'hooopo', :email => 'hoooopo@gmail.com'
    @account = @user.create_account
  end

  def test_should_fetch_account_from_cache
    clean_user = @user.reload
    assert_no_queries do
      clean_user.account
    end
  end

  def test_should_fetch_has_one_through
    user = User.create :name => 'hooopo', :email => 'hoooopo@gmail.com', forked_from_user: @user
    clean_user = user.reload
    assert_equal User, clean_user.forked_from_user.class
    assert_equal @user.id, user.forked_from_user.id
    # clean_user = user.reload
    # assert_no_queries do
    #   clean_user.forked_from_user
    # end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
second_level_cache-2.1.8 test/has_one_association_test.rb