aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/uri_for.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/uri_for.t')
-rw-r--r--t/app/uri_for.t75
1 files changed, 17 insertions, 58 deletions
diff --git a/t/app/uri_for.t b/t/app/uri_for.t
index eecf30e32..810aade62 100644
--- a/t/app/uri_for.t
+++ b/t/app/uri_for.t
@@ -4,7 +4,7 @@ use warnings;
use Test::More;
# FIXME Should this be here? A better way? uri_for varies by map.
-use Test::WWW::Mechanize::Catalyst 'FixMyStreet::App';
+use Catalyst::Test 'FixMyStreet::App';
FixMyStreet::Map::set_map_class();
# structure of these tests borrowed from '/t/aggregate/unit_core_uri_for.t'
@@ -15,43 +15,9 @@ use URI;
use_ok('FixMyStreet::App');
-my $fms_c = FixMyStreet::App->new(
- {
- request => Catalyst::Request->new(
- {
- base => URI->new('http://www.fixmystreet.com/'),
- uri => URI->new('http://www.fixmystreet.com/test_namespace')
- }
- ),
- namespace => 'test_namespace',
- }
-);
-
-my $fgm_c = FixMyStreet::App->new(
- {
- request => Catalyst::Request->new(
- {
- base => URI->new('http://www.fiksgatami.no/'),
- uri => URI->new('http://www.fiksgatami.no/test_namespace')
- }
- ),
- namespace => 'test_namespace',
- }
-);
-
-my $reh_en_c = FixMyStreet::App->new(
- {
- request => Catalyst::Request->new(
- {
- base => URI->new('http://reportemptyhomes.com/'),
- uri => URI->new('http://reportemptyhomes.com/test_namespace')
- }
- ),
- namespace => 'test_namespace',
- }
-);
-$reh_en_c->setup_request();
-
+my $fms_c = ctx_request('http://www.fixmystreet.com/');
+my $fgm_c = ctx_request('http://www.fiksgatami.no/');
+my $reh_en_c = ctx_request('http://reportemptyhomes.com/');
is(
$fms_c->uri_for('/bar/baz') . "",
@@ -61,7 +27,7 @@ is(
is(
$fms_c->uri_for('') . "",
- 'http://www.fixmystreet.com/test_namespace',
+ 'http://www.fixmystreet.com/',
'URI for namespace'
);
@@ -78,36 +44,29 @@ is(
'FiksGataMi url with lat not zoom'
);
-SKIP: {
- skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 2 )
- unless FixMyStreet::Cobrand->exists('emptyhomes');
-
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'emptyhomes' ],
+}, sub {
like(
$reh_en_c->uri_for_email( '/foo' ),
qr{^http://en.},
'adds en to retain language'
);
+};
- # instantiate this here otherwise sets locale to cy and breaks test
- # above
- my $reh_cy_c = FixMyStreet::App->new(
- {
- request => Catalyst::Request->new(
- {
- base => URI->new('http://cy.reportemptyhomes.com/'),
- uri => URI->new('http://cy.reportemptyhomes.com/test_namespace')
- }
- ),
- namespace => 'test_namespace',
- }
- );
- $reh_cy_c->setup_request();
+# instantiate this here otherwise sets locale to cy and breaks test
+# above
+my $reh_cy_c;
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'emptyhomes' ],
+}, sub {
+ $reh_cy_c = ctx_request('http://cy.reportemptyhomes.com/');
like(
$reh_cy_c->uri_for_email( '/foo' ),
qr{^http://cy.},
'retains language'
);
-}
+};
done_testing();