Sha256: 911b6838467a45dd94b15a1fc3e97c82179b016af15e3ca3553f480434bc2f9a

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require File.expand_path("helper", File.dirname(__FILE__))
require "digest/md5"

class ConfigurationMixinTest < ActiveSupport::TestCase

  context "Generating cache keys" do

    should "not choke on empty numeric attributes" do
      expected_cache_key = "kasket-#{Kasket::Version::STRING}/posts/version=3558/blog_id=null"
      query_attributes   = [ [:blog_id, ''] ]

      assert_equal expected_cache_key, Post.kasket_key_for(query_attributes)
    end

    should "not generate keys longer that 255" do
      very_large_number = (1..999).to_a.join
      query_attributes  = [ [:blog_id, very_large_number] ]

      assert(Post.kasket_key_for(query_attributes).size < 255)
    end

    should "not generate keys with spaces" do
      query_attributes = [ [:title, 'this key has speces'] ]

      assert(!(Post.kasket_key_for(query_attributes) =~ /\s/))
    end

    should "downcase string attributes" do
      query_attributes = [ [:title, 'ThIs'] ]
      expected_cache_key = "kasket-#{Kasket::Version::STRING}/posts/version=3558/title='this'"

      assert_equal expected_cache_key, Post.kasket_key_for(query_attributes)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kasket-1.0.4 test/configuration_mixin_test.rb
kasket-1.0.3 test/configuration_mixin_test.rb
kasket-1.0.3.beta2 test/configuration_mixin_test.rb