qor_cache 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +0 -2
  3. data/README.md +0 -14
  4. data/config/qor/cache.rb +0 -7
  5. data/lib/qor_cache.rb +1 -1
  6. data/lib/qor_cache/configuration.rb +0 -2
  7. data/lib/qor_cache/kernel.rb +3 -4
  8. data/lib/qor_cache/{engine.rb → railtie.rb} +1 -1
  9. data/lib/qor_cache/version.rb +1 -1
  10. data/qor_cache.gemspec +1 -1
  11. data/test/dummy/app/controllers/application_controller.rb +0 -24
  12. data/test/dummy/app/helpers/application_helper.rb +0 -3
  13. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  14. data/test/dummy/config/application.rb +3 -3
  15. data/test/dummy/config/initializers/wrap_parameters.rb +6 -6
  16. data/test/dummy/config/qor/cache.rb +3 -25
  17. data/test/dummy/config/routes.rb +56 -6
  18. metadata +24 -62
  19. data/app/controllers/qor/cache_controller.rb +0 -9
  20. data/app/helpers/qor/cache_helper.rb +0 -34
  21. data/config/routes.rb +0 -3
  22. data/test/dummy/app/views/application/expires_in.html.erb +0 -3
  23. data/test/dummy/app/views/application/helpers.html.erb +0 -3
  24. data/test/dummy/app/views/application/index.html.erb +0 -3
  25. data/test/dummy/app/views/application/nocache.html.erb +0 -3
  26. data/test/dummy/app/views/application/products.html.erb +0 -3
  27. data/test/dummy/app/views/application/with_block.html.erb +0 -9
  28. data/test/dummy/app/views/qor_cache_includes/expires_in_time.html.erb +0 -2
  29. data/test/dummy/app/views/qor_cache_includes/helper_time.html.erb +0 -1
  30. data/test/dummy/app/views/qor_cache_includes/nocache_time.html.erb +0 -1
  31. data/test/dummy/app/views/qor_cache_includes/products_time.html.erb +0 -1
  32. data/test/dummy/app/views/qor_cache_includes/time.html.erb +0 -1
  33. data/test/integration_test.rb +0 -135
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bc807528ff2bb7368865ff5d2e557386b911a0cc
4
+ data.tar.gz: 1ff4e8f15c89802543ce6f95e9c183aff6584dc5
5
+ SHA512:
6
+ metadata.gz: d6d3e4c7d23cacab412bdf9873a28b0188df71af5f4271632f43d303b9ddf9de0d8afc483a442f4a11214e91c343e88502b81118c805fef3269bc14c762d138f
7
+ data.tar.gz: dcac4d1f1baa594d8cdea17d2ea5c7f6ad0dbdd7a2e73c70f8f93a77dfed204999ca5cc4f67325b70175898c8e6e950d70473049487e5406054f64304e26b85d
data/Gemfile CHANGED
@@ -2,7 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'qor_dsl'
4
4
  gem 'factory_girl_rails'
5
- gem 'pry'
6
- gem "timecop"
7
5
 
8
6
  gemspec
data/README.md CHANGED
@@ -29,11 +29,6 @@ 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
-
37
32
 
38
33
  # app/models/color_variation.rb
39
34
  def heavy_method_related_to_products
@@ -61,15 +56,6 @@ Qor Cache
61
56
  xxxxx
62
57
  end
63
58
 
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
-
73
59
  ## Contributing
74
60
 
75
61
  1. Fork it
@@ -29,10 +29,3 @@ 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
@@ -1,6 +1,6 @@
1
1
  require "qor_cache/configuration"
2
2
  require "qor_cache/active_record"
3
- require "qor_cache/engine"
3
+ require "qor_cache/railtie"
4
4
  require "qor_cache/kernel"
5
5
  require "digest/md5"
6
6
 
@@ -7,9 +7,7 @@ module Qor
7
7
 
8
8
  default_configs ["config/qor/cache.rb"]
9
9
 
10
- node :cache_includes
11
10
  node :cache_key
12
-
13
11
  node :scope do
14
12
  node :cache_class_method
15
13
  node :cache_method
@@ -1,13 +1,12 @@
1
1
  require "digest/md5"
2
- require 'uri'
3
2
 
4
3
  module Kernel
5
4
  def qor_cache_key(*names, &blk)
6
5
  objs = names.map { |name| Qor::Cache::Configuration.first(:cache_key, name).block.call }
