diff options
author | Rizwan Reza <rizwanreza@gmail.com> | 2010-05-17 02:40:15 +0430 |
---|---|---|
committer | Rizwan Reza <rizwanreza@gmail.com> | 2010-05-17 02:40:15 +0430 |
commit | d148a6f6ba5f8ee65905f12cd2601fcc377d4852 (patch) | |
tree | 4bcb5e7ad47cfb9a9bb14ffe7c9e003d4646d64c /actionpack/test/controller | |
parent | e1c773006969abea3c0619fbdc7e32c121b6085f (diff) | |
parent | 6b4e0cc526f55b5532cf99292c94f0a4db53b16f (diff) | |
download | rails-d148a6f6ba5f8ee65905f12cd2601fcc377d4852.tar.gz rails-d148a6f6ba5f8ee65905f12cd2601fcc377d4852.tar.bz2 rails-d148a6f6ba5f8ee65905f12cd2601fcc377d4852.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/assert_select_test.rb | 22 | ||||
-rw-r--r-- | actionpack/test/controller/capture_test.rb | 5 | ||||
-rw-r--r-- | actionpack/test/controller/flash_test.rb | 20 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 13 |
4 files changed, 52 insertions, 8 deletions
diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb index 4ef6fa4000..7012c4c9b0 100644 --- a/actionpack/test/controller/assert_select_test.rb +++ b/actionpack/test/controller/assert_select_test.rb @@ -80,10 +80,15 @@ class AssertSelectTest < ActionController::TestCase def test_assert_select render_html %Q{<div id="1"></div><div id="2"></div>} assert_select "div", 2 - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) { assert_select "div", 3 } assert_failure(/Expected at least 1 element matching \"p\", found 0/) { assert_select "p" } end + def test_equality_integer + render_html %Q{<div id="1"></div><div id="2"></div>} + assert_failure(/Expected exactly 3 elements matching \"div\", found 2/) { assert_select "div", 3 } + assert_failure(/Expected exactly 0 elements matching \"div\", found 2/) { assert_select "div", 0 } + end + def test_equality_true_false render_html %Q{<div id="1"></div><div id="2"></div>} assert_nothing_raised { assert_select "div" } @@ -94,6 +99,11 @@ class AssertSelectTest < ActionController::TestCase assert_nothing_raised { assert_select "p", false } end + def test_equality_false_message + render_html %Q{<div id="1"></div><div id="2"></div>} + assert_failure(/Expected exactly 0 elements matching \"div\", found 2/) { assert_select "div", false } + end + def test_equality_string_and_regexp render_html %Q{<div id="1">foo</div><div id="2">foo</div>} assert_nothing_raised { assert_select "div", "foo" } @@ -128,7 +138,7 @@ class AssertSelectTest < ActionController::TestCase def test_counts render_html %Q{<div id="1">foo</div><div id="2">foo</div>} assert_nothing_raised { assert_select "div", 2 } - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do + assert_failure(/Expected exactly 3 elements matching \"div\", found 2/) do assert_select "div", 3 end assert_nothing_raised { assert_select "div", 1..2 } @@ -136,7 +146,7 @@ class AssertSelectTest < ActionController::TestCase assert_select "div", 3..4 end assert_nothing_raised { assert_select "div", :count=>2 } - assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do + assert_failure(/Expected exactly 3 elements matching \"div\", found 2/) do assert_select "div", :count=>3 end assert_nothing_raised { assert_select "div", :minimum=>1 } @@ -201,7 +211,7 @@ class AssertSelectTest < ActionController::TestCase assert_nothing_raised { assert_select "div", "foo" } assert_nothing_raised { assert_select "div", "bar" } assert_nothing_raised { assert_select "div", /\w*/ } - assert_nothing_raised { assert_select "div", /\w*/, :count=>2 } + assert_nothing_raised { assert_select "div", :text => /\w*/, :count=>2 } assert_raise(Assertion) { assert_select "div", :text=>"foo", :count=>2 } assert_nothing_raised { assert_select "div", :html=>"<span>bar</span>" } assert_nothing_raised { assert_select "div", :html=>"<span>bar</span>" } @@ -266,8 +276,8 @@ class AssertSelectTest < ActionController::TestCase def test_css_select render_html %Q{<div id="1"></div><div id="2"></div>} - assert 2, css_select("div").size - assert 0, css_select("p").size + assert_equal 2, css_select("div").size + assert_equal 0, css_select("p").size end def test_nested_css_select diff --git a/actionpack/test/controller/capture_test.rb b/actionpack/test/controller/capture_test.rb index 06a5af6b32..d1dbd535c4 100644 --- a/actionpack/test/controller/capture_test.rb +++ b/actionpack/test/controller/capture_test.rb @@ -61,6 +61,11 @@ class CaptureTest < ActionController::TestCase assert_equal expected_content_for_output, @response.body end + def test_proper_block_detection + @todo = "some todo" + get :proper_block_detection + end + private def expected_content_for_output "<title>Putting stuff in the title!</title>\n\nGreat stuff!" diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index 3c651ebebc..c662ce264b 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -81,6 +81,16 @@ class FlashTest < ActionController::TestCase redirect_to '/somewhere', :notice => "Good luck in the somewheres!" end + def render_with_flash_now_alert + flash.now.alert = "Beware the nowheres now!" + render :inline => "hello" + end + + def render_with_flash_now_notice + flash.now.notice = "Good luck in the somewheres now!" + render :inline => "hello" + end + def redirect_with_other_flashes redirect_to '/wonderland', :flash => { :joyride => "Horses!" } end @@ -183,6 +193,16 @@ class FlashTest < ActionController::TestCase assert_equal "Good luck in the somewheres!", @controller.send(:flash)[:notice] end + def test_render_with_flash_now_alert + get :render_with_flash_now_alert + assert_equal "Beware the nowheres now!", @controller.send(:flash)[:alert] + end + + def test_render_with_flash_now_notice + get :render_with_flash_now_notice + assert_equal "Good luck in the somewheres now!", @controller.send(:flash)[:notice] + end + def test_redirect_to_with_other_flashes get :redirect_with_other_flashes assert_equal "Horses!", @controller.send(:flash)[:joyride] diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 2f3997518f..52049f2a8a 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -547,6 +547,10 @@ class TestController < ActionController::Base render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ] end + def partial_collection_with_as_and_counter + render :partial => "customer_counter_with_as", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :client + end + def partial_collection_with_locals render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } end @@ -1242,6 +1246,11 @@ class RenderTest < ActionController::TestCase assert_equal "david0mary1", @response.body end + def test_partial_collection_with_as_and_counter + get :partial_collection_with_as_and_counter + assert_equal "david0mary1", @response.body + end + def test_partial_collection_with_locals get :partial_collection_with_locals assert_equal "Bonjour: davidBonjour: mary", @response.body @@ -1379,7 +1388,7 @@ class EtagRenderTest < ActionController::TestCase def test_render_against_etag_request_should_have_no_content_length_when_match @request.if_none_match = etag_for("hello david") get :render_hello_world_from_variable - assert !@response.headers.has_key?("Content-Length"), @response.headers['Content-Length'] + assert !@response.headers.has_key?("Content-Length") end def test_render_against_etag_request_should_200_when_no_match @@ -1515,4 +1524,4 @@ class LastModifiedRenderTest < ActionController::TestCase get :conditional_hello_with_bangs assert_response :success end -end
\ No newline at end of file +end |