提交 c15bb490 编写于 作者: P Piotr Sarnacki

Fixed routes to use new API in a few more actionpack tests

上级 442e5496
......@@ -42,10 +42,16 @@ def set_as_nil_on_response_obj
class ExplicitContentTypeTest < Rack::TestCase
test "default response is HTML and UTF8" do
get "/content_type/base"
with_routing do |set|
set.draw do
match ':controller', :action => 'index'
end
assert_body "Hello world!"
assert_header "Content-Type", "text/html; charset=utf-8"
get "/content_type/base"
assert_body "Hello world!"
assert_header "Content-Type", "text/html; charset=utf-8"
end
end
test "setting the content type of the response directly on the response object" do
......
......@@ -123,10 +123,14 @@ class TestWithLayout < Rack::TestCase
describe "Rendering with :template using implicit or explicit layout"
test "rendering with implicit layout" do
get "/render_template/with_layout"
with_routing do |set|
set.draw { match ':controller', :action => :index }
assert_body "Hello from basic.html.erb, I'm here!"
assert_status 200
get "/render_template/with_layout"
assert_body "Hello from basic.html.erb, I'm here!"
assert_status 200
end
end
test "rendering with layout => :true" do
......
......@@ -37,15 +37,27 @@ def index
class RenderTest < Rack::TestCase
test "render with blank" do
get "/render/blank_render"
with_routing do |set|
set.draw do
match ":controller", :action => 'index'
end
assert_body "Hello world!"
assert_status 200
get "/render/blank_render"
assert_body "Hello world!"
assert_status 200
end
end
test "rendering more than once raises an exception" do
assert_raises(AbstractController::DoubleRenderError) do
get "/render/double_render", {}, "action_dispatch.show_exceptions" => false
with_routing do |set|
set.draw do
match ":controller", :action => 'index'
end
assert_raises(AbstractController::DoubleRenderError) do
get "/render/double_render", {}, "action_dispatch.show_exceptions" => false
end
end
end
end
......
......@@ -66,16 +66,24 @@ class RenderTextTest < Rack::TestCase
describe "Rendering text using render :text"
test "rendering text from a action with default options renders the text with the layout" do
get "/render_text/simple"
assert_body "hello david"
assert_status 200
with_routing do |set|
set.draw { match ':controller', :action => 'index' }
get "/render_text/simple"
assert_body "hello david"
assert_status 200
end
end
test "rendering text from a action with default options renders the text without the layout" do
get "/render_text/with_layout"
with_routing do |set|
set.draw { match ':controller', :action => 'index' }
assert_body "hello david"
assert_status 200
get "/render_text/with_layout"
assert_body "hello david"
assert_status 200
end
end
test "rendering text, while also providing a custom status code" do
......
......@@ -465,7 +465,15 @@ def test_assert_routing_with_method
end
def test_assert_routing_in_module
assert_routing 'admin/user', :controller => 'admin/user', :action => 'index'
with_routing do |set|
set.draw do
namespace :admin do
match 'user' => 'user#index'
end
end
assert_routing 'admin/user', :controller => 'admin/user', :action => 'index'
end
end
def test_assert_routing_with_glob
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册