Changeset 2873
- Timestamp:
- 11/04/05 19:42:22 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/assertions.rb (modified) (3 diffs)
- trunk/actionpack/lib/action_controller/filters.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/filters_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r2848 r2873 1 1 *SVN* 2 2 3 * Added redirect_to :back as a short-hand for redirect_to(request.env["HTTP_REFERER"]) 3 * Added short-hand to assert_tag so assert_tag :tag => "span" can be written as assert_tag "span" [DHH] 4 5 * Added skip_before_filter/skip_after_filter for easier control of the filter chain in inheritance hierachies [DHH]. Example: 6 7 class ApplicationController < ActionController::Base 8 before_filter :authenticate 9 end 10 11 class WeblogController < ApplicationController 12 # will run the :authenticate filter 13 end 14 15 class SignupController < ActionController::Base 16 # will not run the :authenticate filter 17 skip_before_filter :authenticate 18 end 19 20 * Added redirect_to :back as a short-hand for redirect_to(request.env["HTTP_REFERER"]) [DHH] 4 21 5 22 * Change javascript_include_tag :defaults to not use script.aculo.us loader, which facilitates the use of plugins for future script.aculo.us and third party javascript extensions, and provide register_javascript_include_default for plugins to specify additional JavaScript files to load. Removed slider.js and builder.js from actionpack. [Thomas Fuchs] trunk/actionpack/lib/action_controller/assertions.rb
r2749 r2873 222 222 # assert_tag :tag => "span" 223 223 # 224 # # assert that there is a "span" tag with id="x" 225 # assert_tag :tag => "span", :attributes => { :id => "x" } 226 # 227 # # assert that there is a "span" tag using the short-hand 228 # assert_tag :span 229 # 230 # # assert that there is a "span" tag with id="x" using the short-hand 231 # assert_tag :span, :attributes => { :id => "x" } 232 # 224 233 # # assert that there is a "span" inside of a "div" 225 234 # assert_tag :tag => "span", :parent => { :tag => "div" } … … 249 258 # :descendant => { :tag => "span", 250 259 # :child => /hello world/ } 251 def assert_tag(opts) 252 clean_backtrace do 260 def assert_tag(*opts) 261 clean_backtrace do 262 opts = opts.size > 1 ? opts.last.merge({ :tag => opts.first.to_s }) : opts.first 253 263 tag = find_tag(opts) 254 264 assert tag, "expected tag, but no tag found matching #{opts.inspect} in:\n#{@response.body.inspect}" … … 260 270 def assert_no_tag(opts) 261 271 clean_backtrace do 272 opts = opts.size > 1 ? opts.last.merge({ :tag => opts.first.to_s }) : opts.first 262 273 tag = find_tag(opts) 263 274 assert !tag, "expected no tag, but found tag matching #{opts.inspect} in:\n#{@response.body.inspect}" trunk/actionpack/lib/action_controller/filters.rb
r2749 r2873 126 126 # report_result 127 127 # end 128 # end 129 # 130 # == Filter chain skipping 131 # 132 # Some times its convenient to specify a filter chain in a superclass that'll hold true for the majority of the 133 # subclasses, but not necessarily all of them. The subclasses that behave in exception can then specify which filters 134 # they would like to be relieved of. Examples 135 # 136 # class ApplicationController < ActionController::Base 137 # before_filter :authenticate 138 # end 139 # 140 # class WeblogController < ApplicationController 141 # # will run the :authenticate filter 142 # end 143 # 144 # class SignupController < ActionController::Base 145 # # will not run the :authenticate filter 146 # skip_before_filter :authenticate 128 147 # end 129 148 # … … 229 248 # Short-hand for append_around_filter since that's the most common of the two. 230 249 alias :around_filter :append_around_filter 250 251 # Removes the specified filters from the +before+ filter chain. Note that this only works for skipping method-reference 252 # filters, not procs. This is especially useful for managing the chain in inheritance hierarchies where only one out 253 # of many sub-controllers need a different hierarchy. 254 def skip_before_filter(*filters) 255 for filter in filters.flatten 256 write_inheritable_attribute("before_filters", read_inheritable_attribute("before_filters") - [ filter ]) 257 end 258 end 259 260 # Removes the specified filters from the +after+ filter chain. Note that this only works for skipping method-reference 261 # filters, not procs. This is especially useful for managing the chain in inheritance hierarchies where only one out 262 # of many sub-controllers need a different hierarchy. 263 def skip_after_filter(*filters) 264 for filter in filters.flatten 265 write_inheritable_attribute("after_filters", read_inheritable_attribute("after_filters") - [ filter ]) 266 end 267 end 231 268 232 269 # Returns all the before filters for this class and all its ancestors. trunk/actionpack/test/controller/filters_test.rb
r1915 r2873 100 100 class PrependingController < TestController 101 101 prepend_before_filter :wonderful_life 102 skip_before_filter :fire_flash 102 103 103 104 private … … 226 227 227 228 def test_prepending_filter 228 assert_equal [ :wonderful_life, : fire_flash, :ensure_login ], PrependingController.before_filters229 assert_equal [ :wonderful_life, :ensure_login ], PrependingController.before_filters 229 230 end 230 231