Skip to content
This repository
Browse code

Rails::InfoController tests passing

This includes new tests for /rails/info/routes
  • Loading branch information...
commit c3e3102904c98a6e05bee33616288323278692b8 1 parent cb44e0f
Richard Schneeman authored May 23, 2012
9  railties/test/application/route_inspect_test.rb
@@ -164,5 +164,14 @@ def test_redirect
164 164
       assert_equal "   bar GET /bar(.:format)    redirect(307, path: /foo/bar)", output[1]
165 165
       assert_equal "foobar GET /foobar(.:format) redirect(301)", output[2]
166 166
     end
  167
+
  168
+    def test_presenter
  169
+      output = draw do
  170
+        get "/foo"    => redirect("/foo/bar"), :constraints => { :subdomain => "admin" }
  171
+        get "/bar"    => redirect(path: "/foo/bar", status: 307)
  172
+        get "/foobar" => redirect{ "/foo/bar" }
  173
+      end
  174
+      assert_equal output.join("\n"), Rails::Application::RoutePresenter.display_routes(@set.routes)
  175
+    end
167 176
   end
168 177
 end
12  railties/test/application/routing_test.rb
@@ -15,12 +15,24 @@ def teardown
15 15
       teardown_app
16 16
     end
17 17
 
  18
+    test "rails/info/routes in development" do
  19
+      app("development")
  20
+      get "/rails/info/routes"
  21
+      assert_equal 200, last_response.status
  22
+    end
  23
+
18 24
     test "rails/info/properties in development" do
19 25
       app("development")
20 26
       get "/rails/info/properties"
21 27
       assert_equal 200, last_response.status
22 28
     end
23 29
 
  30
+    test "rails/info/routes in production" do
  31
+      app("production")
  32
+      get "/rails/info/routes"
  33
+      assert_equal 404, last_response.status
  34
+    end
  35
+
24 36
     test "rails/info/properties in production" do
25 37
       app("production")
26 38
       get "/rails/info/properties"
17  railties/test/rails_info_controller_test.rb
@@ -12,29 +12,28 @@ class InfoControllerTest < ActionController::TestCase
12 12
   def setup
13 13
     Rails.application.routes.draw do
14 14
       get '/rails/info/properties' => "rails/info#properties"
  15
+      get '/rails/info/routes'     => "rails/info#routes"
15 16
     end
16  
-    @request.stubs(:local? => true)
17  
-    @controller.stubs(:consider_all_requests_local? => false)
  17
+    @controller.stubs(:local_request? => true)
18 18
     @routes = Rails.application.routes
19 19
 
20 20
     Rails::InfoController.send(:include, @routes.url_helpers)
21 21
   end
22 22
 
23 23
   test "info controller does not allow remote requests" do
24  
-    @request.stubs(:local? => false)
  24
+    @controller.stubs(:local_request? => false)
25 25
     get :properties
26 26
     assert_response :forbidden
27 27
   end
28 28
 
29 29
   test "info controller renders an error message when request was forbidden" do
30  
-    @request.stubs(:local? => false)
  30
+    @controller.stubs(:local_request? => false)
31 31
     get :properties
32 32
     assert_select 'p'
33 33
   end
34 34
 
35 35
   test "info controller allows requests when all requests are considered local" do
36  
-    @request.stubs(:local? => false)
37  
-    @controller.stubs(:consider_all_requests_local? => true)
  36
+    @controller.stubs(:local_request? => true)
38 37
     get :properties
39 38
     assert_response :success
40 39
   end
@@ -48,4 +47,10 @@ def setup
48 47
     get :properties
49 48
     assert_select 'table'
50 49
   end
  50
+
  51
+  test "info controller renders with routes" do
  52
+    get :routes
  53
+    assert_select 'pre'
  54
+  end
  55
+
51 56
 end

0 notes on commit c3e3102

Aaron Patterson

I don't see where the RoutePresenter is defined. Am I missing something?

Richard Schneeman

Nope, we refactored it out, we need to remove this test, good catch. Want a PR?

Richard Schneeman

Submitted PR #6481, sorry about that.

Please sign in to comment.
Something went wrong with that request. Please try again.