diff options
author | Xavier Noria <fxn@hashref.com> | 2010-12-24 01:55:35 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-12-24 01:55:35 +0100 |
commit | 8cdb75808198bf579e14d0fcdd1d2a51b3233add (patch) | |
tree | 9bf4bb54e4175bc805d407e2b5e3bc42bf1d0dd8 /actionpack/test | |
parent | 3822673151cd0f53e0e4e671988e35603bf2901c (diff) | |
parent | 6974c595fd480dc0ae3311ef60920fa87c5ff9d0 (diff) | |
download | rails-8cdb75808198bf579e14d0fcdd1d2a51b3233add.tar.gz rails-8cdb75808198bf579e14d0fcdd1d2a51b3233add.tar.bz2 rails-8cdb75808198bf579e14d0fcdd1d2a51b3233add.zip |
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/callbacks_test.rb | 12 | ||||
-rw-r--r-- | actionpack/test/dispatch/reloader_test.rb | 14 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 19 |
3 files changed, 40 insertions, 5 deletions
diff --git a/actionpack/test/dispatch/callbacks_test.rb b/actionpack/test/dispatch/callbacks_test.rb index 5becb621de..eed2eca2ab 100644 --- a/actionpack/test/dispatch/callbacks_test.rb +++ b/actionpack/test/dispatch/callbacks_test.rb @@ -29,14 +29,16 @@ class DispatcherTest < ActiveSupport::TestCase assert_equal 4, Foo.b end - def test_to_prepare_deprecation - prepared = false - assert_deprecated do - ActionDispatch::Callbacks.to_prepare { prepared = true } - end + def test_to_prepare_and_cleanup_delegation + prepared = cleaned = false + ActionDispatch::Callbacks.to_prepare { prepared = true } + ActionDispatch::Callbacks.to_prepare { cleaned = true } ActionDispatch::Reloader.prepare! assert prepared + + ActionDispatch::Reloader.cleanup! + assert cleaned end private diff --git a/actionpack/test/dispatch/reloader_test.rb b/actionpack/test/dispatch/reloader_test.rb index 995b19030c..eaabc1feb3 100644 --- a/actionpack/test/dispatch/reloader_test.rb +++ b/actionpack/test/dispatch/reloader_test.rb @@ -116,6 +116,20 @@ class ReloaderTest < Test::Unit::TestCase assert cleaned end + def test_cleanup_callbacks_are_called_on_exceptions + cleaned = false + Reloader.to_cleanup { cleaned = true } + + begin + call_and_return_body do + raise "error" + end + rescue + end + + assert cleaned + end + private def call_and_return_body(&block) @reloader ||= Reloader.new(block || proc {[200, {}, 'response']}) diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 39ecafd072..4b4e13e1a7 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -54,6 +54,9 @@ class AssetTagHelperTest < ActionView::TestCase def teardown config.perform_caching = false ENV.delete('RAILS_ASSET_ID') + + JavascriptIncludeTag.expansions.clear + StylesheetIncludeTag.expansions.clear end AutoDiscoveryToTag = { @@ -268,6 +271,14 @@ class AssetTagHelperTest < ActionView::TestCase assert_dom_equal %(<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/rails.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag('controls',:defaults, :robbery, 'effects') end + def test_registering_javascript_expansions_merges_with_existing_expansions + ENV["RAILS_ASSET_ID"] = "" + ActionView::Helpers::AssetTagHelper::register_javascript_expansion :can_merge => ['bank'] + ActionView::Helpers::AssetTagHelper::register_javascript_expansion :can_merge => ['robber'] + ActionView::Helpers::AssetTagHelper::register_javascript_expansion :can_merge => ['bank'] + assert_dom_equal %(<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>), javascript_include_tag(:can_merge) + end + def test_custom_javascript_expansions_with_undefined_symbol ActionView::Helpers::AssetTagHelper::register_javascript_expansion :monkey => nil assert_raise(ArgumentError) { javascript_include_tag('first', :monkey, 'last') } @@ -327,6 +338,14 @@ class AssetTagHelperTest < ActionView::TestCase assert_raise(ArgumentError) { stylesheet_link_tag('first', :monkey, 'last') } end + def test_registering_stylesheet_expansions_merges_with_existing_expansions + ENV["RAILS_ASSET_ID"] = "" + ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :can_merge => ['bank'] + ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :can_merge => ['robber'] + ActionView::Helpers::AssetTagHelper::register_stylesheet_expansion :can_merge => ['bank'] + assert_dom_equal %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag(:can_merge) + end + def test_image_path ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end |