diff options
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 14 | ||||
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 8 | ||||
-rw-r--r-- | actionpack/test/template/test_case_test.rb | 19 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 20 |
4 files changed, 56 insertions, 5 deletions
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 7cc567c72d..bcc55189b9 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -1267,9 +1267,6 @@ class AssetTagHelperTest < ActionView::TestCase assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) end - - - def test_caching_stylesheet_include_tag_when_caching_off ENV["RAILS_ASSET_ID"] = "" config.perform_caching = false @@ -1298,6 +1295,17 @@ class AssetTagHelperTest < ActionView::TestCase assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) end + + def test_caching_stylesheet_include_tag_with_absolute_uri + ENV["RAILS_ASSET_ID"] = "" + + assert_dom_equal( + %(<link href="/stylesheets/all.css" media="screen" rel="stylesheet" />), + stylesheet_link_tag("/foo/baz", :cache => true) + ) + + FileUtils.rm(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) + end end class AssetTagHelperNonVhostTest < ActionView::TestCase diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index c9b39ed18f..7da293ce23 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1054,6 +1054,9 @@ class FormHelperTest < ActionView::TestCase concat f.check_box(:secret) concat f.submit('Create post') concat f.button('Create post') + concat f.button { + concat content_tag(:span, 'Create post') + } end expected = whole_form("/posts/123", "create-post" , "edit_post", :method => 'patch') do @@ -1063,7 +1066,8 @@ class FormHelperTest < ActionView::TestCase "<input name='post[secret]' type='hidden' value='0' />" + "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + "<input name='commit' type='submit' value='Create post' />" + - "<button name='button' type='submit'>Create post</button>" + "<button name='button' type='submit'>Create post</button>" + + "<button name='button' type='submit'><span>Create post</span></button>" end assert_dom_equal expected, output_buffer @@ -2359,7 +2363,7 @@ class FormHelperTest < ActionView::TestCase end def test_form_builder_does_not_have_form_for_method - assert ! ActionView::Helpers::FormBuilder.instance_methods.include?('form_for') + assert !ActionView::Helpers::FormBuilder.instance_methods.include?(:form_for) end def test_form_for_and_fields_for diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb index f2ed2ec609..c005f040eb 100644 --- a/actionpack/test/template/test_case_test.rb +++ b/actionpack/test/template/test_case_test.rb @@ -222,6 +222,25 @@ module ActionView end end + test "is able to use mounted routes" do + with_routing do |set| + app = Class.new do + def self.routes + @routes ||= ActionDispatch::Routing::RouteSet.new + end + + routes.draw { get "bar", :to => lambda {} } + + def self.call(*) + end + end + + set.draw { mount app => "/foo", :as => "foo_app" } + + assert_equal '/foo/bar', foo_app.bar_path + end + end + test "named routes can be used from helper included in view" do with_routing do |set| set.draw { resources :contents } diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 365a86ab91..62608a727f 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -277,6 +277,16 @@ class UrlHelperTest < ActiveSupport::TestCase ) end + def test_link_tag_with_block + assert_dom_equal '<a href="/"><span>Example site</span></a>', + link_to('/') { content_tag(:span, 'Example site') } + end + + def test_link_tag_with_block_and_html_options + assert_dom_equal '<a class="special" href="/"><span>Example site</span></a>', + link_to('/', :class => "special") { content_tag(:span, 'Example site') } + end + def test_link_tag_using_block_in_erb out = render_erb %{<%= link_to('/') do %>Example site<% end %>} assert_equal '<a href="/">Example site</a>', out @@ -289,6 +299,16 @@ class UrlHelperTest < ActiveSupport::TestCase ) end + def test_link_tag_escapes_content + assert_dom_equal '<a href="/">Malicious <script>content</script></a>', + link_to("Malicious <script>content</script>", "/") + end + + def test_link_tag_does_not_escape_html_safe_content + assert_dom_equal '<a href="/">Malicious <script>content</script></a>', + link_to("Malicious <script>content</script>".html_safe, "/") + end + def test_link_to_unless assert_equal "Showing", link_to_unless(true, "Showing", url_hash) |