aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-01-29 08:28:36 +0000
committerDave Arter <davea@mysociety.org>2018-02-07 17:22:10 +0000
commit01311af63412f39b75ff3b12bb6dc4051eab13b3 (patch)
treef612e211382ed2523e5fe65716722fa30ea9a7b7 /t/app
parentd1f04a07b1eb2f24a065a26320350977a10b400f (diff)
Allow ‘report as another user’ to only provide a phone number
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/report_as_other.t67
1 files changed, 65 insertions, 2 deletions
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index 91644e8ce..22bd5185e 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -39,7 +39,7 @@ subtest "Body user, has permission to add report as council" => sub {
};
my @users;
-subtest "Body user, has permission to add report as another user" => sub {
+subtest "Body user, has permission to add report as another user with email" => sub {
my $report = add_report(
'contribute_as_another_user',
form_as => 'another_user',
@@ -57,7 +57,49 @@ subtest "Body user, has permission to add report as another user" => sub {
push @users, $report->user;
};
-subtest "Body user, has permission to add report as another (existing) user" => sub {
+subtest "Body user, has permission to add report as another user with mobile phone number" => sub {
+ my $report = add_report(
+ 'contribute_as_another_user',
+ form_as => 'another_user',
+ title => "Test Report",
+ detail => 'Test report details.',
+ category => 'Potholes',
+ name => 'Another User',
+ username => '07906 111111',
+ );
+ is $report->name, 'Another User', 'report name is given name';
+ is $report->user->name, 'Another User', 'user name matches';
+ is $report->user->phone, '+447906111111', 'user phone correct';
+ is $report->user->phone_verified, 1, 'user phone verified';
+ is $report->user->email, undef, 'user email correct';
+ is $report->user->email_verified, 0, 'user email not verified';
+ isnt $report->user->id, $user->id, 'user does not match';
+ $mech->email_count_is(0);
+ push @users, $report->user;
+};
+
+subtest "Body user, has permission to add report as another user with landline number" => sub {
+ my $report = add_report(
+ 'contribute_as_another_user',
+ form_as => 'another_user',
+ title => "Test Report",
+ detail => 'Test report details.',
+ category => 'Potholes',
+ name => 'Another User',
+ username => '01685 222222',
+ );
+ is $report->name, 'Another User', 'report name is given name';
+ is $report->user->name, 'Another User', 'user name matches';
+ is $report->user->phone, '+441685222222', 'user phone correct';
+ is $report->user->phone_verified, 1, 'user phone verified';
+ is $report->user->email, undef, 'user email correct';
+ is $report->user->email_verified, 0, 'user email not verified';
+ isnt $report->user->id, $user->id, 'user does not match';
+ $mech->email_count_is(0);
+ push @users, $report->user;
+};
+
+subtest "Body user, has permission to add report as another (existing) user with email" => sub {
$mech->create_user_ok('existing@example.net', name => 'Existing User');
my $report = add_report(
'contribute_as_another_user',
@@ -76,6 +118,25 @@ subtest "Body user, has permission to add report as another (existing) user" =>
push @users, $report->user;
};
+subtest "Body user, has permission to add report as another (existing) user with phone" => sub {
+ $mech->create_user_ok('+447906333333', name => 'Existing User');
+ my $report = add_report(
+ 'contribute_as_another_user',
+ form_as => 'another_user',
+ title => "Test Report",
+ detail => 'Test report details.',
+ category => 'Potholes',
+ name => 'Existing Yooser',
+ username => '07906 333333',
+ );
+ is $report->name, 'Existing Yooser', 'report name is given name';
+ is $report->user->name, 'Existing User', 'user name remains same';
+ is $report->user->phone, '+447906333333', 'user phone correct';
+ isnt $report->user->id, $user->id, 'user does not match';
+ $mech->email_count_is(0);
+ push @users, $report->user;
+};
+
subtest "Body user, has permission to add report as anonymous user" => sub {
my $report = add_report(
'contribute_as_anonymous_user',
@@ -155,6 +216,7 @@ sub start_report {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixmystreet' ],
MAPIT_URL => 'http://mapit.uk/',
+ PHONE_COUNTRY => 'GB',
}, sub {
$mech->get_ok('/report/new?latitude=51.7549262252&longitude=-1.25617899435');
};
@@ -166,6 +228,7 @@ sub add_report {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fixmystreet' ],
MAPIT_URL => 'http://mapit.uk/',
+ PHONE_COUNTRY => 'GB',
}, sub {
dropdown_shown(1);
$mech->submit_form_ok({