diff options
Diffstat (limited to 't/app/controller')
-rw-r--r-- | t/app/controller/admin.t | 3 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 131 |
2 files changed, 101 insertions, 33 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 07d72de96..42fd076c7 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -8,8 +8,9 @@ my $mech = FixMyStreet::TestMech->new; my $user = FixMyStreet::App->model('DB::User') - ->find_or_create( { email => 'test@example.com', name => 'Test User' } ); + ->find_or_create( { email => 'test@example.com' } ); ok $user, "created test user"; +$user->update({ name => 'Test User' }); my $user2 = FixMyStreet::App->model('DB::User') diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 6c6b4ca19..f9f5189e5 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -199,7 +199,9 @@ for my $test ( rznvy => '', update => '', name => '', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', fixed => undef, add_alert => 1, may_show_name => undef, @@ -216,7 +218,9 @@ for my $test ( rznvy => 'test', update => '', name => '', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', fixed => undef, add_alert => 1, may_show_name => undef, @@ -233,7 +237,9 @@ for my $test ( rznvy => 'test @ example. com', update => '', name => '', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', fixed => undef, add_alert => 1, may_show_name => undef, @@ -252,7 +258,9 @@ for my $test ( rznvy => 'test@EXAMPLE.COM', update => '', name => '', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', fixed => undef, add_alert => 1, may_show_name => undef, @@ -292,7 +300,9 @@ for my $test ( rznvy => '', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, remember_me => undef, @@ -316,7 +326,9 @@ for my $test ( rznvy => '', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, remember_me => undef, @@ -417,7 +429,9 @@ for my $test ( rznvy => '', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, remember_me => undef, @@ -502,7 +516,9 @@ subtest 'check non authority user cannot change set state' => sub { name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'this is a forbidden update', state => 'fixed - council', }, @@ -530,7 +546,9 @@ for my $state ( qw/unconfirmed hidden partial/ ) { name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'this is a forbidden update', state => $state, }, @@ -553,7 +571,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to investigating', state => 'investigating', }, @@ -565,7 +585,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to in progress', state => 'in progress', }, @@ -577,7 +599,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to fixed', state => 'fixed', }, @@ -589,7 +613,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to action scheduled', state => 'action scheduled', }, @@ -601,7 +627,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to unable to fix', state => 'unable to fix', }, @@ -613,7 +641,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to internal referral', state => 'internal referral', }, @@ -626,7 +656,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to not responsible', state => 'not responsible', }, @@ -639,7 +671,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to duplicate', state => 'duplicate', }, @@ -652,7 +686,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to internal referral', state => 'internal referral', }, @@ -665,7 +701,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to fixed', state => 'fixed', }, @@ -783,7 +821,9 @@ subtest "check comment with no status change has not status in meta" => sub { name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Comment that does not change state', }, }, @@ -813,7 +853,9 @@ subtest "check comment with no status change has not status in meta" => sub { name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Comment that sets state to investigating', state => 'investigating', }, @@ -1049,6 +1091,9 @@ subtest 'submit an update for a registered user, creating update by email' => su $mech->delete_user( $user ); }; +my $sample_file = file(__FILE__)->parent->file("sample.jpg")->stringify; +ok -e $sample_file, "sample file $sample_file exists"; + for my $test ( { desc => 'submit update for registered user', @@ -1056,7 +1101,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1066,6 +1113,7 @@ for my $test ( update => 'update from a registered user', add_alert => undef, fixed => undef, + photo1 => [ [ $sample_file, undef, Content_Type => 'image/jpeg' ], 1 ], }, changed => { update => 'Update from a registered user' @@ -1081,7 +1129,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1107,7 +1157,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1132,7 +1184,9 @@ for my $test ( name => 'Commenter', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1157,7 +1211,9 @@ for my $test ( name => 'Commenter', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', }, email => 'commenter@example.com', @@ -1210,6 +1266,11 @@ for my $test ( $mech->content_contains("/report/" . $report_id); $mech->get_ok("/report/" . $report_id); + my $update = $report->comments->first; + ok $update, 'found update'; + + $mech->content_contains("/photo/c/" . $update->id . ".0.jpeg") if $test->{fields}->{photo1}; + if ( !defined( $test->{endstate_banner} ) ) { is $mech->extract_problem_banner->{text}, undef, 'endstate banner'; } else { @@ -1223,8 +1284,6 @@ for my $test ( %{ $test->{changed} }, }; - my $update = $report->comments->first; - ok $update, 'found update'; is $update->text, $results->{update}, 'update text'; is $update->user->email, $test->{email}, 'update user'; is $update->state, 'confirmed', 'update confirmed'; @@ -1245,7 +1304,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1271,7 +1332,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1298,7 +1361,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1771,7 +1836,9 @@ for my $test ( my %standard_fields = ( name => $report->user->name, update => 'update text', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', may_show_name => 1, add_alert => 1, ); |