test/test_padrino_cache.rb in padrino-cache-0.12.8.1 vs test/test_padrino_cache.rb in padrino-cache-0.12.9
- old
+ new
@@ -477,6 +477,48 @@
while adapter.respond_to? :adapter
adapter = adapter.adapter
end
assert_kind_of Moneta::Adapters::Memory, adapter
end
+
+ it "should check key existence" do
+ count1, count2 = 0, 0
+ mock_app do
+ register Padrino::Cache
+ enable :caching
+ get "/" do
+ cache(:foo) do
+ count1 += 1
+ nil
+ end
+ count1.inspect
+ end
+
+ get "/object" do
+ cache_object(:bar) do
+ count2 += 1
+ nil
+ end
+ count2.inspect
+ end
+ end
+ 2.times { get "/" }
+ assert_equal "1", body
+ 2.times { get "/object" }
+ assert_equal "1", body
+ end
+
+ it 'should cache full mime type of content_type' do
+ mock_app do
+ register Padrino::Cache
+ enable :caching
+ get '/foo', :cache => true do
+ content_type :json, :charset => 'utf-8'
+ '{}'
+ end
+ end
+ get "/foo"
+ assert_equal 'application/json;charset=utf-8', last_response.content_type
+ get "/foo"
+ assert_equal 'application/json;charset=utf-8', last_response.content_type
+ end
end