| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use lib 'lib'; |
|---|
| 6 | |
|---|
| 7 | use Test::More tests => 10; |
|---|
| 8 | |
|---|
| 9 | BEGIN { $ENV{CATALYST_DEBUG} = 0; } |
|---|
| 10 | BEGIN { use_ok 'Catalyst::Test', 'Vee' } |
|---|
| 11 | BEGIN { use_ok 'Vee::Controller::Dex::Compat' } |
|---|
| 12 | |
|---|
| 13 | my $req; |
|---|
| 14 | |
|---|
| 15 | # Test correct redirection of old numbered URLs |
|---|
| 16 | |
|---|
| 17 | $req = request('/dex/pokemon/133'); |
|---|
| 18 | ok $req->is_redirect, "Numeric Pokemon URL results in a redirect"; |
|---|
| 19 | like $req->header('location'), qr# /dex/pokemon/eevee $ #x, |
|---|
| 20 | "...and redirects correctly"; |
|---|
| 21 | |
|---|
| 22 | $req = request('/dex/move/314'); |
|---|
| 23 | ok $req->is_redirect, "Numeric move URL results in a redirect"; |
|---|
| 24 | like $req->header('location'), qr# /dex/moves/air%20cutter $ #x, |
|---|
| 25 | "...and redirects correctly"; |
|---|
| 26 | |
|---|
| 27 | $req = request('/dex/type/5'); |
|---|
| 28 | ok $req->is_redirect, "Numeric type URL results in a redirect"; |
|---|
| 29 | like $req->header('location'), qr# /dex/types/ground $ #x, |
|---|
| 30 | "...and redirects correctly"; |
|---|
| 31 | |
|---|
| 32 | # Make sure invalid ones bomb cleanly |
|---|
| 33 | |
|---|
| 34 | $req = request('/dex/type/12'); |
|---|
| 35 | ok $req->is_success, "Invalid numeric type URL succeeds"; |
|---|
| 36 | like $req->content, qr/<div id="error">/, |
|---|
| 37 | "...and provides an error message"; |
|---|