aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_controller/abstract_controller_test.rb4
-rw-r--r--actionpack/test/activerecord/active_record_store_test.rb1
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb1
-rw-r--r--actionpack/test/controller/addresses_render_test.rb8
-rw-r--r--actionpack/test/controller/integration_test.rb1
-rw-r--r--actionpack/test/controller/routing_test.rb78
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb1
-rw-r--r--actionpack/test/controller/view_paths_test.rb2
-rw-r--r--actionpack/test/dispatch/session/cookie_store_test.rb4
-rw-r--r--actionpack/test/lib/controller/fake_controllers.rb10
-rw-r--r--actionpack/test/lib/fixture_template.rb61
-rw-r--r--actionpack/test/new_base/content_negotiation_test.rb18
-rw-r--r--actionpack/test/new_base/render_file_test.rb2
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb62
-rw-r--r--actionpack/test/template/compiled_templates_test.rb3
-rw-r--r--actionpack/test/template/url_helper_test.rb118
16 files changed, 214 insertions, 160 deletions
diff --git a/actionpack/test/abstract_controller/abstract_controller_test.rb b/actionpack/test/abstract_controller/abstract_controller_test.rb
index 7991436703..3b4046a424 100644
--- a/actionpack/test/abstract_controller/abstract_controller_test.rb
+++ b/actionpack/test/abstract_controller/abstract_controller_test.rb
@@ -148,10 +148,10 @@ module AbstractController
private
def self.layout(formats)
begin
- view_paths.find(name.underscore, {:formats => formats}, "layouts")
+ find_template(name.underscore, {:formats => formats}, :_prefix => "layouts")
rescue ActionView::MissingTemplate
begin
- view_paths.find("application", {:formats => formats}, "layouts")
+ find_template("application", {:formats => formats}, :_prefix => "layouts")
rescue ActionView::MissingTemplate
end
end
diff --git a/actionpack/test/activerecord/active_record_store_test.rb b/actionpack/test/activerecord/active_record_store_test.rb
index a46ce7a0aa..19d9c955a5 100644
--- a/actionpack/test/activerecord/active_record_store_test.rb
+++ b/actionpack/test/activerecord/active_record_store_test.rb
@@ -176,6 +176,7 @@ class ActiveRecordStoreTest < ActionController::IntegrationTest
c.connect "/:action"
end
end
+ reset_app!
yield
end
end
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 453812c128..901cb940ea 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -1,5 +1,6 @@
require 'abstract_unit'
require 'action_controller/vendor/html-scanner'
+require 'controller/fake_controllers'
# a controller class to facilitate the tests
class ActionPackAssertionsController < ActionController::Base
diff --git a/actionpack/test/controller/addresses_render_test.rb b/actionpack/test/controller/addresses_render_test.rb
index 2d2a2745b0..c1cd22113d 100644
--- a/actionpack/test/controller/addresses_render_test.rb
+++ b/actionpack/test/controller/addresses_render_test.rb
@@ -1,5 +1,6 @@
require 'abstract_unit'
require 'logger'
+require 'controller/fake_controllers'
class Address
def Address.count(conditions = nil, join = nil)
@@ -15,13 +16,8 @@ class Address
end
end
-class AddressesTestController < ActionController::Base
- def self.controller_name; "addresses"; end
- def self.controller_path; "addresses"; end
-end
-
class AddressesTest < ActionController::TestCase
- tests AddressesTestController
+ tests AddressesController
def setup
super
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 197ba0c69c..93f5bfa272 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -371,6 +371,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest
c.connect "/:action"
end
end
+ reset!
yield
end
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index d20684296f..1aabf71cad 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -232,14 +232,18 @@ class LegacyRouteSetTests < Test::Unit::TestCase
end
def test_basic_named_route
- rs.add_named_route :home, '', :controller => 'content', :action => 'list'
+ rs.draw do |map|
+ map.home '', :controller => 'content', :action => 'list'
+ end
x = setup_for_named_route
assert_equal("http://test.host/",
x.send(:home_url))
end
def test_basic_named_route_with_relative_url_root
- rs.add_named_route :home, '', :controller => 'content', :action => 'list'
+ rs.draw do |map|
+ map.home '', :controller => 'content', :action => 'list'
+ end
x = setup_for_named_route
ActionController::Base.relative_url_root = "/foo"
assert_equal("http://test.host/foo/",
@@ -249,14 +253,18 @@ class LegacyRouteSetTests < Test::Unit::TestCase
end
def test_named_route_with_option
- rs.add_named_route :page, 'page/:title', :controller => 'content', :action => 'show_page'
+ rs.draw do |map|
+ map.page 'page/:title', :controller => 'content', :action => 'show_page'
+ end
x = setup_for_named_route
assert_equal("http://test.host/page/new%20stuff",
x.send(:page_url, :title => 'new stuff'))
end
def test_named_route_with_default
- rs.add_named_route :page, 'page/:title', :controller => 'content', :action => 'show_page', :title => 'AboutPage'
+ rs.draw do |map|
+ map.page 'page/:title', :controller => 'content', :action => 'show_page', :title => 'AboutPage'
+ end
x = setup_for_named_route
assert_equal("http://test.host/page/AboutRails",
x.send(:page_url, :title => "AboutRails"))
@@ -264,36 +272,46 @@ class LegacyRouteSetTests < Test::Unit::TestCase
end
def test_named_route_with_name_prefix
- rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :name_prefix => 'my_'
+ rs.draw do |map|
+ map.page 'page', :controller => 'content', :action => 'show_page', :name_prefix => 'my_'
+ end
x = setup_for_named_route
assert_equal("http://test.host/page",
x.send(:my_page_url))
end
def test_named_route_with_path_prefix
- rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => 'my'
+ rs.draw do |map|
+ map.page 'page', :controller => 'content', :action => 'show_page', :path_prefix => 'my'
+ end
x = setup_for_named_route
assert_equal("http://test.host/my/page",
x.send(:page_url))
end
def test_named_route_with_blank_path_prefix
- rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => ''
+ rs.draw do |map|
+ map.page 'page', :controller => 'content', :action => 'show_page', :path_prefix => ''
+ end
x = setup_for_named_route
assert_equal("http://test.host/page",
x.send(:page_url))
end
def test_named_route_with_nested_controller
- rs.add_named_route :users, 'admin/user', :controller => 'admin/user', :action => 'index'
+ rs.draw do |map|
+ map.users 'admin/user', :controller => 'admin/user', :action => 'index'
+ end
x = setup_for_named_route
assert_equal("http://test.host/admin/user",
x.send(:users_url))
end
def test_optimised_named_route_call_never_uses_url_for
- rs.add_named_route :users, 'admin/user', :controller => '/admin/user', :action => 'index'
- rs.add_named_route :user, 'admin/user/:id', :controller=>'/admin/user', :action=>'show'
+ rs.draw do |map|
+ map.users 'admin/user', :controller => '/admin/user', :action => 'index'
+ map.user 'admin/user/:id', :controller=>'/admin/user', :action=>'show'
+ end
x = setup_for_named_route
x.expects(:url_for).never
x.send(:users_url)
@@ -303,7 +321,9 @@ class LegacyRouteSetTests < Test::Unit::TestCase
end
def test_optimised_named_route_with_host
- rs.add_named_route :pages, 'pages', :controller => 'content', :action => 'show_page', :host => 'foo.com'
+ rs.draw do |map|
+ map.pages 'pages', :controller => 'content', :action => 'show_page', :host => 'foo.com'
+ end
x = setup_for_named_route
x.expects(:url_for).with(:host => 'foo.com', :only_path => false, :controller => 'content', :action => 'show_page', :use_route => :pages).once
x.send(:pages_url)
@@ -378,7 +398,9 @@ class LegacyRouteSetTests < Test::Unit::TestCase
end
def test_paths_slashes_unescaped_with_ordered_parameters
- rs.add_named_route :path, '/file/*path', :controller => 'content'
+ rs.draw do |map|
+ map.path '/file/*path', :controller => 'content'
+ end
# No / to %2F in URI, only for query params.
x = setup_for_named_route
@@ -1781,23 +1803,23 @@ class RouteSetTest < ActiveSupport::TestCase
end
def test_default_route_recognition
- expected = {:controller => 'accounts', :action => 'show', :id => '10'}
- assert_equal expected, default_route_set.recognize_path('/accounts/show/10')
- assert_equal expected, default_route_set.recognize_path('/accounts/show/10/')
+ expected = {:controller => 'pages', :action => 'show', :id => '10'}
+ assert_equal expected, default_route_set.recognize_path('/pages/show/10')
+ assert_equal expected, default_route_set.recognize_path('/pages/show/10/')
expected[:id] = 'jamis'
- assert_equal expected, default_route_set.recognize_path('/accounts/show/jamis/')
+ assert_equal expected, default_route_set.recognize_path('/pages/show/jamis/')
expected.delete :id
- assert_equal expected, default_route_set.recognize_path('/accounts/show')
- assert_equal expected, default_route_set.recognize_path('/accounts/show/')
+ assert_equal expected, default_route_set.recognize_path('/pages/show')
+ assert_equal expected, default_route_set.recognize_path('/pages/show/')
expected[:action] = 'index'
- assert_equal expected, default_route_set.recognize_path('/accounts/')
- assert_equal expected, default_route_set.recognize_path('/accounts')
+ assert_equal expected, default_route_set.recognize_path('/pages/')
+ assert_equal expected, default_route_set.recognize_path('/pages')
assert_raise(ActionController::RoutingError) { default_route_set.recognize_path('/') }
- assert_raise(ActionController::RoutingError) { default_route_set.recognize_path('/accounts/how/goood/it/is/to/be/free') }
+ assert_raise(ActionController::RoutingError) { default_route_set.recognize_path('/pages/how/goood/it/is/to/be/free') }
end
def test_default_route_should_omit_default_action
@@ -1813,15 +1835,15 @@ class RouteSetTest < ActiveSupport::TestCase
end
def test_default_route_should_uri_escape_pluses
- expected = { :controller => 'accounts', :action => 'show', :id => 'hello world' }
- assert_equal expected, default_route_set.recognize_path('/accounts/show/hello world')
- assert_equal expected, default_route_set.recognize_path('/accounts/show/hello%20world')
- assert_equal '/accounts/show/hello%20world', default_route_set.generate(expected, expected)
+ expected = { :controller => 'pages', :action => 'show', :id => 'hello world' }
+ assert_equal expected, default_route_set.recognize_path('/pages/show/hello world')
+ assert_equal expected, default_route_set.recognize_path('/pages/show/hello%20world')
+ assert_equal '/pages/show/hello%20world', default_route_set.generate(expected, expected)
expected[:id] = 'hello+world'
- assert_equal expected, default_route_set.recognize_path('/accounts/show/hello+world')
- assert_equal expected, default_route_set.recognize_path('/accounts/show/hello%2Bworld')
- assert_equal '/accounts/show/hello+world', default_route_set.generate(expected, expected)
+ assert_equal expected, default_route_set.recognize_path('/pages/show/hello+world')
+ assert_equal expected, default_route_set.recognize_path('/pages/show/hello%2Bworld')
+ assert_equal '/pages/show/hello+world', default_route_set.generate(expected, expected)
end
def test_parameter_shell
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index 9b8d07222b..4c4bf9ade4 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -1,4 +1,5 @@
require 'abstract_unit'
+require 'controller/fake_controllers'
ActionController::UrlRewriter
diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb
index c732d1c910..05d2c8407c 100644
--- a/actionpack/test/controller/view_paths_test.rb
+++ b/actionpack/test/controller/view_paths_test.rb
@@ -43,7 +43,7 @@ class ViewLoadPathsTest < ActionController::TestCase
end
def expand(array)
- array.map {|x| File.expand_path(x)}
+ array.map {|x| File.expand_path(x.to_s)}
end
def assert_paths(*paths)
diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb
index 0723a76d2b..d695be0be4 100644
--- a/actionpack/test/dispatch/session/cookie_store_test.rb
+++ b/actionpack/test/dispatch/session/cookie_store_test.rb
@@ -30,7 +30,7 @@ class CookieStoreTest < ActionController::IntegrationTest
end
def get_session_id
- render :text => "foo: #{session[:foo].inspect}; id: #{request.session_options[:id]}"
+ render :text => "id: #{request.session_options[:id]}"
end
def call_reset_session
@@ -119,7 +119,7 @@ class CookieStoreTest < ActionController::IntegrationTest
get '/get_session_id'
assert_response :success
- assert_equal "foo: \"bar\"; id: #{session_id}", response.body
+ assert_equal "id: #{session_id}", response.body
end
end
diff --git a/actionpack/test/lib/controller/fake_controllers.rb b/actionpack/test/lib/controller/fake_controllers.rb
index 6e02e2d21b..22729188a2 100644
--- a/actionpack/test/lib/controller/fake_controllers.rb
+++ b/actionpack/test/lib/controller/fake_controllers.rb
@@ -9,7 +9,14 @@ module Admin
class UserController < ActionController::Base; end
class NewsFeedController < ActionController::Base; end
end
-
+class ElsewhereController < ActionController::Base; end
+class AddressesController < ActionController::Base; end
+class SessionsController < ActionController::Base; end
+class FooController < ActionController::Base; end
+class CController < ActionController::Base; end
+class HiController < ActionController::Base; end
+class BraveController < ActionController::Base; end
+class ImageController < ActionController::Base; end
# For speed test
class SpeedController < ActionController::Base; end
@@ -24,7 +31,6 @@ class UsersController < SpeedController; end
class SettingsController < SpeedController; end
class ChannelsController < SpeedController; end
class ChannelVideosController < SpeedController; end
-class SessionsController < SpeedController; end
class LostPasswordsController < SpeedController; end
class PagesController < SpeedController; end
diff --git a/actionpack/test/lib/fixture_template.rb b/actionpack/test/lib/fixture_template.rb
index 8da92180d1..6b9e7c5270 100644
--- a/actionpack/test/lib/fixture_template.rb
+++ b/actionpack/test/lib/fixture_template.rb
@@ -1,67 +1,24 @@
module ActionView #:nodoc:
- class FixtureResolver < Resolver
+ class FixtureResolver < PathResolver
def initialize(hash = {}, options = {})
super(options)
@hash = hash
end
- def find_templates(name, details, prefix, partial)
- if regexp = details_to_regexp(name, details, prefix, partial)
- cached(regexp) do
- templates = []
- @hash.select { |k,v| k =~ regexp }.each do |path, source|
- templates << Template.new(source, path, *path_to_details(path))
- end
- templates.sort_by {|t| -t.details.values.compact.size }
- end
- end
- end
-
private
- def formats_regexp
- @formats_regexp ||= begin
- formats = Mime::SET.symbols
- '(?:' + formats.map { |l| "\\.#{Regexp.escape(l.to_s)}" }.join('|') + ')?'
+ def query(path, exts)
+ query = Regexp.escape(path)
+ exts.each do |ext|
+ query << '(?:' << ext.map {|e| e && Regexp.escape(".#{e}") }.join('|') << ')'
end
- end
-
- def handler_regexp
- e = TemplateHandlers.extensions.map{|h| "\\.#{Regexp.escape(h.to_s)}"}.join("|")
- "(?:#{e})"
- end
- def details_to_regexp(name, details, prefix, partial)
- path = ""
- path << "#{prefix}/" unless prefix.empty?
- path << (partial ? "_#{name}" : name)
-
- extensions = ""
- [:locales, :formats].each do |k|
- extensions << if exts = details[k]
- '(?:' + exts.map {|e| "\\.#{Regexp.escape(e.to_s)}"}.join('|') + ')?'
- else
- k == :formats ? formats_regexp : ''
- end
+ templates = []
+ @hash.select { |k,v| k =~ /^#{query}$/ }.each do |path, source|
+ templates << Template.new(source, path, *path_to_details(path))
end
-
- %r'^#{Regexp.escape(path)}#{extensions}#{handler_regexp}$'
+ templates.sort_by {|t| -t.details.values.compact.size }
end
- # TODO: fix me
- # :api: plugin
- def path_to_details(path)
- # [:erb, :format => :html, :locale => :en, :partial => true/false]
- if m = path.match(%r'(_)?[\w-]+((?:\.[\w-]+)*)\.(\w+)$')
- partial = m[1] == '_'
- details = (m[2]||"").split('.').reject { |e| e.empty? }
- handler = Template.handler_class_for_extension(m[3])
-
- format = Mime[details.last] && details.pop.to_sym
- locale = details.last && details.pop.to_sym
-
- return handler, :format => format, :locale => locale, :partial => partial
- end
- end
end
end \ No newline at end of file
diff --git a/actionpack/test/new_base/content_negotiation_test.rb b/actionpack/test/new_base/content_negotiation_test.rb
new file mode 100644
index 0000000000..d2f732738d
--- /dev/null
+++ b/actionpack/test/new_base/content_negotiation_test.rb
@@ -0,0 +1,18 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+
+module ContentNegotiation
+
+ # This has no layout and it works
+ class BasicController < ActionController::Base
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "content_negotiation/basic/hello.html.erb" => "Hello world <%= request.formats %>!"
+ )]
+ end
+
+ class TestContentNegotiation < SimpleRouteCase
+ test "A */* Accept header will return HTML" do
+ get "/content_negotiation/basic/hello", {}, "HTTP_ACCEPT" => "*/*"
+ assert_body "Hello world */*!"
+ end
+ end
+end \ No newline at end of file
diff --git a/actionpack/test/new_base/render_file_test.rb b/actionpack/test/new_base/render_file_test.rb
index 769949be0c..8d7f49dbc2 100644
--- a/actionpack/test/new_base/render_file_test.rb
+++ b/actionpack/test/new_base/render_file_test.rb
@@ -3,7 +3,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
module RenderFile
class BasicController < ActionController::Base
- self.view_paths = "."
+ self.view_paths = File.dirname(__FILE__)
def index
render :file => File.join(File.dirname(__FILE__), *%w[.. fixtures test hello_world])
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index 28f9d48671..83fc6a282c 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -213,11 +213,11 @@ class AssetTagHelperTest < ActionView::TestCase
end
def test_javascript_include_tag_with_missing_source
- assert_raise(Errno::ENOENT) {
+ assert_nothing_raised {
javascript_include_tag('missing_security_guard')
}
- assert_raise(Errno::ENOENT) {
+ assert_nothing_raised {
javascript_include_tag(:defaults, 'missing_security_guard')
}
@@ -276,7 +276,7 @@ class AssetTagHelperTest < ActionView::TestCase
end
def test_stylesheet_link_tag_with_missing_source
- assert_raise(Errno::ENOENT) {
+ assert_nothing_raised {
stylesheet_link_tag('missing_security_guard')
}
@@ -639,6 +639,40 @@ class AssetTagHelperTest < ActionView::TestCase
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
end
+ def test_caching_javascript_include_tag_when_caching_on_and_missing_javascript_file
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionController::Base.perform_caching = true
+
+ assert_raise(Errno::ENOENT) {
+ javascript_include_tag('bank', 'robber', 'missing_security_guard', :cache => true)
+ }
+
+ assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
+
+ assert_raise(Errno::ENOENT) {
+ javascript_include_tag('bank', 'robber', 'missing_security_guard', :cache => "money")
+ }
+
+ assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
+ end
+
+ def test_caching_javascript_include_tag_when_caching_off_and_missing_javascript_file
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionController::Base.perform_caching = false
+
+ assert_raise(Errno::ENOENT) {
+ javascript_include_tag('bank', 'robber', 'missing_security_guard', :cache => true)
+ }
+
+ assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
+
+ assert_raise(Errno::ENOENT) {
+ javascript_include_tag('bank', 'robber', 'missing_security_guard', :cache => "money")
+ }
+
+ assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
+ end
+
def test_caching_stylesheet_link_tag_when_caching_on
ENV["RAILS_ASSET_ID"] = ""
ActionController::Base.asset_host = 'http://a0.example.com'
@@ -709,7 +743,6 @@ class AssetTagHelperTest < ActionView::TestCase
def test_caching_stylesheet_link_tag_when_caching_on_and_missing_css_file
ENV["RAILS_ASSET_ID"] = ""
- ActionController::Base.asset_host = 'http://a0.example.com'
ActionController::Base.perform_caching = true
assert_raise(Errno::ENOENT) {
@@ -729,6 +762,27 @@ class AssetTagHelperTest < ActionView::TestCase
FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
end
+ def test_caching_stylesheet_link_tag_when_caching_off_and_missing_css_file
+ ENV["RAILS_ASSET_ID"] = ""
+ ActionController::Base.perform_caching = false
+
+ assert_raise(Errno::ENOENT) {
+ stylesheet_link_tag('bank', 'robber', 'missing_security_guard', :cache => true)
+ }
+
+ assert ! File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
+
+ assert_raise(Errno::ENOENT) {
+ stylesheet_link_tag('bank', 'robber', 'missing_security_guard', :cache => "money")
+ }
+
+ assert ! File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
+
+ ensure
+ FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
+ FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
+ end
+
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" }
diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb
index 7734e6da73..632988bb2e 100644
--- a/actionpack/test/template/compiled_templates_test.rb
+++ b/actionpack/test/template/compiled_templates_test.rb
@@ -14,6 +14,9 @@ class CompiledTemplatesTest < Test::Unit::TestCase
assert_equal "two", render(:file => "test/render_file_with_locals_and_default.erb", :locals => { :secret => "two" })
end
+ # This is broken in 1.8.6 (not supported in Rails 3.0) because the cache uses a Hash
+ # key. Since Ruby 1.8.6 implements Hash#hash using the hash's object_id, it will never
+ # successfully get a cache hit here.
def test_template_changes_are_not_reflected_with_cached_templates
assert_equal "Hello world!", render(:file => "test/hello_world.erb")
modify_template "test/hello_world.erb", "Goodbye world!" do
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index 0e24fbd24d..44f1925653 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -367,25 +367,25 @@ class UrlHelperTest < ActionView::TestCase
end
end
-class UrlHelperWithControllerTest < ActionView::TestCase
- class UrlHelperController < ActionController::Base
- def self.controller_path; 'url_helper_with_controller' end
-
- def show_url_for
- render :inline => "<%= url_for :controller => 'url_helper_with_controller', :action => 'show_url_for' %>"
- end
+class UrlHelperController < ActionController::Base
+ def self.controller_path; 'url_helper_with_controller' end
- def show_named_route
- render :inline => "<%= show_named_route_#{params[:kind]} %>"
- end
+ def show_url_for
+ render :inline => "<%= url_for :controller => 'url_helper_with_controller', :action => 'show_url_for' %>"
+ end
- def nil_url_for
- render :inline => '<%= url_for(nil) %>'
- end
+ def show_named_route
+ render :inline => "<%= show_named_route_#{params[:kind]} %>"
+ end
- def rescue_action(e) raise e end
+ def nil_url_for
+ render :inline => '<%= url_for(nil) %>'
end
+ def rescue_action(e) raise e end
+end
+
+class UrlHelperWithControllerTest < ActionView::TestCase
tests ActionView::Helpers::UrlHelper
def setup
@@ -416,7 +416,7 @@ class UrlHelperWithControllerTest < ActionView::TestCase
def test_url_for_nil_returns_current_path
get :nil_url_for
- assert_equal '/url_helper_with_controller/nil_url_for', @response.body
+ assert_equal '/url_helper/nil_url_for', @response.body
end
def test_named_route_should_show_host_and_path_using_controller_default_url_options
@@ -436,35 +436,33 @@ class UrlHelperWithControllerTest < ActionView::TestCase
def with_url_helper_routing
with_routing do |set|
set.draw do |map|
- map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper_with_controller', :action => 'show_named_route'
+ map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper', :action => 'show_named_route'
end
yield
end
end
end
-class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase
- class TasksController < ActionController::Base
- def self.controller_path; 'tasks' end
-
- def index
- render_default
- end
+class TasksController < ActionController::Base
+ def index
+ render_default
+ end
- def show
- render_default
- end
+ def show
+ render_default
+ end
- def rescue_action(e) raise e end
+ def rescue_action(e) raise e end
- protected
- def render_default
- render :inline =>
- "<%= link_to_unless_current(\"tasks\", tasks_path) %>\n" +
- "<%= link_to_unless_current(\"tasks\", tasks_url) %>"
- end
- end
+ protected
+ def render_default
+ render :inline =>
+ "<%= link_to_unless_current(\"tasks\", tasks_path) %>\n" +
+ "<%= link_to_unless_current(\"tasks\", tasks_url) %>"
+ end
+end
+class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase
tests ActionView::Helpers::UrlHelper
def setup
@@ -537,41 +535,37 @@ class Session
end
end
-class PolymorphicControllerTest < ActionView::TestCase
- class WorkshopsController < ActionController::Base
- def self.controller_path; 'workshops' end
-
- def index
- @workshop = Workshop.new(1, true)
- render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>"
- end
-
- def show
- @workshop = Workshop.new(params[:id], false)
- render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>"
- end
-
- def rescue_action(e) raise e end
+class WorkshopsController < ActionController::Base
+ def index
+ @workshop = Workshop.new(1, true)
+ render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>"
end
- class SessionsController < ActionController::Base
- def self.controller_path; 'sessions' end
+ def show
+ @workshop = Workshop.new(params[:id], false)
+ render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>"
+ end
- def index
- @workshop = Workshop.new(params[:workshop_id], false)
- @session = Session.new(1, true)
- render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>"
- end
+ def rescue_action(e) raise e end
+end
- def show
- @workshop = Workshop.new(params[:workshop_id], false)
- @session = Session.new(params[:id], false)
- render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>"
- end
+class SessionsController < ActionController::Base
+ def index
+ @workshop = Workshop.new(params[:workshop_id], false)
+ @session = Session.new(1, true)
+ render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>"
+ end
- def rescue_action(e) raise e end
+ def show
+ @workshop = Workshop.new(params[:workshop_id], false)
+ @session = Session.new(params[:id], false)
+ render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>"
end
+ def rescue_action(e) raise e end
+end
+
+class PolymorphicControllerTest < ActionView::TestCase
tests ActionView::Helpers::UrlHelper
def setup