diff options
author | Struan Donald <struan@exo.org.uk> | 2012-03-27 16:49:37 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-03-27 16:49:37 +0100 |
commit | 116bc9780071acbda22c0e8a6a6e6d8706bcd24e (patch) | |
tree | 7346afca2471c51edbcbd4151c57986d7191f446 /t | |
parent | c93cb823dafba47191f14fd7b31cf7b9d0cf37e0 (diff) |
sort out putting names in comments
Diffstat (limited to 't')
-rw-r--r-- | t/open311.t | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/open311.t b/t/open311.t index 2a9d513eb..2a5e5d11c 100644 --- a/t/open311.t +++ b/t/open311.t @@ -45,6 +45,7 @@ warning_like {$o2->send_service_request( $p, { url => 'http://example.com/' }, 1 my $dt = DateTime->now(); my $user = FixMyStreet::App->model('DB::User')->new( { + name => 'Test User', email => 'test@example.com', } ); @@ -61,6 +62,7 @@ my $comment = FixMyStreet::App->model('DB::Comment')->new( { anonymous => 0, text => 'this is a comment', confirmed => $dt, + extra => { title => 'Mr', email_alerts_requested => 0 }, } ); subtest 'testing posting updates' => sub { @@ -79,6 +81,10 @@ subtest 'testing posting updates' => sub { is $c->param('service_request_id'), 81, 'request id correct'; is $c->param('public_anonymity_required'), 'FALSE', 'anon status correct'; is $c->param('updated_datetime'), $dt, 'correct date'; + is $c->param('title'), 'Mr', 'correct title'; + 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'; }; foreach my $test ( @@ -143,6 +149,24 @@ foreach my $test ( }; } + +subtest 'check correct name used' => sub { + $comment->name( 'First Last' ); + $user->name( 'Personal Family'); + + 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>' ); + + my $c = CGI::Simple->new( $results->{ req }->content ); + is $c->param('first_name'), 'First', 'Name from comment'; + + $comment->name( '' ); + + $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>' ); + + $c = CGI::Simple->new( $results->{ req }->content ); + is $c->param('first_name'), 'Personal', 'Name from user'; +}; + subtest 'No update id in reponse' => sub { my $results; warning_like { |