aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-05-29 20:07:47 +0200
committerMikel Lindsaar <raasdnil@gmail.com>2010-06-03 23:32:10 +1000
commited34652d1aca148fea61c5309c1bd5ff3a55abfa (patch)
treeee2fbf07bfca011623c928c0b24a7783925e8f88 /railties/test/application
parente6b0ea3f8a252b6795156ad8c0816198f7c18cf9 (diff)
downloadrails-ed34652d1aca148fea61c5309c1bd5ff3a55abfa.tar.gz
rails-ed34652d1aca148fea61c5309c1bd5ff3a55abfa.tar.bz2
rails-ed34652d1aca148fea61c5309c1bd5ff3a55abfa.zip
Removing Metal from Rails 3.
If you have existing Metals, you have a few options: * if your metal behaves like a middleware, add it to the middleware stack via config.middleware.use. You can use methods on the middleware stack to control exactly where it should go * if it behaves like a Rack endpoint, you can link to it in the router. This will result in more optimal routing time, and allows you to remove code in your endpoint that matches specific URLs in favor of the more powerful handling in the router itself. For the future, you can use ActionController::Metal to get a very fast controller with the ability to opt-in to specific controller features without paying the penalty of the full controller stack. Since Rails 3 is closer to Rack, the Metal abstraction is no longer needed.
Diffstat (limited to 'railties/test/application')
-rw-r--r--railties/test/application/metal_test.rb86
-rw-r--r--railties/test/application/middleware_test.rb6
-rw-r--r--railties/test/application/paths_test.rb2
3 files changed, 0 insertions, 94 deletions
diff --git a/railties/test/application/metal_test.rb b/railties/test/application/metal_test.rb
deleted file mode 100644
index 1ec62282c8..0000000000
--- a/railties/test/application/metal_test.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require 'isolation/abstract_unit'
-
-module ApplicationTests
- class MetalTest < Test::Unit::TestCase
- include ActiveSupport::Testing::Isolation
-
- def setup
- build_app
- boot_rails
-
- require 'rack/test'
- extend Rack::Test::Methods
- end
-
- def app
- @app ||= begin
- require "#{app_path}/config/environment"
- Rails.application
- end
- end
-
- test "single metal endpoint" do
- app_file 'app/metal/foo_metal.rb', <<-RUBY
- class FooMetal
- def self.call(env)
- [200, { "Content-Type" => "text/html"}, ["FooMetal"]]
- end
- end
- RUBY
-
- get "/not/slash"
- assert_equal 200, last_response.status
- assert_equal "FooMetal", last_response.body
- end
-
- test "multiple metal endpoints" do
- app_file 'app/metal/metal_a.rb', <<-RUBY
- class MetalA
- def self.call(env)
- [404, { "Content-Type" => "text/html", "X-Cascade" => "pass" }, ["Metal A"]]
- end
- end
- RUBY
-
- app_file 'app/metal/metal_b.rb', <<-RUBY
- class MetalB
- def self.call(env)
- [200, { "Content-Type" => "text/html"}, ["Metal B"]]
- end
- end
- RUBY
-
- get "/not/slash"
- assert_equal 200, last_response.status
- assert_equal "Metal B", last_response.body
- end
-
- test "pass through to application" do
- app_file 'app/metal/foo_metal.rb', <<-RUBY
- class FooMetal
- def self.call(env)
- [404, { "Content-Type" => "text/html", "X-Cascade" => "pass" }, ["Not Found"]]
- end
- end
- RUBY
-
- controller :foo, <<-RUBY
- class FooController < ActionController::Base
- def index
- render :text => "foo"
- end
- end
- RUBY
-
- app_file 'config/routes.rb', <<-RUBY
- AppTemplate::Application.routes.draw do |map|
- match ':controller(/:action)'
- end
- RUBY
-
- get "/foo"
- assert_equal 200, last_response.status
- assert_equal "foo", last_response.body
- end
- end
-end
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb
index 617525bf78..78e7c39660 100644
--- a/railties/test/application/middleware_test.rb
+++ b/railties/test/application/middleware_test.rb
@@ -82,12 +82,6 @@ module ApplicationTests
assert_equal "Rack::Config", middleware.first
end
- test "shows cascade if any metal exists" do
- app_file "app/metal/foo.rb", "class Foo; end"
- boot!
- assert middleware.include?("ActionDispatch::Cascade")
- end
-
# x_sendfile_header middleware
test "config.action_dispatch.x_sendfile_header defaults to ''" do
make_basic_app
diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb
index 978d677efc..c98b11556b 100644
--- a/railties/test/application/paths_test.rb
+++ b/railties/test/application/paths_test.rb
@@ -38,7 +38,6 @@ module ApplicationTests
test "booting up Rails yields a valid paths object" do
assert_path @paths.app.models, "app", "models"
- assert_path @paths.app.metals, "app", "metal"
assert_path @paths.app.helpers, "app", "helpers"
assert_path @paths.app.views, "app", "views"
assert_path @paths.lib, "lib"
@@ -73,7 +72,6 @@ module ApplicationTests
assert_in_load_path "vendor"
assert_not_in_load_path "app", "views"
- assert_not_in_load_path "app", "metal"
assert_not_in_load_path "config"
assert_not_in_load_path "config", "locales"
assert_not_in_load_path "config", "environments"