From c15bb4901b4c33667d56ad4a2ffbeaa3fb0f9b88 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 6 Aug 2010 17:57:58 +0200 Subject: Fixed routes to use new API in a few more actionpack tests --- .../test/controller/new_base/content_type_test.rb | 12 +++++++++--- .../controller/new_base/render_template_test.rb | 10 +++++++--- actionpack/test/controller/new_base/render_test.rb | 22 +++++++++++++++++----- .../test/controller/new_base/render_text_test.rb | 20 ++++++++++++++------ actionpack/test/controller/test_test.rb | 10 +++++++++- 5 files changed, 56 insertions(+), 18 deletions(-) (limited to 'actionpack') diff --git a/actionpack/test/controller/new_base/content_type_test.rb b/actionpack/test/controller/new_base/content_type_test.rb index 33c2e442f0..8ba30944f5 100644 --- a/actionpack/test/controller/new_base/content_type_test.rb +++ b/actionpack/test/controller/new_base/content_type_test.rb @@ -42,10 +42,16 @@ module ContentType 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 diff --git a/actionpack/test/controller/new_base/render_template_test.rb b/actionpack/test/controller/new_base/render_template_test.rb index 70cebbfd89..fea98d6bbd 100644 --- a/actionpack/test/controller/new_base/render_template_test.rb +++ b/actionpack/test/controller/new_base/render_template_test.rb @@ -123,10 +123,14 @@ module RenderTemplate 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 diff --git a/actionpack/test/controller/new_base/render_test.rb b/actionpack/test/controller/new_base/render_test.rb index 6bd7453d1a..df97a2725b 100644 --- a/actionpack/test/controller/new_base/render_test.rb +++ b/actionpack/test/controller/new_base/render_test.rb @@ -37,15 +37,27 @@ module Render 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 diff --git a/actionpack/test/controller/new_base/render_text_test.rb b/actionpack/test/controller/new_base/render_text_test.rb index 81c2a9daf2..06d500cca7 100644 --- a/actionpack/test/controller/new_base/render_text_test.rb +++ b/actionpack/test/controller/new_base/render_text_test.rb @@ -66,16 +66,24 @@ module RenderText 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 diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 0dd49cef70..fc7d314e04 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -465,7 +465,15 @@ XML 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 -- cgit v1.2.3