@@ -40,8 +40,10 @@ class ActionCachingTestController < CachingController
40
40
caches_action :with_format_and_http_param , cache_path : -> ( c ) { { key : "value" } }
41
41
caches_action :with_symbol_format , cache_path : "http://test.host/action_caching_test/with_symbol_format"
42
42
caches_action :not_url_cache_path , cache_path : -> ( c ) { "#{ c . params [ :action ] } _key" }
43
+ caches_action :not_url_cache_path_no_args , cache_path : -> { "#{ params [ :action ] } _key" }
43
44
caches_action :layout_false , layout : false
44
45
caches_action :with_layout_proc_param , layout : -> ( c ) { c . params [ :layout ] != "false" }
46
+ caches_action :with_layout_proc_param_no_args , layout : -> { params [ :layout ] != "false" }
45
47
caches_action :record_not_found , :four_oh_four , :simple_runtime_error
46
48
caches_action :streaming
47
49
caches_action :invalid
@@ -81,6 +83,7 @@ def with_symbol_format
81
83
def not_url_cache_path
82
84
render plain : "cache_this"
83
85
end
86
+ alias_method :not_url_cache_path_no_args , :not_url_cache_path
84
87
85
88
def record_not_found
86
89
raise ActiveRecord ::RecordNotFound , "oops!"
@@ -101,6 +104,7 @@ def simple_runtime_error
101
104
alias_method :symbol_cache_path , :index
102
105
alias_method :layout_false , :with_layout
103
106
alias_method :with_layout_proc_param , :with_layout
107
+ alias_method :with_layout_proc_param_no_args , :with_layout
104
108
105
109
def expire
106
110
expire_action controller : "action_caching_test" , action : "index"
@@ -807,6 +811,29 @@ def test_explicit_html_format_is_used_for_fragment_path
807
811
assert_not_cached cached_time
808
812
end
809
813
814
+ def test_lambda_arity
815
+ draw do
816
+ get "/action_caching_test/not_url_cache_path_no_args" , to : "action_caching_test#not_url_cache_path_no_args"
817
+ get "/action_caching_test/with_layout_proc_param_no_args" , to : "action_caching_test#with_layout_proc_param_no_args"
818
+ end
819
+
820
+ get :not_url_cache_path_no_args
821
+ assert_response :success
822
+ assert !fragment_exist? ( "test.host/action_caching_test/not_url_cache_path_no_args" )
823
+ assert fragment_exist? ( "not_url_cache_path_no_args_key" )
824
+
825
+ get :with_layout_proc_param_no_args , params : { title : "Request 1" , layout : "false" }
826
+ assert_response :success
827
+ cached_time = content_to_cache
828
+ assert_equal "<title>Request 1</title>\n #{ cached_time } " , @response . body
829
+ assert_equal cached_time , read_fragment ( "hostname.com/action_caching_test/with_layout_proc_param_no_args" )
830
+
831
+ get :with_layout_proc_param_no_args , params : { title : "Request 2" , layout : "false" }
832
+ assert_response :success
833
+ assert_equal "<title>Request 2</title>\n #{ cached_time } " , @response . body
834
+ assert_equal cached_time , read_fragment ( "hostname.com/action_caching_test/with_layout_proc_param_no_args" )
835
+ end
836
+
810
837
private
811
838
def get_html ( *args )
812
839
@request . accept = "text/html"
0 commit comments