Sha256: fd5ec683c9436eba04a4890fce3a82b186814356ad300971e0c2befae9a6c430

Contents?: true

Size: 906 Bytes

Versions: 6

Compression:

Stored size: 906 Bytes

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
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kasket-1.0.3.beta1 test/configuration_mixin_test.rb
kasket-1.0.2 test/configuration_mixin_test.rb
kasket-1.0.1 test/configuration_mixin_test.rb
kasket-1.0.0 test/configuration_mixin_test.rb
kasket-0.9.1 test/configuration_mixin_test.rb
kasket-0.9.0 test/configuration_mixin_test.rb