Sha256: 9e0ff73dd9a227cf7687aa9ace77c144fee62b28552ff76848d1d4763c67e280

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 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::PROTOCOL}/posts/version=#{POST_VERSION}/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::PROTOCOL}/posts/version=#{POST_VERSION}/title='this'"

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kasket-3.0.0 test/configuration_mixin_test.rb
kasket-2.2.1 test/configuration_mixin_test.rb
kasket-2.2.0 test/configuration_mixin_test.rb
kasket-2.1.2 test/configuration_mixin_test.rb
kasket-2.1.1 test/configuration_mixin_test.rb
kasket-2.1.0 test/configuration_mixin_test.rb