Ticket #2291: components_flash.diff
| File components_flash.diff, 1.9 kB (added by htonl, 3 years ago) |
|---|
-
test/controller/components_test.rb
old new 25 25 render_text "Yes, ma'am" 26 26 end 27 27 28 def set_flash 29 render_component(:controller => 'callee', :action => 'set_flash') 30 end 31 32 def use_flash 33 render_component(:controller => 'callee', :action => 'use_flash') 34 end 35 28 36 def rescue_action(e) raise end 29 37 end 30 38 … … 36 44 def blowing_up 37 45 render_text "It's game over, man, just game over, man!", "500 Internal Server Error" 38 46 end 47 48 def set_flash 49 flash[:notice] = 'My stoney baby' 50 render :text => 'flash is set' 51 end 52 53 def use_flash 54 render :text => flash[:notice] || 'no flash' 55 end 39 56 40 57 def rescue_action(e) raise end 41 58 end … … 71 88 get :internal_caller 72 89 assert_equal "Are you there? Yes, ma'am", @response.body 73 90 end 91 92 def test_flash 93 get :set_flash 94 assert_equal 'My stoney baby', flash[:notice] 95 get :use_flash 96 assert_equal 'My stoney baby', @response.body 97 get :use_flash 98 assert_equal 'no flash', @response.body 99 end 74 100 end -
lib/action_controller/components.rb
old new 43 43 44 44 private 45 45 def component_response(options, reuse_response = true) 46 component_class(options).process(request_for_component(options), reuse_response ? @response : response_for_component) 46 c = component_class(options) 47 c.after_filter {|c| flash.keep } 48 c.process(request_for_component(options), reuse_response ? @response : response_for_component) 47 49 end 48 50 49 51 def component_class(options)