Changeset 5525
- Timestamp:
- 11/15/06 12:45:52 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/assertions/selector_assertions.rb (modified) (6 diffs)
- trunk/actionpack/test/controller/assert_select_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r5512 r5525 1 1 *SVN* 2 3 * assert_select_rjs :remove. [Dylan Egan] 2 4 3 5 * Always clear model associations from session. #4795 [sd@notso.net, andylien@gmail.com] trunk/actionpack/lib/action_controller/assertions/selector_assertions.rb
r5278 r5525 318 318 # 319 319 # Use the first argument to narrow down assertions to only statements 320 # of that type. Possible values are +:replace+, +:replace_html+ and320 # of that type. Possible values are +:replace+, +:replace_html+, +:remove+ and 321 321 # +:insert_html+. 322 322 # … … 324 324 # down the assertion to only statements that insert elements in that 325 325 # position. Possible values are +:top+, +:bottom+, +:before+ and +:after+. 326 # 327 # Using the +:remove+ statement, you will be able to pass a block, but it will 328 # be ignored as there is no HTML passed for this statement. 326 329 # 327 330 # === Using blocks … … 352 355 # # Inserting into the element bar, top position. 353 356 # assert_select_rjs :insert, :top, "bar" 357 # 358 # # Remove the element bar 359 # assert_select_rjs :remove, "bar" 354 360 # 355 361 # # Changing the element foo, with an image. … … 401 407 when :chained_replace, :chained_replace_html 402 408 Regexp.new("\\$\\(\"#{id}\"\\)#{statement}\\(#{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE) 409 when :remove 410 Regexp.new("#{statement}\\(\"#{id}\"\\)") 403 411 else 404 412 Regexp.new("#{statement}\\(\"#{id}\", #{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE) … … 407 415 # Duplicate the body since the next step involves destroying it. 408 416 matches = nil 409 @response.body.gsub(pattern) do |match| 410 html = unescape_rjs($2) 411 matches ||= [] 412 matches.concat HTML::Document.new(html).root.children.select { |n| n.tag? } 413 "" 417 case rjs_type 418 when :remove 419 matches = @response.body.match(pattern) 420 else 421 @response.body.gsub(pattern) do |match| 422 html = unescape_rjs($2) 423 matches ||= [] 424 matches.concat HTML::Document.new(html).root.children.select { |n| n.tag? } 425 "" 426 end 414 427 end 415 428 if matches 416 if block_given? 429 if block_given? && rjs_type != :remove 417 430 begin 418 431 in_scope, @selected = @selected, matches … … 520 533 :chained_replace => /\.replace/, 521 534 :chained_replace_html => /\.update/, 535 :remove => /Element\.remove/, 522 536 } 523 537 RJS_INSERTIONS = [:top, :bottom, :before, :after] trunk/actionpack/test/controller/assert_select_test.rb
r5251 r5525 407 407 end 408 408 assert_raises(AssertionFailedError) { assert_select_rjs :replace_html, "test1" } 409 end 410 411 # Simple remove 412 def test_assert_select_rjs_for_remove 413 render_rjs do |page| 414 page.remove "test1" 415 end 416 417 assert_select_rjs :remove, "test1" 418 end 419 420 def test_assert_select_rjs_for_remove_ignores_block 421 render_rjs do |page| 422 page.remove "test1" 423 end 424 425 assert_nothing_raised do 426 assert_select_rjs :remove, "test1" do 427 assert_select "p" 428 end 429 end 409 430 end 410 431