aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cypress/cypress/integration/isleofwight.js2
-rwxr-xr-xbin/fixmystreet.com/fixture13
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm17
-rw-r--r--t/app/controller/report_new_open311.t2
-rw-r--r--t/cobrand/isleofwight.t27
-rw-r--r--templates/web/base/report/new/category_extras.html2
6 files changed, 54 insertions, 9 deletions
diff --git a/.cypress/cypress/integration/isleofwight.js b/.cypress/cypress/integration/isleofwight.js
index ab1c17941..daa69f36a 100644
--- a/.cypress/cypress/integration/isleofwight.js
+++ b/.cypress/cypress/integration/isleofwight.js
@@ -17,6 +17,8 @@ describe('When you look at the Island Roads site', function() {
cy.contains('sent to Island Roads');
cy.get('select:eq(4)').select('Private');
cy.contains('sent to Island Roads');
+ cy.get('select:eq(4)').select('Extra');
+ cy.contains('Help Island Roads');
});
it('displays nearby roadworks', function() {
diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture
index 1340858a4..f1b2ff4c3 100755
--- a/bin/fixmystreet.com/fixture
+++ b/bin/fixmystreet.com/fixture
@@ -99,7 +99,7 @@ if ($opt->test_fixtures) {
{ area_id => 2257, categories => ['Flytipping', 'Graffiti'], name => 'Chiltern District Council' },
{ area_id => 2397, categories => [ 'Graffiti' ], name => 'Northampton Borough Council' },
{ area_id => 2483, categories => [ 'Potholes', 'Other' ], name => 'Hounslow Borough Council' },
- { area_id => 2636, categories => [ 'Potholes', 'Private' ], name => 'Isle of Wight Council' },
+ { area_id => 2636, categories => [ 'Potholes', 'Private', 'Extra' ], name => 'Isle of Wight Council' },
) {
$bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_);
my $cats = join(', ', @{$_->{categories}});
@@ -153,6 +153,17 @@ if ($opt->test_fixtures) {
$child_cat->update({
non_public => 1
});
+ $child_cat = FixMyStreet::DB->resultset("Contact")->find({
+ body => $bodies->{2636},
+ category => 'Extra',
+ });
+ $child_cat->set_extra_fields({
+ code => 'extra',
+ datatype => 'string',
+ order => 1,
+ variable => 'true',
+ });
+ $child_cat->update;
}
FixMyStreet::DB::Factory::ResponseTemplate->create({
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 554fbc3b7..2856d6660 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -261,15 +261,20 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
sub by_category_ajax_data : Private {
my ($self, $c, $type, $category) = @_;
- my $bodies = $c->forward('contacts_to_bodies', [ $category ]);
- my $list_of_names = [ map { $_->name } ($category ? @$bodies : values %{$c->stash->{bodies_to_list}}) ];
- my $vars = {
- $category ? (list_of_names => $list_of_names) : (),
- };
+ my @bodies;
+ my $bodies = [];
+ my $vars = {};
+ if ($category) {
+ $bodies = $c->forward('contacts_to_bodies', [ $category ]);
+ @bodies = @$bodies;
+ $vars->{list_of_names} = [ map { $_->cobrand_name } @bodies ];
+ } else {
+ @bodies = values %{$c->stash->{bodies_to_list}};
+ }
my $non_public = $c->stash->{non_public_categories}->{$category};
my $body = {
- bodies => $list_of_names,
+ bodies => [ map { $_->name } @bodies ],
$non_public ? ( non_public => JSON->true ) : (),
};
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index 52f1ddc6e..a0d122a7b 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -203,6 +203,8 @@ foreach my $test (
# check that we got the errors expected
is_deeply $mech->page_errors, $test->{errors}, "check errors";
+ $mech->content_contains('Help <strong>Borsetshire Council</strong> resolve your problem quicker');
+
# check that fields have changed as expected
my $new_values = {
%{ $test->{fields} }, # values added to form
diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t
index 745b378dc..8afc2f29b 100644
--- a/t/cobrand/isleofwight.t
+++ b/t/cobrand/isleofwight.t
@@ -16,7 +16,7 @@ my $params = {
jurisdiction => 'home',
};
my $isleofwight = $mech->create_body_ok(2636, 'Isle of Wight Council', $params);
-$mech->create_contact_ok(
+my $contact = $mech->create_contact_ok(
body_id => $isleofwight->id,
category => 'Potholes',
email => 'pothole@example.org',
@@ -240,4 +240,29 @@ subtest "sends branded report sent emails" => sub {
like $mech->get_text_body_from_email($email), qr/Island Roads/, "emails are branded";
};
+subtest "check category extra uses correct name" => sub {
+ my @extras = ( {
+ code => 'test',
+ datatype => 'string',
+ description => 'question',
+ variable => 'true',
+ required => 'false',
+ order => 1,
+ datatype_description => 'datatype',
+ } );
+ $contact->set_extra_fields( @extras );
+ $contact->update;
+
+ my $extra_details;
+
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ ALLOWED_COBRANDS => ['isleofwight','fixmystreet'],
+ }, sub {
+ $extra_details = $mech->get_ok_json('/report/new/category_extras?category=Potholes&latitude=50.71086&longitude=-1.29573');
+ };
+
+ like $extra_details->{category_extra}, qr/Island Roads/, 'correct name in category extras';
+};
+
done_testing();
diff --git a/templates/web/base/report/new/category_extras.html b/templates/web/base/report/new/category_extras.html
index c7bdad94d..8e5b02952 100644
--- a/templates/web/base/report/new/category_extras.html
+++ b/templates/web/base/report/new/category_extras.html
@@ -1,4 +1,4 @@
-[% SET default_list = [] %][% FOR b IN bodies_to_list.values %][% default_list.push(b.name) %][% END %]
+[% SET default_list = [] %][% FOR b IN bodies_to_list.values %][% default_list.push(b.cobrand_name) %][% END %]
[% DEFAULT list_of_names = default_list %]
<div id="category_meta">