aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/rss.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller/rss.t')
-rw-r--r--t/app/controller/rss.t99
1 files changed, 90 insertions, 9 deletions
diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t
index 77e2c7ee1..bafa1ddc0 100644
--- a/t/app/controller/rss.t
+++ b/t/app/controller/rss.t
@@ -3,6 +3,7 @@ use warnings;
use Test::More;
use FixMyStreet::TestMech;
+use FixMyStreet::App;
my $mech = FixMyStreet::TestMech->new;
@@ -13,11 +14,13 @@ my $dt = DateTime->new(
);
my $user1 = FixMyStreet::App->model('DB::User')
- ->find_or_create( { email => 'reporter@example.com', name => 'Reporter User' } );
+ ->find_or_create( { email => 'reporter-rss@example.com', name => 'Reporter User' } );
+
+my $dt_parser = FixMyStreet::App->model('DB')->schema->storage->datetime_parser;
my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
postcode => 'eh1 1BB',
- council => '2651',
+ bodies_str => '2651',
areas => ',11808,135007,14419,134935,2651,20728,',
category => 'Street lighting',
title => 'Testing',
@@ -26,9 +29,9 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
name => $user1->name,
anonymous => 0,
state => 'confirmed',
- confirmed => $dt,
- lastupdate => $dt,
- whensent => $dt->clone->add( minutes => 5 ),
+ confirmed => $dt_parser->format_datetime($dt),
+ lastupdate => $dt_parser->format_datetime($dt),
+ whensent => $dt_parser->format_datetime($dt->clone->add( minutes => 5 )),
lang => 'en-gb',
service => '',
cobrand => 'default',
@@ -39,8 +42,13 @@ my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( {
user_id => $user1->id,
} );
-
-$mech->get_ok("/rss/pc/EH11BB/2");
+$mech->host('www.fixmystreet.com');
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $mech->get_ok("/rss/pc/EH11BB/2");
+};
$mech->content_contains( "Testing, 10th October" );
$mech->content_lacks( 'Nearest road to the pin' );
@@ -108,11 +116,84 @@ $report->geocode(
);
$report->update();
-$mech->get_ok("/rss/pc/EH11BB/2");
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+}, sub {
+ $mech->get_ok("/rss/pc/EH11BB/2");
+};
$mech->content_contains( "Testing, 10th October" );
$mech->content_contains( '18 North Bridge, Edinburgh' );
$report->delete();
-$user1->delete();
+
+my $now = DateTime->now();
+my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
+ {
+ postcode => 'WS13 6YY',
+ bodies_str => '2434',
+ areas => ',2434,2240,',
+ category => 'Other',
+ title => 'council report',
+ detail => 'Test 2 Detail',
+ used_map => 't',
+ name => 'Test User',
+ anonymous => 'f',
+ state => 'closed',
+ confirmed => $now->ymd . ' ' . $now->hms,
+ lang => 'en-gb',
+ service => '',
+ cobrand => 'default',
+ cobrand_data => '',
+ send_questionnaire => 't',
+ latitude => '52.727588',
+ longitude => '-1.731322',
+ user_id => $user1->id,
+ }
+);
+
+my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_create(
+ {
+ postcode => 'WS13 6YY',
+ bodies_str => '2240',
+ areas => ',2434,2240,',
+ category => 'Other',
+ title => 'county report',
+ detail => 'Test 2 Detail',
+ used_map => 't',
+ name => 'Test User',
+ anonymous => 'f',
+ state => 'closed',
+ confirmed => $now->ymd . ' ' . $now->hms,
+ lang => 'en-gb',
+ service => '',
+ cobrand => 'default',
+ cobrand_data => '',
+ send_questionnaire => 't',
+ latitude => '52.727588',
+ longitude => '-1.731322',
+ user_id => $user1->id,
+ }
+);
+
+subtest "check RSS feeds on cobrand have correct URLs for non-cobrand reports" => sub {
+ $mech->host('lichfielddc.fixmystreet.com');
+ my $expected1 = mySociety::Config::get('BASE_URL') . '/report/' . $report_to_county_council->id;
+ my $expected2;
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'lichfielddc' ],
+ MAPIT_URL => 'http://mapit.mysociety.org/',
+ }, sub {
+ $mech->get_ok("/rss/area/Lichfield");
+ my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('lichfielddc')->new();
+ $expected2 = $cobrand->base_url . '/report/' . $report_to_council->id;
+ };
+
+ $mech->content_contains($expected1, 'non cobrand area report point to fixmystreet.com');
+ $mech->content_contains($expected2, 'cobrand area report point to cobrand url');
+};
+
+$mech->delete_user( $user1 );
done_testing();