7
- objs << instance_eval(&blk) if block_given?
6
+ objs << blk.call if block_given?
8
7
 
9
- results = objs.flatten.map do |obj|
10
- obj.respond_to?(:cache_key) ? obj.cache_key : obj.inspect
8
+ results = objs.map do |obj|
9
+ Array(obj).map {|x| x.respond_to?(:cache_key) ? x.cache_key : x.inspect }.join("-")
11
10
  end
12
11
 
13
12
  Digest::MD5.hexdigest(results.join("-"))
@@ -1,6 +1,6 @@
1
1
  module Qor
2
2
  module Cache
3
- class Railtie < Rails::Engine
3
+ class Railtie < Rails::Railtie
4
4
 
5
5
  initializer "insert_active_record_methods_for_qor_cache" do
6
6
  ActiveSupport.on_load(:active_record) do
@@ -1,5 +1,5 @@
1
1
  module Qor
2
2
  module Cache
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency "qor_test"
21
20
  gem.add_dependency "qor_dsl"
22
21
  gem.add_dependency "rails"
23
22
  gem.add_development_dependency "sqlite3"
23
+ gem.add_development_dependency "qor_test"
24
24
  end
@@ -1,27 +1,3 @@
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
27
3
  end
@@ -1,5 +1,2 @@
1
1
  module ApplicationHelper
2
- def current_user
3
- request.env["CURRENT_USER_ID"]
4
- end
5
2
  end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -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
 
@@ -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
- # wrap_parameters :format => [:json]
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
- # self.include_root_in_json = false
14
- # end
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -1,33 +1,11 @@
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
-
13
1
  scope :product do
14
2
  cache_method :slow_method
15
- cache_method :slow_method_with_args
3
+ cache_method :slow_method1
16
4
 
17
5
  cache_class_method :slow_class_method
18
- cache_class_method :slow_class_method_with_args
6
+ cache_class_method :slow_class_method1
19
7
  end
20
8
 
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
-
9
+ scope :product do
30
10
  cache_field :product_code, :from => [:product, :code]
31
11
  end
32
-
33
- cache_includes "nocache_time", :no_cache => true
@@ -1,8 +1,58 @@
1
1
  Dummy::Application.routes.draw do
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"
2
+ # The priority is based upon order of creation:
3
+ # first created -> highest priority.
4
+
5
+ # Sample of regular route:
6
+ # match 'products/:id' => 'catalog#view'
7
+ # Keep in mind you can assign values other than :controller and :action
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)'
8
58
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qor_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jinzhu
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-04 00:00:00.000000000 Z
11
+ date: 2014-09-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: qor_test
14
+ name: qor_dsl
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
- name: qor_dsl
28
+ name: rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
- name: rails
42
+ name: sqlite3
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
- type: :runtime
48
+ type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
- name: sqlite3
56
+ name: qor_test
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: Qor Cache
@@ -82,21 +73,18 @@ executables: []
82
73
  extensions: []
83
74
  extra_rdoc_files: []
84
75
  files:
85
- - .gitignore
76
+ - ".gitignore"
86
77
  - Gemfile
87
78
  - LICENSE.txt
88
79
  - README.md
89
80
  - Rakefile
90
- - app/controllers/qor/cache_controller.rb
91
- - app/helpers/qor/cache_helper.rb
92
81
  - config/qor/cache.rb
93
82
  - config/qor/test.rb
94
- - config/routes.rb
95
83
  - lib/qor_cache.rb
96
84
  - lib/qor_cache/active_record.rb
97
85
  - lib/qor_cache/configuration.rb
98
- - lib/qor_cache/engine.rb
99
86
  - lib/qor_cache/kernel.rb
87
+ - lib/qor_cache/railtie.rb
100
88
  - lib/qor_cache/version.rb
101
89
  - qor_cache.gemspec
102
90
  - test/dummy/.gitignore
@@ -110,17 +98,7 @@ files:
110
98
  - test/dummy/app/models/.gitkeep
111
99
  - test/dummy/app/models/color_variation.rb
112
100
  - test/dummy/app/models/product.rb
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
101
+ - test/dummy/app/views/layouts/application.html.erb
124
102
  - test/dummy/config.ru
125
103
  - test/dummy/config/application.rb
126
104
  - test/dummy/config/boot.rb
@@ -151,36 +129,33 @@ files:
151
129
  - test/dummy/test/fixtures/products.yml
152
130
  - test/dummy/test/unit/color_variation_test.rb
