Last active
August 29, 2015 14:06
-
-
Save tgxworld/de167eb9cefa3d73f660 to your computer and use it in GitHub Desktop.
Bound Parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'abstract_unit' | |
class SomethingController < ApplicationController | |
def index | |
render plain: 'ok' | |
end | |
end | |
class SomethingTest < ActionDispatch::IntegrationTest | |
class SomeController < ApplicationController | |
def index | |
render plain: 'ok' | |
end | |
end | |
def test_non_nested_controller | |
# Both cases work as expected | |
with_routing do |set| | |
set.draw do | |
get ':controller(/:action(/:id))' | |
end | |
assert_equal '/something', @routes.path_for({controller: 'something', action: :index}) | |
get '/something' | |
assert_equal 'ok', response.body | |
get '/something/index' | |
assert_equal 'ok', response.body | |
end | |
end | |
def test_nested_controller | |
with_routing do |set| | |
set.draw do | |
get ':controller(/:action)' # test wont pass for '/something_test/some/index' unless this has been added | |
get ':controller(/:action(/:id))' | |
end | |
assert_equal '/something_test/some', @routes.path_for({controller: 'something_test/some', action: :index}) | |
get '/something_test/some/index', nil, { 'action_dispatch.show_exceptions' => false } | |
assert_equal 'ok', response.body | |
# This will fail unless the index action is specified in the url. | |
get '/something_test/some', nil, { 'action_dispatch.show_exceptions' => false } | |
assert_equal 'ok', response.body | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment