Looking at the Rails Guides http://guides.rubyonrails.org/testing.html#integration-testing-examples and this SO question Rails Functional Test of Arbitrary or Custom URLs, the following should work in a test:
require 'test_helper'
class ApplicationControllerTest < ActionController::TestCase
test "test authentication" do
get "/dash"
assert_response :success
end
end
But I get an error: ActionController::RoutingError: No route matches {:controller=>"application", :action=>"/dash"}
My route is set up and works at the following URL: http://localhost:3000/dash
This is the route:
dash /dash(.:format) {:action=>"population", :controller=>"dashboard"}
Why wouldn't a get
with a URL work?
I am running this test from class ApplicationControllerTest < ActionController::TestCase
, which is different from dashboard controller. Do you have to run it from the functional test of the same name as the controller?
Working in Rails 3.07 using Test::Unit.