diff options
author | Struan Donald <struan@exo.org.uk> | 2012-05-24 15:09:06 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-05-24 15:09:06 +0100 |
commit | 65820a534a42852d0d9a1819649f48a54b37c22f (patch) | |
tree | 73fb2c02bdaf20d5e9053e7f6ab2f784fa4e3de8 | |
parent | 47979155279b45b9bb4b12b57cde49c6bf00681f (diff) |
send media_url if comment has a photo
-rw-r--r-- | perllib/Open311.pm | 7 | ||||
-rw-r--r-- | t/open311.t | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/perllib/Open311.pm b/perllib/Open311.pm index 0d3c0720d..2df6ac5dd 100644 --- a/perllib/Open311.pm +++ b/perllib/Open311.pm @@ -278,6 +278,13 @@ sub _populate_service_request_update_params { first_name => $firstname, }; + if ( $comment->photo ) { + my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($comment->cobrand)->new(); + my $email_base_url = $cobrand->base_url_for_emails($comment->cobrand_data); + my $url = $email_base_url . '/photos/c/' . $comment->id . '.full.jpeg'; + $params->{media_url} = $url; + } + if ( $comment->extra ) { $params->{'email_alerts_requested'} = $comment->extra->{email_alerts_requested} ? 'TRUE' : 'FALSE'; diff --git a/t/open311.t b/t/open311.t index 60757219e..814b11f82 100644 --- a/t/open311.t +++ b/t/open311.t @@ -214,6 +214,22 @@ subtest 'basic request update post parameters' => sub { is $c->param('last_name'), 'User', 'correct first name'; is $c->param('first_name'), 'Test', 'correct second name'; is $c->param('email_alerts_requested'), 'FALSE', 'email alerts flag correct'; + is $c->param('media_url'), undef, 'no media url'; +}; + +subtest 'check media url set' => sub { + $comment->photo(1); + $comment->cobrand('fixmystreet'); + + 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'; + + my $req = $o->test_req_used; + + my $c = CGI::Simple->new( $results->{ req }->content ); + my $expected_path = '/c/' . $comment->id . '.full.jpeg'; + like $c->param('media_url'), qr/$expected_path/, 'image url included'; }; foreach my $test ( |