Sha256: e62a10a6c884e4c36840c7fff6460fa36668eeaa204f317c636a633a31938092

Contents?: true

Size: 890 Bytes

Versions: 7

Compression:

Stored size: 890 Bytes

Contents

require File.dirname(__FILE__) + '/helper'
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

7 entries across 7 versions & 1 rubygems

Version Path
kasket-0.8.4 test/configuration_mixin_test.rb
kasket-0.8.3 test/configuration_mixin_test.rb
kasket-0.8.2 test/configuration_mixin_test.rb
kasket-0.8.1 test/configuration_mixin_test.rb
kasket-0.8.0 test/configuration_mixin_test.rb
kasket-0.7.8 test/configuration_mixin_test.rb
kasket-0.7.7 test/configuration_mixin_test.rb