Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix a bunch of failing AP / AM specs created from the previous Abstra…

…ctController configuration refactor.
  • Loading branch information...
commit ad2e6ee4ec5cc6c6bc5f11bfb875e582dbe55468 1 parent 9eddc85
Carl Lerche authored
View
8 actionmailer/test/old_base/asset_host_test.rb
@@ -21,13 +21,17 @@ def teardown
end
def test_asset_host_as_string
- ActionController::Base.asset_host = "http://www.example.com"
+ ActionMailer::Base.configure do |c|
+ c.asset_host = "http://www.example.com"
+ c.assets_dir = File.dirname(__FILE__)
+ end
+
mail = AssetHostMailer.email_with_asset
assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.to_s.strip
end
def test_asset_host_as_one_arguement_proc
- ActionController::Base.asset_host = Proc.new { |source|
+ AssetHostMailer.config.asset_host = Proc.new { |source|
if source.starts_with?('/images')
"http://images.example.com"
else
View
2  actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -670,7 +670,7 @@ def is_uri?(path)
# or the value returned from invoking the proc if it's a proc or the value from
# invoking call if it's an object responding to call.
def compute_asset_host(source)
- if host = ActionController::Base.asset_host
+ if host = config.asset_host
if host.is_a?(Proc) || host.respond_to?(:call)
case host.is_a?(Proc) ? host.arity : host.method(:call).arity
when 2
View
42 actionpack/test/template/asset_tag_helper_test.rb
@@ -401,7 +401,7 @@ def test_should_not_modify_source_string
def test_caching_image_path_with_caching_and_proc_asset_host_using_request
ENV['RAILS_ASSET_ID'] = ''
- ActionController::Base.asset_host = Proc.new do |source, request|
+ @controller.config.asset_host = Proc.new do |source, request|
if request.ssl?
"#{request.protocol}#{request.host_with_port}"
else
@@ -409,8 +409,6 @@ def test_caching_image_path_with_caching_and_proc_asset_host_using_request
end
end
- ActionController::Base.perform_caching = true
-
@controller.request.stubs(:ssl?).returns(false)
assert_equal "http://assets15.example.com/images/xml.png", image_path("xml.png")
@@ -421,7 +419,7 @@ def test_caching_image_path_with_caching_and_proc_asset_host_using_request
def test_caching_javascript_include_tag_when_caching_on
ENV["RAILS_ASSET_ID"] = ""
- ActionController::Base.asset_host = 'http://a0.example.com'
+ @controller.config.asset_host = 'http://a0.example.com'
ActionController::Base.perform_caching = true
assert_dom_equal(
@@ -453,7 +451,7 @@ def test_caching_javascript_include_tag_when_caching_on
def test_caching_javascript_include_tag_when_caching_on_with_proc_asset_host
ENV['RAILS_ASSET_ID'] = ''
- ActionController::Base.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" }
+ @controller.config.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" }
ActionController::Base.perform_caching = true
assert_equal '/javascripts/scripts.js'.length, 23
@@ -470,7 +468,7 @@ def test_caching_javascript_include_tag_when_caching_on_with_proc_asset_host
def test_caching_javascript_include_tag_when_caching_on_with_2_argument_proc_asset_host
ENV['RAILS_ASSET_ID'] = ''
- ActionController::Base.asset_host = Proc.new { |source, request|
+ @controller.config.asset_host = Proc.new { |source, request|
if request.ssl?
"#{request.protocol}#{request.host_with_port}"
else
@@ -507,7 +505,7 @@ def ssl?() true end
def test_caching_javascript_include_tag_when_caching_on_with_2_argument_object_asset_host
ENV['RAILS_ASSET_ID'] = ''
- ActionController::Base.asset_host = Class.new do
+ @controller.config.asset_host = Class.new do
def call(source, request)
if request.ssl?
"#{request.protocol}#{request.host_with_port}"
@@ -547,7 +545,7 @@ def ssl?() true end
def test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory
ENV["RAILS_ASSET_ID"] = ""
- ActionController::Base.asset_host = 'http://a%d.example.com'
+ @controller.config.asset_host = 'http://a%d.example.com'
ActionController::Base.perform_caching = true
hash = '/javascripts/cache/money.js'.hash % 4
@@ -563,7 +561,7 @@ def test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory
def test_caching_javascript_include_tag_with_all_and_recursive_puts_defaults_at_the_start_of_the_file
ENV["RAILS_ASSET_ID"] = ""
- ActionController::Base.asset_host = 'http://a0.example.com'
+ @controller.config.asset_host = 'http://a0.example.com'
ActionController::Base.perform_caching = true
assert_dom_equal(
@@ -584,7 +582,7 @@ def test_caching_javascript_include_tag_with_all_and_recursive_puts_defaults_at_
def test_caching_javascript_include_tag_with_all_puts_defaults_at_the_start_of_the_file
ENV["RAILS_ASSET_ID"] = ""
- ActionController::Base.asset_host = 'http://a0.example.com'
+ @controller.config.asset_host = 'http://a0.example.com'
ActionController::Base.perform_caching = true
assert_dom_equal(
@@ -692,7 +690,7 @@ def test_caching_javascript_include_tag_when_caching_off_and_missing_javascript_
def test_caching_stylesheet_link_tag_when_caching_on
ENV["RAILS_ASSET_ID"] = ""
- ActionController::Base.asset_host = 'http://a0.example.com'
+ @controller.config.asset_host = 'http://a0.example.com'
ActionController::Base.perform_caching = true
assert_dom_equal(
@@ -802,7 +800,7 @@ def test_caching_stylesheet_link_tag_when_caching_off_and_missing_css_file
def test_caching_stylesheet_link_tag_when_caching_on_with_proc_asset_host
ENV["RAILS_ASSET_ID"] = ""
- ActionController::Base.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" }
+ @controller.config.asset_host = Proc.new { |source| "http://a#{source.length}.example.com" }
ActionController::Base.perform_caching = true
assert_equal '/stylesheets/styles.css'.length, 23
@@ -911,43 +909,33 @@ def test_should_ignore_relative_root_path_on_complete_url
end
def test_should_compute_proper_path_with_asset_host
- ActionController::Base.asset_host = "http://assets.example.com"
+ @controller.config.asset_host = "http://assets.example.com"
assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag)
assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr"))
assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style"))
assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/images/xml.png), image_path("xml.png"))
assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png"))
assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse2.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png")))
- ensure
- ActionController::Base.asset_host = ""
end
def test_should_ignore_asset_host_on_complete_url
- ActionController::Base.asset_host = "http://assets.example.com"
+ @controller.config.asset_host = "http://assets.example.com"
assert_dom_equal(%(<link href="http://bar.example.com/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag("http://bar.example.com/stylesheets/style.css"))
- ensure
- ActionController::Base.asset_host = ""
end
def test_should_wildcard_asset_host_between_zero_and_four
- ActionController::Base.asset_host = 'http://a%d.example.com'
+ @controller.config.asset_host = 'http://a%d.example.com'
assert_match %r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png')
- ensure
- ActionController::Base.asset_host = nil
end
def test_asset_host_without_protocol_should_use_request_protocol
- ActionController::Base.asset_host = 'a.example.com'
+ @controller.config.asset_host = 'a.example.com'
assert_equal 'gopher://a.example.com/collaboration/hieraki/images/xml.png', image_path('xml.png')
- ensure
- ActionController::Base.asset_host = nil
end
def test_asset_host_without_protocol_should_use_request_protocol_even_if_path_present
- ActionController::Base.asset_host = 'a.example.com/files/go/here'
+ @controller.config.asset_host = 'a.example.com/files/go/here'
assert_equal 'gopher://a.example.com/files/go/here/collaboration/hieraki/images/xml.png', image_path('xml.png')
- ensure
- ActionController::Base.asset_host = nil
end
def test_assert_css_and_js_of_the_same_name_return_correct_extension
Please sign in to comment.
Something went wrong with that request. Please try again.