aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-07-16 10:30:56 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-07-16 13:51:31 +0100
commit1010d24d5d3c5085958e642f617ccb67286dc019 (patch)
tree60e45d74274dff27a62354bf430feff3166b9127
parentfcc46472c7abd45cdafd2c3bcb6bc673ebd300b5 (diff)
[BANES] Move staff map code later.
Due to refactoring in 12d2346, this was loading prior to the main asset code and thus not activating.
-rw-r--r--.cypress/cypress/integration/bathnes.js24
-rwxr-xr-xbin/browser-tests1
-rw-r--r--perllib/FixMyStreet/Cobrand/BathNES.pm12
-rw-r--r--templates/web/bathnes/footer_extra_js.html8
4 files changed, 33 insertions, 12 deletions
diff --git a/.cypress/cypress/integration/bathnes.js b/.cypress/cypress/integration/bathnes.js
index c675c34fa..1acbd3602 100644
--- a/.cypress/cypress/integration/bathnes.js
+++ b/.cypress/cypress/integration/bathnes.js
@@ -2,3 +2,27 @@ it('loads the right front page', function() {
cy.visit('http://bathnes.localhost:3001/');
cy.contains('North East Somerset');
});
+
+it('loads the staff layer correctly', function() {
+ cy.request({
+ method: 'POST',
+ url: 'http://bathnes.localhost:3001/auth?r=/',
+ form: true,
+ body: { username: 'admin@example.org', password_sign_in: 'password' }
+ });
+ cy.visit('http://bathnes.localhost:3001/');
+ cy.contains('Your account');
+ cy.get('[name=pc]').type(Cypress.env('postcode'));
+ cy.get('[name=pc]').parents('form').submit();
+ cy.url().should('include', '/around');
+ cy.window().its('fixmystreet.maps').should('have.property', 'banes_defaults');
+ cy.window().then(function(win){
+ var llpg = 0;
+ win.fixmystreet.map.layers.forEach(function(lyr) {
+ if (lyr.fixmystreet && lyr.fixmystreet.http_options.params.TYPENAME === 'LLPG') {
+ llpg++;
+ }
+ });
+ expect(llpg).to.equal(1);
+ });
+});
diff --git a/bin/browser-tests b/bin/browser-tests
index 6ce9159bf..11d83d133 100755
--- a/bin/browser-tests
+++ b/bin/browser-tests
@@ -88,6 +88,7 @@ sub run {
ALLOWED_COBRANDS => $cobrand,
MAPIT_URL => $mapit_url,
BASE_URL => 'http://fixmystreet.localhost:3001',
+ STAGING_FLAGS => { skip_checks => 1 },
COBRAND_FEATURES => {
category_groups => { map { $_ => 1 } @$cobrand },
}
diff --git a/perllib/FixMyStreet/Cobrand/BathNES.pm b/perllib/FixMyStreet/Cobrand/BathNES.pm
index 05c91c8dd..b6014a276 100644
--- a/perllib/FixMyStreet/Cobrand/BathNES.pm
+++ b/perllib/FixMyStreet/Cobrand/BathNES.pm
@@ -76,18 +76,6 @@ sub send_questionnaires { 0 }
sub default_map_zoom { 3 }
-sub map_js_extra {
- my $self = shift;
-
- my $c = $self->{c};
- return unless $c->user_exists;
-
- my $banes_user = $c->user->from_body && $c->user->from_body->areas->{$self->council_area_id};
- if ( $banes_user || $c->user->is_superuser ) {
- return ['/cobrands/bathnes/staff.js'];
- }
-}
-
sub category_extra_hidden {
my ($self, $meta) = @_;
my $code = $meta->{code};
diff --git a/templates/web/bathnes/footer_extra_js.html b/templates/web/bathnes/footer_extra_js.html
index c195600fc..240767d48 100644
--- a/templates/web/bathnes/footer_extra_js.html
+++ b/templates/web/bathnes/footer_extra_js.html
@@ -12,3 +12,11 @@ IF bodyclass.match('mappage');
);
END
%]
+[%~
+SET council_area_id = c.cobrand.council_area_id;
+IF c.user_exists AND ((c.user.from_body AND c.user.from_body.areas.$council_area_id) OR c.user.is_superuser);
+ scripts.push(
+ version('/cobrands/bathnes/staff.js'),
+ );
+END
+%]