aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/report_new.t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-10-12 12:23:01 +0100
committerStruan Donald <struan@exo.org.uk>2012-10-12 12:23:01 +0100
commit2951ecb56dcdd7609a45248870b62bbc8edecc45 (patch)
tree395a86c8f858c1dce5f7ce17602e7a64e7e10cbf /t/app/controller/report_new.t
parent0a0bd26d4a4c6996bae3e647e0443e2b93c1ceb7 (diff)
If there is no user title submitted with a problem then do not set the DB field
Diffstat (limited to 't/app/controller/report_new.t')
-rw-r--r--t/app/controller/report_new.t47
1 files changed, 47 insertions, 0 deletions
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 2e7e60f75..77afb071c 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -1028,6 +1028,53 @@ for my $test (
};
}
+subtest 'user title not reset if no user title in submission' => sub {
+ $mech->log_out_ok;
+ $mech->host( 'http://fixmystreet.com' );
+
+ my $user = $mech->log_in_ok( 'userwithtitle@example.com' );
+
+ ok $user->update(
+ {
+ name => 'Has Title',
+ phone => '0789 654321',
+ title => 'MR',
+ }
+ ),
+ "set users details";
+
+
+ my $submission_fields = {
+ title => "Test Report",
+ detail => 'Test report details.',
+ photo => '',
+ name => 'Has Title',
+ may_show_name => '1',
+ phone => '07903 123 456',
+ category => 'Trees',
+ };
+
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => 'EH99 1SP', } },
+ "submit location" );
+ $mech->follow_link_ok(
+ { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link"
+ );
+
+ my $fields = $mech->visible_form_values('mapSkippedForm');
+ ok !exists( $fields->{fms_extra_title} ), 'user title field not displayed';
+
+ $mech->submit_form_ok( { with_fields => $submission_fields },
+ "submit good details" );
+
+ $user->discard_changes;
+ my $report = $user->problems->first;
+ ok $report, "Found report";
+ is $report->title, "Test Report", "Report title correct";
+ is $user->title, 'MR', 'User title unchanged';
+};
+
SKIP: {
skip( "Need 'lichfielddc' in ALLOWED_COBRANDS config", 100 )
unless FixMyStreet::Cobrand->exists('lichfielddc');