qor_cache 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -1
- data/README.md +19 -0
- data/app/controllers/qor/cache_controller.rb +9 -0
- data/app/helpers/qor/cache_helper.rb +34 -0
- data/config/qor/cache.rb +7 -0
- data/config/qor/test.rb +8 -16
- data/config/routes.rb +3 -0
- data/lib/qor_cache/configuration.rb +4 -0
- data/lib/qor_cache/{railtie.rb → engine.rb} +1 -1
- data/lib/qor_cache/kernel.rb +4 -3
- data/lib/qor_cache/version.rb +1 -1
- data/lib/qor_cache.rb +1 -1
- data/test/dummy/app/controllers/application_controller.rb +24 -0
- data/test/dummy/app/helpers/application_helper.rb +3 -0
- data/test/dummy/app/models/color_variation.rb +0 -1
- data/test/dummy/app/views/application/expires_in.html.erb +3 -0
- data/test/dummy/app/views/application/helpers.html.erb +3 -0
- data/test/dummy/app/views/application/index.html.erb +3 -0
- data/test/dummy/app/views/application/nocache.html.erb +3 -0
- data/test/dummy/app/views/application/products.html.erb +3 -0
- data/test/dummy/app/views/application/with_block.html.erb +9 -0
- data/test/dummy/app/views/qor_cache_includes/expires_in_time.html.erb +2 -0
- data/test/dummy/app/views/qor_cache_includes/helper_time.html.erb +1 -0
- data/test/dummy/app/views/qor_cache_includes/nocache_time.html.erb +1 -0
- data/test/dummy/app/views/qor_cache_includes/products_time.html.erb +1 -0
- data/test/dummy/app/views/qor_cache_includes/time.html.erb +1 -0
- data/test/dummy/config/application.rb +3 -3
- data/test/dummy/config/environments/development.rb +1 -1
- data/test/dummy/config/environments/test.rb +1 -1
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/test/dummy/config/qor/cache.rb +25 -3
- data/test/dummy/config/routes.rb +6 -56
- data/test/dummy/tmp/cache/.gitkeep +0 -0
- data/test/integration_test.rb +135 -0
- metadata +33 -5
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -29,6 +29,11 @@ Qor Cache
|
|
|
29
29
|
cache_field :product_code, :from => [:product, :code]
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
cache_includes "filename", :no_cache => true, :expires_in => 5.minutes do |app|
|
|
33
|
+
...
|
|
34
|
+
end
|
|
35
|
+
cache_includes "filename", "cache_key..."
|
|
36
|
+
|
|
32
37
|
|
|
33
38
|
# app/models/color_variation.rb
|
|
34
39
|
def heavy_method_related_to_products
|
|
@@ -56,6 +61,15 @@ Qor Cache
|
|
|
56
61
|
xxxxx
|
|
57
62
|
end
|
|
58
63
|
|
|
64
|
+
qor_cache_includes "filename"
|
|
65
|
+
|
|
66
|
+
## TODO
|
|
67
|
+
|
|
68
|
+
Support render :file, :url for render_qor_cache_includes
|
|
69
|
+
:partial => "filename"
|
|
70
|
+
:filename => "filename"
|
|
71
|
+
:url => "http://xxx" -> SSI ? Rewrite ?
|
|
72
|
+
|
|
59
73
|
## Contributing
|
|
60
74
|
|
|
61
75
|
1. Fork it
|
|
@@ -63,3 +77,8 @@ Qor Cache
|
|
|
63
77
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
64
78
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
65
79
|
5. Create new Pull Request
|
|
80
|
+
|
|
81
|
+
## Author ##
|
|
82
|
+
Jinzhu <http://github.com/jinzhu>
|
|
83
|
+
|
|
84
|
+
* A Product From ThePlant <http://theplant.jp>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Qor
|
|
2
|
+
module CacheHelper
|
|
3
|
+
def qor_cache_includes(filename, &blk)
|
|
4
|
+
env = respond_to?(:request) && request.respond_to?(:env) ? request.env : {}
|
|
5
|
+
path = URI.parse(filename).path rescue filename
|
|
6
|
+
node = Qor::Cache::Configuration.deep_find(:cache_includes, path)[0]
|
|
7
|
+
|
|
8
|
+
cache_key = node.nil? ? "" : qor_cache_key(*node.data.select {|x| x.is_a? String }, &node.block)
|
|
9
|
+
cache_key += qor_cache_key(&blk) if block_given?
|
|
10
|
+
key = "/qor_cache_includes/#{filename}?#{cache_key}"
|
|
11
|
+
|
|
12
|
+
if env['QOR_CACHE_SSI_ENABLED']
|
|
13
|
+
%Q[<!--# include virtual="#{key}" -->]
|
|
14
|
+
elsif env['QOR_CACHE_ESI_ENABLED']
|
|
15
|
+
%Q[<esi:include src="#{key}"/>]
|
|
16
|
+
else
|
|
17
|
+
render_qor_cache_includes(path, key)
|
|
18
|
+
end.html_safe
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def render_qor_cache_includes(path, cache_key)
|
|
22
|
+
options = Qor::Cache::Configuration.first(:cache_includes, path).try(:options) || {}
|
|
23
|
+
|
|
24
|
+
format = params["format"] || "html" rescue "html"
|
|
25
|
+
file = Dir[File.join(Rails.root, "app/views/qor_cache_includes", "#{path}.#{format}*")][0]
|
|
26
|
+
|
|
27
|
+
if options.delete(:no_cache) == true
|
|
28
|
+
Erubis::Eruby.new(File.read(file)).result(binding)
|
|
29
|
+
else
|
|
30
|
+
Rails.cache.fetch(cache_key, options) { Erubis::Eruby.new(File.read(file)).result(binding) }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/config/qor/cache.rb
CHANGED
|
@@ -29,3 +29,10 @@ scope :color_variation do
|
|
|
29
29
|
|
|
30
30
|
cache_field :product_code, :from => [:product, :code]
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
cache_includes "nocache_time", :no_cache => true
|
|
34
|
+
cache_includes "expires_in_time", :expires_in => 2.days
|
|
35
|
+
cache_includes "products_time", "product", "color_variation"
|
|
36
|
+
cache_includes "helper_time" do
|
|
37
|
+
current_user
|
|
38
|
+
end
|
data/config/qor/test.rb
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
gem 'nokogiri', :git => "git://github.com/sparklemotion/nokogiri.git", :branch => "1.4"
|
|
6
|
-
gem 'nokogiri', :git => "git://github.com/sparklemotion/nokogiri.git", :branch => "master"
|
|
4
|
+
gem 'rails', [3.1, 3.2]
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
env '2.0' do
|
|
7
|
+
ruby '2.0'
|
|
8
|
+
end
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
# So with above config, your tests will run 6 times
|
|
13
|
-
# [nokogiri(1.4), rails(3.1)], [nokogiri(master), rails(3.1)]
|
|
14
|
-
# [nokogiri(1.4), rails(3.2)], [nokogiri(master), rails(3.2)]
|
|
15
|
-
# [nokogiri(1.4), rails(4.0)], [nokogiri(master), rails(4.0)]
|
|
16
|
-
env 'default' do
|
|
10
|
+
env '1.9.3' do
|
|
17
11
|
ruby '1.9.3'
|
|
18
|
-
gem 'rails', ['3.1', '3.2', '4.0']
|
|
19
12
|
end
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
gem 'rails', ['3.1', '3.2']
|
|
14
|
+
env '1.8.7' do
|
|
15
|
+
ruby '1.8.7'
|
|
16
|
+
gem 'factory_girl_rails', '1.3.0'
|
|
25
17
|
end
|
data/config/routes.rb
ADDED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'qor_dsl'
|
|
2
|
+
|
|
1
3
|
module Qor
|
|
2
4
|
module Cache
|
|
3
5
|
class Configuration
|
|
@@ -5,7 +7,9 @@ module Qor
|
|
|
5
7
|
|
|
6
8
|
default_configs ["config/qor/cache.rb"]
|
|
7
9
|
|
|
10
|
+
node :cache_includes
|
|
8
11
|
node :cache_key
|
|
12
|
+
|
|
9
13
|
node :scope do
|
|
10
14
|
node :cache_class_method
|
|
11
15
|
node :cache_method
|
data/lib/qor_cache/kernel.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
require "digest/md5"
|
|
2
|
+
require 'uri'
|
|
2
3
|
|
|
3
4
|
module Kernel
|
|
4
5
|
def qor_cache_key(*names, &blk)
|
|
5
6
|
objs = names.map { |name| Qor::Cache::Configuration.first(:cache_key, name).block.call }
|
|
6
|
-
objs << blk
|
|
7
|
+
objs << instance_eval(&blk) if block_given?
|
|
7
8
|
|
|
8
|
-
results = objs.map do |obj|
|
|
9
|
-
|
|
9
|
+
results = objs.flatten.map do |obj|
|
|
10
|
+
obj.respond_to?(:cache_key) ? obj.cache_key : obj.inspect
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
Digest::MD5.hexdigest(results.join("-"))
|
data/lib/qor_cache/version.rb
CHANGED
data/lib/qor_cache.rb
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
1
|
class ApplicationController < ActionController::Base
|
|
2
2
|
protect_from_forgery
|
|
3
|
+
|
|
4
|
+
def index
|
|
5
|
+
render :index
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def nocache
|
|
9
|
+
render :nocache
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def expires_in
|
|
13
|
+
render :expires_in
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def products
|
|
17
|
+
render :products
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def helpers
|
|
21
|
+
render :helpers
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def with_block
|
|
25
|
+
render :with_block
|
|
26
|
+
end
|
|
3
27
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= Time.now.strftime("%Y-%m-%d") %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= Time.now.strftime("%Y-%m-%d") %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= Time.now.strftime("%Y-%m-%d") %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= Time.now.strftime("%Y-%m-%d") %>
|
|
@@ -47,13 +47,13 @@ module Dummy
|
|
|
47
47
|
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
|
48
48
|
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
|
49
49
|
# parameters by using an attr_accessible or attr_protected declaration.
|
|
50
|
-
config.active_record.whitelist_attributes = true
|
|
50
|
+
# config.active_record.whitelist_attributes = true
|
|
51
51
|
|
|
52
52
|
# Enable the asset pipeline
|
|
53
|
-
config.assets.enabled = true
|
|
53
|
+
# config.assets.enabled = true
|
|
54
54
|
|
|
55
55
|
# Version of your assets, change this if you want to expire all your assets
|
|
56
|
-
config.assets.version = '1.0'
|
|
56
|
+
# config.assets.version = '1.0'
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -23,7 +23,7 @@ Dummy::Application.configure do
|
|
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
|
24
24
|
|
|
25
25
|
# Raise exception on mass assignment protection for Active Record models
|
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
|
26
|
+
# config.active_record.mass_assignment_sanitizer = :strict
|
|
27
27
|
|
|
28
28
|
# Log the query plan for queries taking more than this (works
|
|
29
29
|
# with SQLite, MySQL, and PostgreSQL)
|
|
@@ -30,7 +30,7 @@ Dummy::Application.configure do
|
|
|
30
30
|
config.action_mailer.delivery_method = :test
|
|
31
31
|
|
|
32
32
|
# Raise exception on mass assignment protection for Active Record models
|
|
33
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
|
33
|
+
# config.active_record.mass_assignment_sanitizer = :strict
|
|
34
34
|
|
|
35
35
|
# Print deprecation notices to the stderr
|
|
36
36
|
config.active_support.deprecation = :stderr
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
|
2
2
|
|
|
3
|
-
Dummy::Application.config.session_store :cookie_store, key
|
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
|
4
4
|
|
|
5
5
|
# Use the database for sessions instead of the cookie-based default,
|
|
6
6
|
# which shouldn't be used to store highly confidential information
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
# is enabled by default.
|
|
5
5
|
|
|
6
6
|
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
|
7
|
-
ActiveSupport.on_load(:action_controller) do
|
|
8
|
-
|
|
9
|
-
end
|
|
7
|
+
# ActiveSupport.on_load(:action_controller) do
|
|
8
|
+
# wrap_parameters :format => [:json]
|
|
9
|
+
# end
|
|
10
10
|
|
|
11
11
|
# Disable root element in JSON by default.
|
|
12
|
-
ActiveSupport.on_load(:active_record) do
|
|
13
|
-
|
|
14
|
-
end
|
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
|
13
|
+
# self.include_root_in_json = false
|
|
14
|
+
# end
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
+
cache_key :product do
|
|
2
|
+
Product
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
cache_key :color_variation do
|
|
6
|
+
[ColorVariation]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
cache_key :product_and_color_variation do
|
|
10
|
+
[Product, ColorVariation]
|
|
11
|
+
end
|
|
12
|
+
|
|
1
13
|
scope :product do
|
|
2
14
|
cache_method :slow_method
|
|
3
|
-
cache_method :
|
|
15
|
+
cache_method :slow_method_with_args
|
|
4
16
|
|
|
5
17
|
cache_class_method :slow_class_method
|
|
6
|
-
cache_class_method :
|
|
18
|
+
cache_class_method :slow_class_method_with_args
|
|
7
19
|
end
|
|
8
20
|
|
|
9
|
-
scope :
|
|
21
|
+
scope :color_variation do
|
|
22
|
+
cache_method :slow_method, 'product'
|
|
23
|
+
|
|
24
|
+
cache_method :slow_method_with_product do |s|
|
|
25
|
+
s.product
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
cache_class_method :slow_class_method, 'product'
|
|
29
|
+
|
|
10
30
|
cache_field :product_code, :from => [:product, :code]
|
|
11
31
|
end
|
|
32
|
+
|
|
33
|
+
cache_includes "nocache_time", :no_cache => true
|
data/test/dummy/config/routes.rb
CHANGED
|
@@ -1,58 +1,8 @@
|
|
|
1
1
|
Dummy::Application.routes.draw do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# Sample of named route:
|
|
10
|
-
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
|
11
|
-
# This route can be invoked with purchase_url(:id => product.id)
|
|
12
|
-
|
|
13
|
-
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
|
14
|
-
# resources :products
|
|
15
|
-
|
|
16
|
-
# Sample resource route with options:
|
|
17
|
-
# resources :products do
|
|
18
|
-
# member do
|
|
19
|
-
# get 'short'
|
|
20
|
-
# post 'toggle'
|
|
21
|
-
# end
|
|
22
|
-
#
|
|
23
|
-
# collection do
|
|
24
|
-
# get 'sold'
|
|
25
|
-
# end
|
|
26
|
-
# end
|
|
27
|
-
|
|
28
|
-
# Sample resource route with sub-resources:
|
|
29
|
-
# resources :products do
|
|
30
|
-
# resources :comments, :sales
|
|
31
|
-
# resource :seller
|
|
32
|
-
# end
|
|
33
|
-
|
|
34
|
-
# Sample resource route with more complex sub-resources
|
|
35
|
-
# resources :products do
|
|
36
|
-
# resources :comments
|
|
37
|
-
# resources :sales do
|
|
38
|
-
# get 'recent', :on => :collection
|
|
39
|
-
# end
|
|
40
|
-
# end
|
|
41
|
-
|
|
42
|
-
# Sample resource route within a namespace:
|
|
43
|
-
# namespace :admin do
|
|
44
|
-
# # Directs /admin/products/* to Admin::ProductsController
|
|
45
|
-
# # (app/controllers/admin/products_controller.rb)
|
|
46
|
-
# resources :products
|
|
47
|
-
# end
|
|
48
|
-
|
|
49
|
-
# You can have the root of your site routed with "root"
|
|
50
|
-
# just remember to delete public/index.html.
|
|
51
|
-
# root :to => 'welcome#index'
|
|
52
|
-
|
|
53
|
-
# See how all your routes lay out with "rake routes"
|
|
54
|
-
|
|
55
|
-
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
|
56
|
-
# Note: This route will make all actions in every controller accessible via GET requests.
|
|
57
|
-
# match ':controller(/:action(/:id))(.:format)'
|
|
2
|
+
match "/" => "application#index"
|
|
3
|
+
match "/nocache" => "application#nocache"
|
|
4
|
+
match "/expires_in" => "application#expires_in"
|
|
5
|
+
match "/products" => "application#products"
|
|
6
|
+
match "/helpers" => "application#helpers"
|
|
7
|
+
match "/with_block" => "application#with_block"
|
|
58
8
|
end
|
|
File without changes
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
require File.expand_path("../test_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
class IntegrationTest < ActionDispatch::IntegrationTest
|
|
4
|
+
def setup
|
|
5
|
+
Rails.cache.clear
|
|
6
|
+
Timecop.freeze("2012-10-10")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "Normal mode" do
|
|
10
|
+
get "/"
|
|
11
|
+
assert_response 200
|
|
12
|
+
assert response.body.include?('2012-10-10')
|
|
13
|
+
|
|
14
|
+
Timecop.freeze("2012-10-11")
|
|
15
|
+
get "/"
|
|
16
|
+
assert_response 200
|
|
17
|
+
assert response.body.include?('2012-10-10')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "SSI mode" do
|
|
21
|
+
get "/", {}, {"QOR_CACHE_SSI_ENABLED" => 1}
|
|
22
|
+
assert_response 200
|
|
23
|
+
assert response.body.include?(%Q[<!--# include virtual="/qor_cache_includes/time])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
test "ESI mode" do
|
|
27
|
+
get "/", {}, {"QOR_CACHE_ESI_ENABLED" => 1}
|
|
28
|
+
assert_response 200
|
|
29
|
+
assert response.body.include?(%Q[<esi:include src="/qor_cache_includes/time])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "request qor_cache_includes partial" do
|
|
33
|
+
get "/qor_cache_includes/time"
|
|
34
|
+
assert_response 200
|
|
35
|
+
assert response.body.include?('2012-10-10')
|
|
36
|
+
|
|
37
|
+
Timecop.freeze("2012-10-11")
|
|
38
|
+
get "/qor_cache_includes/time"
|
|
39
|
+
assert_response 200
|
|
40
|
+
assert response.body.include?('2012-10-10')
|
|
41
|
+
|
|
42
|
+
get "/qor_cache_includes/time?hello"
|
|
43
|
+
assert_response 200
|
|
44
|
+
assert response.body.include?('2012-10-11')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
test "qor_cache_includes no_cache option" do
|
|
48
|
+
get "/nocache"
|
|
49
|
+
assert_response 200
|
|
50
|
+
assert response.body.include?('2012-10-10')
|
|
51
|
+
|
|
52
|
+
Timecop.freeze("2012-10-11")
|
|
53
|
+
get "/nocache"
|
|
54
|
+
assert_response 200
|
|
55
|
+
assert response.body.include?('2012-10-11')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
test "qor_cache_includes expires_in option" do
|
|
59
|
+
get "/expires_in"
|
|
60
|
+
assert_response 200
|
|
61
|
+
assert response.body.include?('2012-10-10')
|
|
62
|
+
|
|
63
|
+
Timecop.freeze("2012-10-11")
|
|
64
|
+
get "/expires_in"
|
|
65
|
+
assert_response 200
|
|
66
|
+
assert response.body.include?('2012-10-10')
|
|
67
|
+
|
|
68
|
+
Timecop.freeze("2012-10-13")
|
|
69
|
+
get "/expires_in"
|
|
70
|
+
assert_response 200
|
|
71
|
+
assert response.body.include?('2012-10-13')
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
test "qor_cache_includes with qor_cache_key" do
|
|
75
|
+
get "/products"
|
|
76
|
+
assert_response 200
|
|
77
|
+
assert response.body.include?('2012-10-10')
|
|
78
|
+
|
|
79
|
+
Timecop.freeze("2012-10-11")
|
|
80
|
+
get "/products"
|
|
81
|
+
assert_response 200
|
|
82
|
+
assert response.body.include?('2012-10-10')
|
|
83
|
+
|
|
84
|
+
FactoryGirl.create(:product)
|
|
85
|
+
get "/products"
|
|
86
|
+
assert_response 200
|
|
87
|
+
assert response.body.include?('2012-10-11')
|
|
88
|
+
|
|
89
|
+
Timecop.freeze("2012-10-12")
|
|
90
|
+
get "/products"
|
|
91
|
+
assert_response 200
|
|
92
|
+
assert response.body.include?('2012-10-11')
|
|
93
|
+
|
|
94
|
+
FactoryGirl.create(:color_variation)
|
|
95
|
+
get "/products"
|
|
96
|
+
assert_response 200
|
|
97
|
+
assert response.body.include?('2012-10-12')
|
|
98
|
+
|
|
99
|
+
Timecop.freeze("2012-10-13")
|
|
100
|
+
get "/products"
|
|
101
|
+
assert_response 200
|
|
102
|
+
assert response.body.include?('2012-10-12')
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
test "qor_cache_includes with helpers current_user" do
|
|
106
|
+
get "/helpers", {}, {"CURRENT_USER_ID" => 1}
|
|
107
|
+
assert_response 200
|
|
108
|
+
assert response.body.include?('2012-10-10')
|
|
109
|
+
|
|
110
|
+
Timecop.freeze("2012-10-11")
|
|
111
|
+
get "/helpers", {}, {"CURRENT_USER_ID" => 1}
|
|
112
|
+
assert_response 200
|
|
113
|
+
assert response.body.include?('2012-10-10')
|
|
114
|
+
|
|
115
|
+
get "/helpers", {}, {"CURRENT_USER_ID" => 2}
|
|
116
|
+
assert_response 200
|
|
117
|
+
assert response.body.include?('2012-10-11')
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
test "qor_cache_includes with block" do
|
|
121
|
+
FactoryGirl.create(:product)
|
|
122
|
+
get "/with_block", {}, {"CURRENT_USER_ID" => 1}
|
|
123
|
+
assert_response 200
|
|
124
|
+
assert response.body.include?('2012-10-10')
|
|
125
|
+
|
|
126
|
+
Timecop.freeze("2012-10-11")
|
|
127
|
+
get "/with_block", {}, {"CURRENT_USER_ID" => 1}
|
|
128
|
+
assert_response 200
|
|
129
|
+
assert response.body.include?('2012-10-10')
|
|
130
|
+
|
|
131
|
+
get "/with_block", {}, {"CURRENT_USER_ID" => 2}
|
|
132
|
+
assert_response 200
|
|
133
|
+
assert response.body.include?('2012-10-11')
|
|
134
|
+
end
|
|
135
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: qor_cache
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: qor_test
|
|
@@ -87,13 +87,16 @@ files:
|
|
|
87
87
|
- LICENSE.txt
|
|
88
88
|
- README.md
|
|
89
89
|
- Rakefile
|
|
90
|
+
- app/controllers/qor/cache_controller.rb
|
|
91
|
+
- app/helpers/qor/cache_helper.rb
|
|
90
92
|
- config/qor/cache.rb
|
|
91
93
|
- config/qor/test.rb
|
|
94
|
+
- config/routes.rb
|
|
92
95
|
- lib/qor_cache.rb
|
|
93
96
|
- lib/qor_cache/active_record.rb
|
|
94
97
|
- lib/qor_cache/configuration.rb
|
|
98
|
+
- lib/qor_cache/engine.rb
|
|
95
99
|
- lib/qor_cache/kernel.rb
|
|
96
|
-
- lib/qor_cache/railtie.rb
|
|
97
100
|
- lib/qor_cache/version.rb
|
|
98
101
|
- qor_cache.gemspec
|
|
99
102
|
- test/dummy/.gitignore
|
|
@@ -107,7 +110,17 @@ files:
|
|
|
107
110
|
- test/dummy/app/models/.gitkeep
|
|
108
111
|
- test/dummy/app/models/color_variation.rb
|
|
109
112
|
- test/dummy/app/models/product.rb
|
|
110
|
-
- test/dummy/app/views/
|
|
113
|
+
- test/dummy/app/views/application/expires_in.html.erb
|
|
114
|
+
- test/dummy/app/views/application/helpers.html.erb
|
|
115
|
+
- test/dummy/app/views/application/index.html.erb
|
|
116
|
+
- test/dummy/app/views/application/nocache.html.erb
|
|
117
|
+
- test/dummy/app/views/application/products.html.erb
|
|
118
|
+
- test/dummy/app/views/application/with_block.html.erb
|
|
119
|
+
- test/dummy/app/views/qor_cache_includes/expires_in_time.html.erb
|
|
120
|
+
- test/dummy/app/views/qor_cache_includes/helper_time.html.erb
|
|
121
|
+
- test/dummy/app/views/qor_cache_includes/nocache_time.html.erb
|
|
122
|
+
- test/dummy/app/views/qor_cache_includes/products_time.html.erb
|
|
123
|
+
- test/dummy/app/views/qor_cache_includes/time.html.erb
|
|
111
124
|
- test/dummy/config.ru
|
|
112
125
|
- test/dummy/config/application.rb
|
|
113
126
|
- test/dummy/config/boot.rb
|
|
@@ -138,7 +151,9 @@ files:
|
|
|
138
151
|
- test/dummy/test/fixtures/products.yml
|
|
139
152
|
- test/dummy/test/unit/color_variation_test.rb
|
|
140
153
|
- test/dummy/test/unit/product_test.rb
|
|
154
|
+
- test/dummy/tmp/cache/.gitkeep
|
|
141
155
|
- test/factories.rb
|
|
156
|
+
- test/integration_test.rb
|
|
142
157
|
- test/qor_cache_fields_test.rb
|
|
143
158
|
- test/qor_cache_key_test.rb
|
|
144
159
|
- test/qor_cache_methods_test.rb
|
|
@@ -179,7 +194,17 @@ test_files:
|
|
|
179
194
|
- test/dummy/app/models/.gitkeep
|
|
180
195
|
- test/dummy/app/models/color_variation.rb
|
|
181
196
|
- test/dummy/app/models/product.rb
|
|
182
|
-
- test/dummy/app/views/
|
|
197
|
+
- test/dummy/app/views/application/expires_in.html.erb
|
|
198
|
+
- test/dummy/app/views/application/helpers.html.erb
|
|
199
|
+
- test/dummy/app/views/application/index.html.erb
|
|
200
|
+
- test/dummy/app/views/application/nocache.html.erb
|
|
201
|
+
- test/dummy/app/views/application/products.html.erb
|
|
202
|
+
- test/dummy/app/views/application/with_block.html.erb
|
|
203
|
+
- test/dummy/app/views/qor_cache_includes/expires_in_time.html.erb
|
|
204
|
+
- test/dummy/app/views/qor_cache_includes/helper_time.html.erb
|
|
205
|
+
- test/dummy/app/views/qor_cache_includes/nocache_time.html.erb
|
|
206
|
+
- test/dummy/app/views/qor_cache_includes/products_time.html.erb
|
|
207
|
+
- test/dummy/app/views/qor_cache_includes/time.html.erb
|
|
183
208
|
- test/dummy/config.ru
|
|
184
209
|
- test/dummy/config/application.rb
|
|
185
210
|
- test/dummy/config/boot.rb
|
|
@@ -210,8 +235,11 @@ test_files:
|
|
|
210
235
|
- test/dummy/test/fixtures/products.yml
|
|
211
236
|
- test/dummy/test/unit/color_variation_test.rb
|
|
212
237
|
- test/dummy/test/unit/product_test.rb
|
|
238
|
+
- test/dummy/tmp/cache/.gitkeep
|
|
213
239
|
- test/factories.rb
|
|
240
|
+
- test/integration_test.rb
|
|
214
241
|
- test/qor_cache_fields_test.rb
|
|
215
242
|
- test/qor_cache_key_test.rb
|
|
216
243
|
- test/qor_cache_methods_test.rb
|
|
217
244
|
- test/test_helper.rb
|
|
245
|
+
has_rdoc:
|