Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rails::InfoController tests passing

This includes new tests for /rails/info/routes
  • Loading branch information...
commit c3e3102904c98a6e05bee33616288323278692b8 1 parent cb44e0f
@schneems schneems authored
View
9 railties/test/application/route_inspect_test.rb
@@ -164,5 +164,14 @@ def test_redirect
assert_equal " bar GET /bar(.:format) redirect(307, path: /foo/bar)", output[1]
assert_equal "foobar GET /foobar(.:format) redirect(301)", output[2]
end
+
+ def test_presenter
+ output = draw do
+ get "/foo" => redirect("/foo/bar"), :constraints => { :subdomain => "admin" }
+ get "/bar" => redirect(path: "/foo/bar", status: 307)
+ get "/foobar" => redirect{ "/foo/bar" }
+ end
+ assert_equal output.join("\n"), Rails::Application::RoutePresenter.display_routes(@set.routes)
@tenderlove Owner

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

@schneems Collaborator

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

@rafaelfranca Owner

please.

@schneems Collaborator

Submitted PR #6481, sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
end
end
View
12 railties/test/application/routing_test.rb
@@ -15,12 +15,24 @@ def teardown
teardown_app
end
+ test "rails/info/routes in development" do
+ app("development")
+ get "/rails/info/routes"
+ assert_equal 200, last_response.status
+ end
+
test "rails/info/properties in development" do
app("development")
get "/rails/info/properties"
assert_equal 200, last_response.status
end
+ test "rails/info/routes in production" do
+ app("production")
+ get "/rails/info/routes"
+ assert_equal 404, last_response.status
+ end
+
test "rails/info/properties in production" do
app("production")
get "/rails/info/properties"
View
17 railties/test/rails_info_controller_test.rb
@@ -12,29 +12,28 @@ class InfoControllerTest < ActionController::TestCase
def setup
Rails.application.routes.draw do
get '/rails/info/properties' => "rails/info#properties"
+ get '/rails/info/routes' => "rails/info#routes"
end
- @request.stubs(:local? => true)
- @controller.stubs(:consider_all_requests_local? => false)
+ @controller.stubs(:local_request? => true)
@routes = Rails.application.routes
Rails::InfoController.send(:include, @routes.url_helpers)
end
test "info controller does not allow remote requests" do
- @request.stubs(:local? => false)
+ @controller.stubs(:local_request? => false)
get :properties
assert_response :forbidden
end
test "info controller renders an error message when request was forbidden" do
- @request.stubs(:local? => false)
+ @controller.stubs(:local_request? => false)
get :properties
assert_select 'p'
end
test "info controller allows requests when all requests are considered local" do
- @request.stubs(:local? => false)
- @controller.stubs(:consider_all_requests_local? => true)
+ @controller.stubs(:local_request? => true)
get :properties
assert_response :success
end
@@ -48,4 +47,10 @@ def setup
get :properties
assert_select 'table'
end
+
+ test "info controller renders with routes" do
+ get :routes
+ assert_select 'pre'
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.