Sha256: 09bccff9bd6d6cf9a2025e10ad36c28dfc07879506834c6b0a866a29e6771f2b

Contents?: true

Size: 921 Bytes

Versions: 4

Compression:

Stored size: 921 Bytes

Contents

require 'test_helper'
require 'timeout'

class QorCacheFieldsTest < ActiveSupport::TestCase
  test "cache field should works" do
    product = FactoryGirl.create(:product, :code => '1111')
    product.color_variations << FactoryGirl.build(:color_variation)
    product.save

    color_variation = product.color_variations.first

    assert_equal color_variation.product_code, '1111'
  end

  test "cached field should be updated after update" do
    product = FactoryGirl.create(:product, :code => '1111')
    product.color_variations << FactoryGirl.build(:color_variation)
    product.save

    color_variation = product.color_variations.first
    assert_equal color_variation.product_code, '1111'

    product.update_attribute(:code, '2222')
    assert_equal color_variation.reload.product_code, '2222'

    product.update_attribute(:code, '3333')
    assert_equal color_variation.reload.product_code, '3333'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qor_cache-0.0.4 test/qor_cache_fields_test.rb
qor_cache-0.0.3 test/qor_cache_fields_test.rb
qor_cache-0.0.2 test/qor_cache_fields_test.rb
qor_cache-0.0.1 test/qor_cache_fields_test.rb