diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-08 17:30:46 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-08 17:30:46 +0000 |
commit | d5f642294ccd696c852ba3d538a4f1180c101a4b (patch) | |
tree | 5ca536309b146bf5833bdd5c5cd803ef263facdd /actionpack | |
parent | 10d0fcd4ecdb6c9fc48d95c4ccac1cc7455aa707 (diff) | |
download | rails-d5f642294ccd696c852ba3d538a4f1180c101a4b.tar.gz rails-d5f642294ccd696c852ba3d538a4f1180c101a4b.tar.bz2 rails-d5f642294ccd696c852ba3d538a4f1180c101a4b.zip |
test javascript include with and without application.js
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5875 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/fixtures/public/javascripts/application.js | 0 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 33 |
2 files changed, 13 insertions, 20 deletions
diff --git a/actionpack/test/fixtures/public/javascripts/application.js b/actionpack/test/fixtures/public/javascripts/application.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/actionpack/test/fixtures/public/javascripts/application.js diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index bc4f026f7b..4a99e9d321 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -6,24 +6,19 @@ class AssetTagHelperTest < Test::Unit::TestCase include ActionView::Helpers::AssetTagHelper def setup - @controller = Class.new do + Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/") + @controller = Class.new do attr_accessor :request - - def url_for(options, *parameters_for_method_reference) - "http://www.example.com" - end - + def url_for(*args) "http://www.example.com" end end.new - - @request = Class.new do - def relative_url_root - "" - end + + @request = Class.new do + def relative_url_root() "" end end.new @controller.request = @request - + ActionView::Helpers::AssetTagHelper::reset_javascript_include_default end @@ -111,14 +106,16 @@ class AssetTagHelperTest < Test::Unit::TestCase end def test_javascript_include_tag + Object.send(:remove_const, :RAILS_ROOT) if defined?(RAILS_ROOT) JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } - Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/") - ENV["RAILS_ASSET_ID"] = "1" + + ENV["RAILS_ASSET_ID"] = "1" assert_dom_equal(%(<script src="/javascripts/prototype.js?1" type="text/javascript"></script>\n<script src="/javascripts/effects.js?1" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js?1" type="text/javascript"></script>\n<script src="/javascripts/controls.js?1" type="text/javascript"></script>\n<script src="/javascripts/application.js?1" type="text/javascript"></script>), javascript_include_tag(:defaults)) end - + def test_register_javascript_include_default + Object.send(:remove_const, :RAILS_ROOT) if defined?(RAILS_ROOT) ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider' assert_dom_equal %(<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/slider.js" type="text/javascript"></script>), javascript_include_tag(:defaults) ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2' @@ -146,26 +143,22 @@ class AssetTagHelperTest < Test::Unit::TestCase assert_deprecated("image_path") { assert_dom_equal(tag, eval(method)) } end end - + def test_timebased_asset_id - Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/") expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png") end def test_should_skip_asset_id_on_complete_url - Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/") assert_equal %(<img alt="Rails" src="http://www.example.com/rails.png" />), image_tag("http://www.example.com/rails.png") end def test_should_use_preset_asset_id - Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/") ENV["RAILS_ASSET_ID"] = "4500" assert_equal %(<img alt="Rails" src="/images/rails.png?4500" />), image_tag("rails.png") end def test_preset_empty_asset_id - Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/") ENV["RAILS_ASSET_ID"] = "" assert_equal %(<img alt="Rails" src="/images/rails.png" />), image_tag("rails.png") end |