153
131
  - test/dummy/test/unit/product_test.rb
154
- - test/dummy/tmp/cache/.gitkeep
155
132
  - test/factories.rb
156
- - test/integration_test.rb
157
133
  - test/qor_cache_fields_test.rb
158
134
  - test/qor_cache_key_test.rb
159
135
  - test/qor_cache_methods_test.rb
160
136
  - test/test_helper.rb
161
137
  homepage: ''
162
138
  licenses: []
139
+ metadata: {}
163
140
  post_install_message:
164
141
  rdoc_options: []
165
142
  require_paths:
166
143
  - lib
167
144
  required_ruby_version: !ruby/object:Gem::Requirement
168
- none: false
169
145
  requirements:
170
- - - ! '>='
146
+ - - ">="
171
147
  - !ruby/object:Gem::Version
172
148
  version: '0'
173
149
  required_rubygems_version: !ruby/object:Gem::Requirement
174
- none: false
175
150
  requirements:
176
- - - ! '>='
151
+ - - ">="
177
152
  - !ruby/object:Gem::Version
178
153
  version: '0'
179
154
  requirements: []
180
155
  rubyforge_project:
181
- rubygems_version: 1.8.24
156
+ rubygems_version: 2.2.2
182
157
  signing_key:
183
- specification_version: 3
158
+ specification_version: 4
184
159
  summary: Qor Cache
185
160
  test_files:
186
161
  - test/dummy/.gitignore
@@ -194,17 +169,7 @@ test_files:
194
169
  - test/dummy/app/models/.gitkeep
195
170
  - test/dummy/app/models/color_variation.rb
196
171
  - test/dummy/app/models/product.rb
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
172
+ - test/dummy/app/views/layouts/application.html.erb
208
173
  - test/dummy/config.ru
209
174
  - test/dummy/config/application.rb
210
175
  - test/dummy/config/boot.rb
@@ -235,11 +200,8 @@ test_files:
235
200
  - test/dummy/test/fixtures/products.yml
236
201
  - test/dummy/test/unit/color_variation_test.rb
237
202
  - test/dummy/test/unit/product_test.rb
238
- - test/dummy/tmp/cache/.gitkeep
239
203
  - test/factories.rb
240
- - test/integration_test.rb
241
204
  - test/qor_cache_fields_test.rb
242
205
  - test/qor_cache_key_test.rb
243
206
  - test/qor_cache_methods_test.rb
244
207
  - test/test_helper.rb
245
- has_rdoc:
@@ -1,9 +0,0 @@
1
- module Qor
2
- class CacheController < ActionController::Base
3
- include Qor::CacheHelper
4
-
5
- def includes
6
- render :text => render_qor_cache_includes(params[:path], request.fullpath)
7
- end
8
- end
9
- end
@@ -1,34 +0,0 @@
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
@@ -1,3 +0,0 @@
1
- Rails.application.routes.draw do
2
- match "/qor_cache_includes/*path" => "Qor::Cache#includes"
3
- end
@@ -1,3 +0,0 @@
1
- Hello World!
2
-
3
- <%= qor_cache_includes "expires_in_time" %>
@@ -1,3 +0,0 @@
1
- Hello World!
2
-
3
- <%= qor_cache_includes "helper_time" %>
@@ -1,3 +0,0 @@
1
- Hello World!
2
-
3
- <%= qor_cache_includes "time" %>
@@ -1,3 +0,0 @@
1
- Hello World!
2
-
3
- <%= qor_cache_includes "nocache_time" %>
@@ -1,3 +0,0 @@
1
- Hello World!
2
-
3
- <%= qor_cache_includes "products_time" %>
@@ -1,9 +0,0 @@
1
- Hello World!
2
-
3
- <%=
4
- @current_user = current_user
5
- qor_cache_includes "time" do
6
- @current_user
7
- end
8
- %>
9
-
@@ -1,2 +0,0 @@
1
- <%= Time.now.strftime("%Y-%m-%d") %>
2
-
@@ -1 +0,0 @@
1
- <%= Time.now.strftime("%Y-%m-%d") %>
@@ -1 +0,0 @@
1
- <%= Time.now.strftime("%Y-%m-%d") %>
@@ -1 +0,0 @@
1
- <%= Time.now.strftime("%Y-%m-%d") %>
@@ -1 +0,0 @@
1
- <%= Time.now.strftime("%Y-%m-%d") %>
@@ -1,135 +0,0 @@
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