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

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

上级 442e5496
......@@ -42,11 +42,17 @@ def set_as_nil_on_response_obj
class ExplicitContentTypeTest < Rack::TestCase
test "default response is HTML and UTF8" do
with_routing do |set|
set.draw do
match ':controller', :action => 'index'
end
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
get "/content_type/base/set_on_response_obj"
......
......@@ -123,11 +123,15 @@ class TestWithLayout < Rack::TestCase
describe "Rendering with :template using implicit or explicit layout"
test "rendering with implicit layout" do
with_routing do |set|
set.draw { match ':controller', :action => :index }
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
get "/render_template/with_layout/with_layout"
......
......@@ -37,18 +37,30 @@ def index
class RenderTest < Rack::TestCase
test "render with blank" do
with_routing do |set|
set.draw do
match ":controller", :action => 'index'
end
get "/render/blank_render"
assert_body "Hello world!"
assert_status 200
end
end
test "rendering more than once raises an exception" do
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
class TestOnlyRenderPublicActions < Rack::TestCase
describe "Only public methods on actual controllers are callable actions"
......
......@@ -66,17 +66,25 @@ 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
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
with_routing do |set|
set.draw { match ':controller', :action => 'index' }
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
get "/render_text/with_layout/custom_code"
......
......@@ -465,8 +465,16 @@ def test_assert_routing_with_method
end
def test_assert_routing_in_module
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
with_routing do |set|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册