diff options
author | Matthew Somerville <matthew@mysociety.org> | 2014-07-10 15:28:54 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-07-10 17:23:09 +0100 |
commit | 5aab29046bbc602bb63a647f61f5b9fd4fe137cd (patch) | |
tree | e1b54449b7a94ef777702e4d0b800a88cf308e00 /perllib | |
parent | 49cb1e91e0cf01e27843f4c8e22731b7d28c049e (diff) |
Add fixmystreet.com reporting form A/B tests.
Testing two things:
* Putting the email box above the Yes/No, or repeating it inside.
* Showing the contents of the Yes/No sections at first, or not.
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 1e9f83aec..c885e1a8a 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -719,7 +719,8 @@ sub process_user : Private { # Extract all the params to a hash to make them easier to work with my %params = map { $_ => scalar $c->req->param($_) } - ( 'email', 'name', 'phone', 'password_register', 'fms_extra_title' ); + ( 'email', 'name', 'phone', 'password_register', 'fms_extra_title', + 'email_y', 'email_n' ); my $user_title = Utils::trim_text( $params{fms_extra_title} ); @@ -744,6 +745,9 @@ sub process_user : Private { # cleanup the email address my $email = $params{email} ? lc $params{email} : ''; + my $email_y = $params{email_y} ? lc $params{email_y} : ''; + my $email_n = $params{email_n} ? lc $params{email_n} : ''; + $email = $email || $email_y || $email_n; $email =~ s{\s+}{}g; $report->user( $c->model('DB::User')->find_or_new( { email => $email } ) ) diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index be8f004a5..5b3cc39a7 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -238,7 +238,10 @@ sub page_errors { process 'div.form-error, p.form-error, p.error, ul.error li', 'errors[]', 'TEXT'; } ->scrape( $mech->response ); - return $result->{errors} || []; + my $err = $result->{errors} || []; + my %seen = (); + $err = [ grep { not $seen{$_}++ } @$err ]; + return $err; } =head2 import_errors @@ -479,6 +482,10 @@ sub visible_form_values { my %params = map { $_ => $form->value($_) } @visible_field_names; + # Ignore content experiment fields + delete $params{email_y}; + delete $params{email_n}; + return \%params; } |