aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/resources_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-02-25 20:13:19 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-02-25 20:13:19 +0000
commit784298008bf25c901564929d319eb631eb1a5639 (patch)
tree82020764784e62012d54d7da4bbc2b04f1858524 /actionpack/test/controller/resources_test.rb
parentb203b9b55b0dc35da057cbb9b23277f60bd5260b (diff)
downloadrails-784298008bf25c901564929d319eb631eb1a5639.tar.gz
rails-784298008bf25c901564929d319eb631eb1a5639.tar.bz2
rails-784298008bf25c901564929d319eb631eb1a5639.zip
Allow routing requirements on map.resource(s) (closes #7633) [quixoten]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6232 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/resources_test.rb')
-rw-r--r--actionpack/test/controller/resources_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index e5605dff62..2b65ae21c2 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -57,6 +57,31 @@ class ResourcesTest < Test::Unit::TestCase
end
end
+ def test_irregular_id_with_no_requirements_should_raise_error
+ expected_options = {:controller => 'messages', :action => 'show', :id => '1.1.1'}
+
+ with_restful_routing :messages do
+ assert_raises(ActionController::RoutingError) do
+ assert_recognizes(expected_options, :path => 'messages/1.1.1', :method => :get)
+ end
+ end
+ end
+
+ def test_irregular_id_with_requirements_should_pass
+ expected_options = {:controller => 'messages', :action => 'show', :id => '1.1.1'}
+
+ with_restful_routing(:messages, :requirements => {:id => /[0-9]\.[0-9]\.[0-9]/}) do
+ assert_recognizes(expected_options, :path => 'messages/1.1.1', :method => :get)
+ end
+ end
+
+ def test_with_path_prefix_requirements
+ expected_options = {:controller => 'messages', :action => 'show', :thread_id => '1.1.1', :id => '1'}
+ with_restful_routing :messages, :path_prefix => '/thread/:thread_id', :requirements => {:thread_id => /[0-9]\.[0-9]\.[0-9]/} do
+ assert_recognizes(expected_options, :path => 'thread/1.1.1/messages/1', :method => :get)
+ end
+ end
+
def test_with_path_prefix
with_restful_routing :messages, :path_prefix => '/thread/:thread_id' do
assert_simply_restful_for :messages, :path_prefix => 'thread/5/', :options => { :thread_id => '5' }