aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb4
-rw-r--r--railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb4
-rw-r--r--railties/test/metal_test.rb30
3 files changed, 34 insertions, 4 deletions
diff --git a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb
index 2d373ce422..4ca4ddd447 100644
--- a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb
+++ b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb
@@ -1,5 +1,5 @@
-class MetalA < Rails::Rack::Metal
+class MetalA
def self.call(env)
- [200, { "Content-Type" => "text/html"}, ["Hi"]]
+ [404, { "Content-Type" => "text/html"}, ["Metal A"]]
end
end
diff --git a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb
index a8bbf3fd60..80e69fe0b0 100644
--- a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb
+++ b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb
@@ -1,5 +1,5 @@
-class MetalB < Rails::Rack::Metal
+class MetalB
def self.call(env)
- [200, { "Content-Type" => "text/html"}, ["Hi"]]
+ [200, { "Content-Type" => "text/html"}, ["Metal B"]]
end
end
diff --git a/railties/test/metal_test.rb b/railties/test/metal_test.rb
index d3d231132b..c79a819a76 100644
--- a/railties/test/metal_test.rb
+++ b/railties/test/metal_test.rb
@@ -55,8 +55,38 @@ class MetalTest < Test::Unit::TestCase
assert_equal(["FooMetal", "EngineMetal"], found_metals_as_string_array)
end
end
+
+ def test_metal_default_pass_through_on_404
+ use_appdir("multiplemetals") do
+ result = Rails::Rack::Metal.new(app).call({})
+ assert_equal 200, result.first
+ assert_equal ["Metal B"], result.last
+ end
+ end
+
+ def test_metal_pass_through_on_417
+ use_appdir("multiplemetals") do
+ Rails::Rack::Metal.pass_through_on = 417
+ result = Rails::Rack::Metal.new(app).call({})
+ assert_equal 404, result.first
+ assert_equal ["Metal A"], result.last
+ end
+ end
+
+ def test_metal_pass_through_on_404_and_200
+ use_appdir("multiplemetals") do
+ Rails::Rack::Metal.pass_through_on = [404, 200]
+ result = Rails::Rack::Metal.new(app).call({})
+ assert_equal 402, result.first
+ assert_equal ["End of the Line"], result.last
+ end
+ end
private
+
+ def app
+ lambda{[402,{},["End of the Line"]]}
+ end
def use_appdir(root)
dir = "#{File.dirname(__FILE__)}/fixtures/metal/#{root}"