Skip to content

Commit 83243ce

Browse files
committed
Tidy up and standardise test temporary directory
1 parent e788c08 commit 83243ce

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/caching_test.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
require 'mocha/setup'
33

44
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)
78

89
class CachingController < ActionController::Base
910
abstract!
@@ -33,17 +34,17 @@ class ActionCachingTestController < CachingController
3334
request.params[:format] = :json
3435
end
3536

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
3738
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' }
3940
caches_action :custom_cache_path, cache_path: CachePath.new
4041
caches_action :symbol_cache_path, cache_path: :cache_path_protected_method
4142
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' } }
4344
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" }
4546
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" }
4748
caches_action :record_not_found, :four_oh_four, :simple_runtime_error
4849
caches_action :streaming
4950
caches_action :invalid

0 commit comments

Comments
 (0)