|
2 | 2 | require 'mocha/setup'
|
3 | 3 |
|
4 | 4 | CACHE_DIR = 'test_cache'
|
5 |
| -# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed |
6 |
| -FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR) |
| 5 | +# Don't change "../tmp" cavalierly or you might hose something you don't want hosed |
| 6 | +TEST_TMP_DIR = File.expand_path("../tmp", __FILE__) |
| 7 | +FILE_STORE_PATH = File.join(TEST_TMP_DIR, CACHE_DIR) |
7 | 8 |
|
8 | 9 | class CachingController < ActionController::Base
|
9 | 10 | abstract!
|
@@ -33,17 +34,17 @@ class ActionCachingTestController < CachingController
|
33 | 34 | request.params[:format] = :json
|
34 | 35 | end
|
35 | 36 |
|
36 |
| - caches_action :index, :redirected, :forbidden, if: Proc.new { |c| c.request.format && !c.request.format.json? }, expires_in: 1.hour |
| 37 | + caches_action :index, :redirected, :forbidden, if: ->(c) { c.request.format && !c.request.format.json? }, expires_in: 1.hour |
37 | 38 | caches_action :show, cache_path: 'http://test.host/custom/show'
|
38 |
| - caches_action :edit, cache_path: Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : 'http://test.host/edit' } |
| 39 | + caches_action :edit, cache_path: ->(c) { c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : 'http://test.host/edit' } |
39 | 40 | caches_action :custom_cache_path, cache_path: CachePath.new
|
40 | 41 | caches_action :symbol_cache_path, cache_path: :cache_path_protected_method
|
41 | 42 | caches_action :with_layout
|
42 |
| - caches_action :with_format_and_http_param, cache_path: Proc.new { |c| { key: 'value' } } |
| 43 | + caches_action :with_format_and_http_param, cache_path: ->(c) { { key: 'value' } } |
43 | 44 | caches_action :with_symbol_format, cache_path: 'http://test.host/action_caching_test/with_symbol_format'
|
44 |
| - caches_action :not_url_cache_path, cache_path: Proc.new { |c| "#{c.params[:action]}_key" } |
| 45 | + caches_action :not_url_cache_path, cache_path: ->(c) { "#{c.params[:action]}_key" } |
45 | 46 | caches_action :layout_false, layout: false
|
46 |
| - caches_action :with_layout_proc_param, layout: Proc.new { |c| c.params[:layout] != "false" } |
| 47 | + caches_action :with_layout_proc_param, layout: ->(c) { c.params[:layout] != "false" } |
47 | 48 | caches_action :record_not_found, :four_oh_four, :simple_runtime_error
|
48 | 49 | caches_action :streaming
|
49 | 50 | caches_action :invalid
|
|
0 commit comments