aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/token.t
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2015-02-13 17:12:21 +0000
committerMatthew Somerville <matthew@mysociety.org>2015-03-20 20:30:40 +0000
commit6d9c719d25e2450ee2f31a5f305b603c2f451594 (patch)
treeafc3b450191ce752cbe3ee67450875dba73e052e /t/app/controller/token.t
parent10b3a899af00205e46e177509a0b4c13bf746299 (diff)
Add Extra role to ease use of {extra} field.
Historically, the extra field has been used in two different ways by different cobrands, both as a list (e.g. Open311 category fields) and a hash (e.g. the Zurich cobrand). This commit consolidates usage, adding an API to make use of the field easier and always returning a hash for the code to use. Fixes #1018.
Diffstat (limited to 't/app/controller/token.t')
-rw-r--r--t/app/controller/token.t37
1 files changed, 37 insertions, 0 deletions
diff --git a/t/app/controller/token.t b/t/app/controller/token.t
new file mode 100644
index 000000000..9ca8b905d
--- /dev/null
+++ b/t/app/controller/token.t
@@ -0,0 +1,37 @@
+use strict;
+use warnings;
+use Test::More;
+use utf8;
+
+use FixMyStreet::TestMech;
+use FixMyStreet::App;
+
+my $user = FixMyStreet::App->model('DB::User')->find_or_create({
+ name => 'Bob', email => 'bob@example.com',
+ });
+my $mech = FixMyStreet::TestMech->new;
+
+subtest 'Zurich special case for C::Tokens->problem_confirm' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => ['zurich'],
+ }, sub {
+ my $c = FixMyStreet::App->new;
+ my $zurich = $mech->create_body_ok( 1, 'Zurich' );
+ my ($report) = $mech->create_problems_for_body(
+ 1, $zurich->id,
+ {
+ state => 'unconfirmed',
+ confirmed => undef,
+ cobrand => 'zurich',
+ });
+
+ is $report->get_extra_metadata('email_confirmed'), undef, 'email_confirmed not yet set (sanity)';
+ my $token = $c->model('DB::Token')->create({ scope => 'problem', data => $report->id });
+
+ $mech->get_ok('/P/' . $token->token);
+ $report->discard_changes;
+ is $report->get_extra_metadata('email_confirmed'), 1, 'email_confirmed set by Zurich special case';
+ };
+};
+
+done_testing;