diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 13 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 40 | ||||
-rw-r--r-- | actionpack/test/template/date_helper_test.rb | 4 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 5 |
4 files changed, 52 insertions, 10 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 88a5c37c43..659c6c715e 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -529,6 +529,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end end + + scope '/job', :controller => 'job' do + scope ':id', :action => 'manage_applicant' do + get "/active" + end + end end end @@ -1444,6 +1450,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + def test_controller_option_with_nesting_and_leading_slash + with_test_routes do + get '/job/5/active' + assert_equal 'job#manage_applicant', @response.body + end + end + def test_dynamically_generated_helpers_on_collection_do_not_clobber_resources_url_helper with_test_routes do assert_equal '/replies', replies_path diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index b1a01b53b1..6b1bc01f54 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -79,13 +79,17 @@ class AssetTagHelperTest < ActionView::TestCase JavascriptPathToTag = { %(javascript_path("xmlhr")) => %(/javascripts/xmlhr.js), %(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js), - %(javascript_path("/super/xmlhr.js")) => %(/super/xmlhr.js) + %(javascript_path("/super/xmlhr.js")) => %(/super/xmlhr.js), + %(javascript_path("http://www.outside.com/foo.js")) => %(http://www.outside.com/foo.js), + %(javascript_path("HTTP://www.outside.com/foo.js")) => %(HTTP://www.outside.com/foo.js) } PathToJavascriptToTag = { %(path_to_javascript("xmlhr")) => %(/javascripts/xmlhr.js), %(path_to_javascript("super/xmlhr")) => %(/javascripts/super/xmlhr.js), - %(path_to_javascript("/super/xmlhr.js")) => %(/super/xmlhr.js) + %(path_to_javascript("/super/xmlhr.js")) => %(/super/xmlhr.js), + %(path_to_javascript("http://www.outside.com/foo.js")) => %(http://www.outside.com/foo.js), + %(path_to_javascript("HTTP://www.outside.com/foo.js")) => %(HTTP://www.outside.com/foo.js) } JavascriptIncludeToTag = { @@ -109,14 +113,18 @@ class AssetTagHelperTest < ActionView::TestCase %(stylesheet_path("bank")) => %(/stylesheets/bank.css), %(stylesheet_path("bank.css")) => %(/stylesheets/bank.css), %(stylesheet_path('subdir/subdir')) => %(/stylesheets/subdir/subdir.css), - %(stylesheet_path('/subdir/subdir.css')) => %(/subdir/subdir.css) + %(stylesheet_path('/subdir/subdir.css')) => %(/subdir/subdir.css), + %(stylesheet_path("http://www.outside.com/foo.css")) => %(http://www.outside.com/foo.css), + %(stylesheet_path("HTTP://www.outside.com/foo.css")) => %(HTTP://www.outside.com/foo.css) } PathToStyleToTag = { %(path_to_stylesheet("style")) => %(/stylesheets/style.css), %(path_to_stylesheet("style.css")) => %(/stylesheets/style.css), %(path_to_stylesheet('dir/file')) => %(/stylesheets/dir/file.css), - %(path_to_stylesheet('/dir/file.rcss')) => %(/dir/file.rcss) + %(path_to_stylesheet('/dir/file.rcss')) => %(/dir/file.rcss), + %(path_to_stylesheet("http://www.outside.com/foo.css")) => %(http://www.outside.com/foo.css), + %(path_to_stylesheet("HTTP://www.outside.com/foo.css")) => %(HTTP://www.outside.com/foo.css) } StyleLinkToTag = { @@ -139,14 +147,18 @@ class AssetTagHelperTest < ActionView::TestCase %(image_path("xml")) => %(/images/xml), %(image_path("xml.png")) => %(/images/xml.png), %(image_path("dir/xml.png")) => %(/images/dir/xml.png), - %(image_path("/dir/xml.png")) => %(/dir/xml.png) + %(image_path("/dir/xml.png")) => %(/dir/xml.png), + %(image_path("http://www.outside.com/foo.png")) => %(http://www.outside.com/foo.png), + %(image_path("HTTP://www.outside.com/foo.png")) => %(HTTP://www.outside.com/foo.png) } PathToImageToTag = { %(path_to_image("xml")) => %(/images/xml), %(path_to_image("xml.png")) => %(/images/xml.png), %(path_to_image("dir/xml.png")) => %(/images/dir/xml.png), - %(path_to_image("/dir/xml.png")) => %(/dir/xml.png) + %(path_to_image("/dir/xml.png")) => %(/dir/xml.png), + %(path_to_image("http://www.outside.com/foo.png")) => %(http://www.outside.com/foo.png), + %(path_to_image("HTTP://www.outside.com/foo.png")) => %(HTTP://www.outside.com/foo.png) } ImageLinkToTag = { @@ -181,14 +193,18 @@ class AssetTagHelperTest < ActionView::TestCase %(video_path("xml")) => %(/videos/xml), %(video_path("xml.ogg")) => %(/videos/xml.ogg), %(video_path("dir/xml.ogg")) => %(/videos/dir/xml.ogg), - %(video_path("/dir/xml.ogg")) => %(/dir/xml.ogg) + %(video_path("/dir/xml.ogg")) => %(/dir/xml.ogg), + %(video_path("http://www.outside.com/foo.ogg")) => %(http://www.outside.com/foo.ogg), + %(video_path("HTTP://www.outside.com/foo.ogg")) => %(HTTP://www.outside.com/foo.ogg) } PathToVideoToTag = { %(path_to_video("xml")) => %(/videos/xml), %(path_to_video("xml.ogg")) => %(/videos/xml.ogg), %(path_to_video("dir/xml.ogg")) => %(/videos/dir/xml.ogg), - %(path_to_video("/dir/xml.ogg")) => %(/dir/xml.ogg) + %(path_to_video("/dir/xml.ogg")) => %(/dir/xml.ogg), + %(path_to_video("http://www.outside.com/foo.ogg")) => %(http://www.outside.com/foo.ogg), + %(path_to_video("HTTP://www.outside.com/foo.ogg")) => %(HTTP://www.outside.com/foo.ogg) } VideoLinkToTag = { @@ -211,14 +227,18 @@ class AssetTagHelperTest < ActionView::TestCase %(audio_path("xml")) => %(/audios/xml), %(audio_path("xml.wav")) => %(/audios/xml.wav), %(audio_path("dir/xml.wav")) => %(/audios/dir/xml.wav), - %(audio_path("/dir/xml.wav")) => %(/dir/xml.wav) + %(audio_path("/dir/xml.wav")) => %(/dir/xml.wav), + %(audio_path("http://www.outside.com/foo.wav")) => %(http://www.outside.com/foo.wav), + %(audio_path("HTTP://www.outside.com/foo.wav")) => %(HTTP://www.outside.com/foo.wav) } PathToAudioToTag = { %(path_to_audio("xml")) => %(/audios/xml), %(path_to_audio("xml.wav")) => %(/audios/xml.wav), %(path_to_audio("dir/xml.wav")) => %(/audios/dir/xml.wav), - %(path_to_audio("/dir/xml.wav")) => %(/dir/xml.wav) + %(path_to_audio("/dir/xml.wav")) => %(/dir/xml.wav), + %(path_to_audio("http://www.outside.com/foo.wav")) => %(http://www.outside.com/foo.wav), + %(path_to_audio("HTTP://www.outside.com/foo.wav")) => %(HTTP://www.outside.com/foo.wav) } AudioLinkToTag = { diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index e4f84f8dd7..ad46ff4429 100644 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -19,6 +19,8 @@ class DateHelperTest < ActionView::TestCase end def assert_distance_of_time_in_words(from, to=nil) + Fixnum.send(:private, :/) if RUBY_VERSION >= '1.9.3' # test we avoid Integer#/ (redefined by mathn) + to ||= from # 0..1 with include_seconds @@ -96,6 +98,8 @@ class DateHelperTest < ActionView::TestCase # test to < from assert_equal "about 4 hours", distance_of_time_in_words(from + 4.hours, to) assert_equal "less than 20 seconds", distance_of_time_in_words(from + 19.seconds, to, true) + ensure + Fixnum.send(:public, :/) if RUBY_VERSION >= '1.9.3' end def test_distance_in_words diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 38f77203e0..a00d71ff29 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -306,6 +306,11 @@ class UrlHelperTest < ActiveSupport::TestCase link_to_unless(true, "Showing", url_hash) { "test" } + + assert_equal %{<b>Showing</b>}, link_to_unless(true, "<b>Showing</b>", url_hash) + assert_equal %{<a href="/"><b>Showing</b></a>}, link_to_unless(false, "<b>Showing</b>", url_hash) + assert_equal %{<b>Showing</b>}, link_to_unless(true, "<b>Showing</b>".html_safe, url_hash) + assert_equal %{<a href="/"><b>Showing</b></a>}, link_to_unless(false, "<b>Showing</b>".html_safe, url_hash) end def test_link_to_if |