Ticket #7780: assert_select_rjs_show_and_hide.patch
| File assert_select_rjs_show_and_hide.patch, 3.1 kB (added by dchelimsky, 2 years ago) |
|---|
-
actionpack/test/controller/assert_select_test.rb
old new 429 429 end 430 430 end 431 431 432 # Simple show 433 def test_assert_select_rjs_for_show 434 render_rjs do |page| 435 page.show "test1" 436 end 437 438 assert_select_rjs :show, "test1" 439 end 440 441 def test_assert_select_rjs_for_show_ignores_block 442 render_rjs do |page| 443 page.show "test1" 444 end 445 446 assert_nothing_raised do 447 assert_select_rjs :show, "test1" do 448 assert_select "p" 449 end 450 end 451 end 452 453 # Simple hide 454 def test_assert_select_rjs_for_hide 455 render_rjs do |page| 456 page.hide "test1" 457 end 458 459 assert_select_rjs :hide, "test1" 460 end 461 462 def test_assert_select_rjs_for_hide_ignores_block 463 render_rjs do |page| 464 page.hide "test1" 465 end 466 467 assert_nothing_raised do 468 assert_select_rjs :hide, "test1" do 469 assert_select "p" 470 end 471 end 472 end 473 432 474 # Non-positioned insert. 433 475 def test_assert_select_rjs_for_nonpositioned_insert 434 476 render_rjs do |page| … … 475 517 assert_select "div", 4 476 518 end 477 519 end 478 479 520 480 521 # Simple selection from a single result. 481 522 def test_nested_assert_select_rjs_with_single_result 482 523 render_rjs do |page| -
actionpack/lib/action_controller/assertions/selector_assertions.rb
old new 406 406 case rjs_type 407 407 when :chained_replace, :chained_replace_html 408 408 Regexp.new("\\$\\(\"#{id}\"\\)#{statement}\\(#{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE) 409 when :remove 409 when :remove, :show, :hide 410 410 Regexp.new("#{statement}\\(\"#{id}\"\\)") 411 411 else 412 412 Regexp.new("#{statement}\\(\"#{id}\", #{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE) … … 415 415 # Duplicate the body since the next step involves destroying it. 416 416 matches = nil 417 417 case rjs_type 418 when :remove 418 when :remove, :show, :hide 419 419 matches = @response.body.match(pattern) 420 420 else 421 421 @response.body.gsub(pattern) do |match| … … 426 426 end 427 427 end 428 428 if matches 429 if block_given? && rjs_type != :remove429 if block_given? && !([:remove, :show, :hide].include? rjs_type) 430 430 begin 431 431 in_scope, @selected = @selected, matches 432 432 yield matches … … 533 533 :chained_replace => /\.replace/, 534 534 :chained_replace_html => /\.update/, 535 535 :remove => /Element\.remove/, 536 :show => /Element\.show/, 537 :hide => /Element\.hide/ 536 538 } 537 539 RJS_INSERTIONS = [:top, :bottom, :before, :after] 538 540 RJS_INSERTIONS.each do |insertion|