aboutsummaryrefslogtreecommitdiffstats
path: root/t/open311.t
diff options
context:
space:
mode:
Diffstat (limited to 't/open311.t')
-rw-r--r--t/open311.t63
1 files changed, 37 insertions, 26 deletions
diff --git a/t/open311.t b/t/open311.t
index ef52eb538..3bb85f595 100644
--- a/t/open311.t
+++ b/t/open311.t
@@ -70,6 +70,8 @@ my $problem = FixMyStreet::DB->resultset('Problem')->new( {
cobrand => 'fixmystreet',
} );
+my $bromley = FixMyStreet::DB->resultset('Body')->new({ name => 'Bromley' });
+
subtest 'posting service request' => sub {
my $extra = {
url => 'http://example.com/report/1',
@@ -261,19 +263,23 @@ for my $test (
};
}
-
-my $comment = FixMyStreet::DB->resultset('Comment')->new( {
- id => 38362,
- user => $user,
- problem => $problem,
- anonymous => 0,
- text => 'this is a comment',
- confirmed => $dt,
- problem_state => 'confirmed',
- extra => { title => 'Mr', email_alerts_requested => 0 },
-} );
+sub make_comment {
+ my $cobrand = shift;
+ FixMyStreet::DB->resultset('Comment')->new( {
+ id => 38362,
+ user => $user,
+ problem => $problem,
+ anonymous => 0,
+ text => 'this is a comment',
+ confirmed => $dt,
+ problem_state => 'confirmed',
+ cobrand => $cobrand || 'default',
+ extra => { title => 'Mr', email_alerts_requested => 0 },
+ } );
+}
subtest 'basic request update post parameters' => sub {
+ my $comment = make_comment();
my $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>' );
is $results->{ res }, 248, 'got update id';
@@ -292,7 +298,13 @@ subtest 'basic request update post parameters' => sub {
};
subtest 'extended request update post parameters' => sub {
- my $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>', { use_extended_updates => 1 } );
+ my $comment = make_comment('bromley');
+ my $results;
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'bromley',
+ }, sub {
+ $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>' );
+ };
is $results->{ res }, 248, 'got update id';
@@ -318,8 +330,8 @@ subtest 'check media url set' => sub {
my $image_path = path('t/app/controller/sample.jpg');
$image_path->copy( path( $UPLOAD_DIR, '0123456789012345678901234567890123456789.jpeg' ) );
+ my $comment = make_comment('fixmystreet');
$comment->photo("0123456789012345678901234567890123456789");
- $comment->cobrand('fixmystreet');
FixMyStreet::override_config {
PHOTO_STORAGE_BACKEND => 'FileSystem',
@@ -335,7 +347,6 @@ subtest 'check media url set' => sub {
my $expected_path = '/c/' . $comment->id . '.0.full.jpeg';
like $c->param('media_url'), qr/$expected_path/, 'image url included';
};
- $comment->photo(undef);
};
foreach my $test (
@@ -432,6 +443,7 @@ foreach my $test (
},
) {
subtest $test->{desc} => sub {
+ my $comment = make_comment();
$comment->problem_state( $test->{state} );
$comment->problem->state( $test->{state} );
$comment->mark_open(1) if $test->{mark_open};
@@ -466,11 +478,17 @@ for my $test (
},
) {
subtest $test->{desc} => sub {
+ my $comment = make_comment('bromley');
$comment->problem_state( $test->{state} );
$comment->problem->state( $test->{state} );
$comment->anonymous( $test->{anon} );
- my $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>', { use_extended_updates => 1 } );
+ my $results;
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'bromley',
+ }, sub {
+ $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>' );
+ };
my $c = CGI::Simple->new( $results->{ req }->content );
is $c->param('public_anonymity_required'), $test->{anon} ? 'TRUE' : 'FALSE', 'correct anonymity';
@@ -480,17 +498,6 @@ for my $test (
my $dt2 = $dt->clone;
$dt2->add( 'minutes' => 1 );
-my $comment2 = FixMyStreet::DB->resultset('Comment')->new( {
- id => 38363,
- user => $user,
- problem => $problem,
- anonymous => 0,
- text => 'this is a comment',
- confirmed => $dt,
- problem_state => 'confirmed',
- extra => { title => 'Mr', email_alerts_requested => 0 },
-} );
-
for my $test (
{
desc => 'comment with fixed - council state sends status of CLOSED even if problem is open',
@@ -515,6 +522,7 @@ for my $test (
},
) {
subtest $test->{desc} => sub {
+ my $comment = make_comment();
$comment->problem_state( $test->{state} );
$comment->problem->state( $test->{problem_state} );
my $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>' );
@@ -559,6 +567,7 @@ for my $test (
)
{
subtest $test->{desc} => sub {
+ my $comment = make_comment();
$comment->name( $test->{comment_name} );
$user->name( $test->{user_name} );
$comment->extra( $test->{ extra } );
@@ -647,6 +656,7 @@ for my $test (
}
$problem->send_fail_count(1);
+my $comment = make_comment();
$comment->send_fail_count(1);
subtest 'No request id in reponse' => sub {
@@ -812,6 +822,7 @@ sub _make_req {
$open311_conf{'test_mode'} = 1;
$open311_conf{'end_point'} = 'http://localhost/o311';
+ $open311_conf{fixmystreet_body} = $bromley;
my $o =
Open311->new( %open311_conf );