diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-12-06 05:16:24 -0800 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-12-06 05:16:24 -0800 |
commit | e58d663f3e285f22f2ca249cfc28d3b5673c5708 (patch) | |
tree | 974360404c983db30f10fc45fc942e6925a56ac7 /actionpack/test/template/sprockets_helper_with_routes_test.rb | |
parent | f0f0e59c104ebd79ce2a48d5678d6a51a5acd42b (diff) | |
parent | 25007ad3fb3eac28a5f7ad3f6cd26eb33e14b4e0 (diff) | |
download | rails-e58d663f3e285f22f2ca249cfc28d3b5673c5708.tar.gz rails-e58d663f3e285f22f2ca249cfc28d3b5673c5708.tar.bz2 rails-e58d663f3e285f22f2ca249cfc28d3b5673c5708.zip |
Merge pull request #3428 from adrianpike/asset_path_conflicts
Issue #3427 - asset_path_conflicts
Diffstat (limited to 'actionpack/test/template/sprockets_helper_with_routes_test.rb')
-rw-r--r-- | actionpack/test/template/sprockets_helper_with_routes_test.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/actionpack/test/template/sprockets_helper_with_routes_test.rb b/actionpack/test/template/sprockets_helper_with_routes_test.rb new file mode 100644 index 0000000000..bcbd81a7dd --- /dev/null +++ b/actionpack/test/template/sprockets_helper_with_routes_test.rb @@ -0,0 +1,57 @@ +require 'abstract_unit' +require 'sprockets' +require 'sprockets/helpers/rails_helper' +require 'mocha' + +class SprocketsHelperWithRoutesTest < ActionView::TestCase + include Sprockets::Helpers::RailsHelper + + # Let's bring in some named routes to test namespace conflicts with potential *_paths. + # We have to do this after we bring in the Sprockets RailsHelper so if there are conflicts, + # they'll fail in the way we expect in a real live Rails app. + routes = ActionDispatch::Routing::RouteSet.new + routes.draw do + resources :assets + end + include routes.url_helpers + + def setup + super + @controller = BasicController.new + + @assets = Sprockets::Environment.new + @assets.append_path(FIXTURES.join("sprockets/app/javascripts")) + @assets.append_path(FIXTURES.join("sprockets/app/stylesheets")) + @assets.append_path(FIXTURES.join("sprockets/app/images")) + + application = Struct.new(:config, :assets).new(config, @assets) + Rails.stubs(:application).returns(application) + @config = config + @config.perform_caching = true + @config.assets.digest = true + @config.assets.compile = true + end + + test "namespace conflicts on a named route called asset_path" do + # Testing this for sanity - asset_path is now a named route! + assert_match asset_path('test_asset'), '/assets/test_asset' + + assert_match %r{/assets/logo-[0-9a-f]+.png}, + path_to_asset("logo.png") + assert_match %r{/assets/logo-[0-9a-f]+.png}, + path_to_asset("logo.png", :digest => true) + assert_match %r{/assets/logo.png}, + path_to_asset("logo.png", :digest => false) + end + + test "javascript_include_tag with a named_route named asset_path" do + assert_match %r{<script src="/assets/application-[0-9a-f]+.js" type="text/javascript"></script>}, + javascript_include_tag(:application) + end + + test "stylesheet_link_tag with a named_route named asset_path" do + assert_match %r{<link href="/assets/application-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />}, + stylesheet_link_tag(:application) + end + +end
\ No newline at end of file |