aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
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/cobrand
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/cobrand')
-rw-r--r--t/cobrand/bromley.t20
-rw-r--r--t/cobrand/zurich.t9
2 files changed, 26 insertions, 3 deletions
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 6437ba3bd..fdded5606 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -8,6 +8,11 @@ my $mech = FixMyStreet::TestMech->new;
# Create test data
my $user = $mech->create_user_ok( 'bromley@example.com' );
my $body = $mech->create_body_ok( 2482, 'Bromley', id => 2482 );
+$mech->create_contact_ok(
+ body_id => $body->id,
+ category => 'Other',
+ email => 'LIGHT',
+);
my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
cobrand => 'bromley',
@@ -36,6 +41,21 @@ $mech->content_contains( 'marked as in progress' );
$mech->content_contains( 'marks it as unable to fix' );
$mech->content_contains( 'marked as no further action' );
+subtest 'testing special Open311 behaviour', sub {
+ $report->set_extra_fields();
+ $report->update;
+ $body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test' } );
+ FixMyStreet::override_config {
+ SEND_REPORTS_ON_STAGING => 1,
+ }, sub {
+ FixMyStreet::App->model('DB::Problem')->send_reports();
+ };
+ $report->discard_changes;
+ ok $report->whensent, 'Report marked as sent';
+ is $report->send_method_used, 'Open311', 'Report sent via Open311';
+ is $report->external_id, 248, 'Report has right external ID';
+};
+
# Clean up
$mech->delete_user($user);
$mech->delete_problems_for_body( $body->id );
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 203bbc0f8..31aceab28 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -17,13 +17,16 @@ use JSON;
# commonlib/bin/gettext-makemo FixMyStreet
use FixMyStreet;
+my $c = FixMyStreet::App->new();
+my $cobrand = FixMyStreet::Cobrand::Zurich->new({ c => $c });
+$c->stash->{cobrand} = $cobrand;
# This is a helper method that will send the reports but with the config
# correctly set - notably SEND_REPORTS_ON_STAGING needs to be true.
sub send_reports_for_zurich {
FixMyStreet::override_config { SEND_REPORTS_ON_STAGING => 1 }, sub {
# Actually send the report
- FixMyStreet::App->model('DB::Problem')->send_reports('zurich');
+ $c->model('DB::Problem')->send_reports('zurich');
};
}
sub reset_report_state {
@@ -285,9 +288,9 @@ subtest "report_edit" => sub {
is ( $report->extra->{closed_overdue}, 0, 'Marking hidden from scratch also set closed_overdue' );
is get_moderated_count(), 1;
- is (FixMyStreet::Cobrand::Zurich->new->get_or_check_overdue($report), 0, 'sanity check');
+ is ($cobrand->get_or_check_overdue($report), 0, 'sanity check');
$report->update({ created => $created->clone->subtract(days => 10) });
- is (FixMyStreet::Cobrand::Zurich->new->get_or_check_overdue($report), 0, 'overdue call not increased');
+ is ($cobrand->get_or_check_overdue($report), 0, 'overdue call not increased');
reset_report_state($report, $created);
};