From: André Walker Date: Tue, 20 Jan 2015 16:20:05 +0000 (-0200) Subject: Add test case for OPTIONS X-Git-Tag: 5.90083~6^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=0c246eea6a68c8c34b267148b6de4435eda36b0f;hp=e2a8c7e5e1e3bd9a510ec5758a505585de2f3172 Add test case for OPTIONS The attribute OPTION should not have any effect on method matching. The attribute OPTIONS should work as expected. --- diff --git a/t/aggregate/live_component_controller_httpmethods.t b/t/aggregate/live_component_controller_httpmethods.t index 6507af1..9cc6e9f 100644 --- a/t/aggregate/live_component_controller_httpmethods.t +++ b/t/aggregate/live_component_controller_httpmethods.t @@ -1,13 +1,17 @@ use strict; use warnings; use Test::More; -use HTTP::Request::Common qw/GET POST DELETE PUT /; +use HTTP::Request::Common qw/GET POST DELETE PUT/; use FindBin; use lib "$FindBin::Bin/../lib"; use Catalyst::Test 'TestApp'; - + +sub OPTIONS { + HTTP::Request->new('OPTIONS', @_); +} + is(request(GET '/httpmethods/foo')->content, 'get'); is(request(POST '/httpmethods/foo')->content, 'post'); is(request(DELETE '/httpmethods/foo')->content, 'default'); @@ -34,4 +38,12 @@ is(request(GET '/httpmethods/check_default')->content, 'get3'); is(request(POST '/httpmethods/check_default')->content, 'post3'); is(request(PUT '/httpmethods/check_default')->content, 'chain_default'); +is(request(GET '/httpmethods/opt_typo')->content, 'typo'); +is(request(POST '/httpmethods/opt_typo')->content, 'typo'); +is(request(PUT '/httpmethods/opt_typo')->content, 'typo'); + +is(request(OPTIONS '/httpmethods/opt')->content, 'options'); +is(request(GET '/httpmethods/opt')->content, 'default'); +is(request(POST '/httpmethods/opt')->content, 'default'); + done_testing; diff --git a/t/lib/TestApp/Controller/HTTPMethods.pm b/t/lib/TestApp/Controller/HTTPMethods.pm index e687372..2f7476d 100644 --- a/t/lib/TestApp/Controller/HTTPMethods.pm +++ b/t/lib/TestApp/Controller/HTTPMethods.pm @@ -30,6 +30,16 @@ sub any_method : Path('baz') { $ctx->response->body('any'); } +sub typo_option : Path('opt_typo') OPTION { + my ($self, $ctx) = @_; + $ctx->response->body('typo'); +} + +sub real_options : Path('opt') OPTIONS { + my ($self, $ctx) = @_; + $ctx->response->body('options'); +} + sub base :Chained('/') PathPrefix CaptureArgs(0) { } sub chained_get :Chained('base') Args(0) GET {