diff options
-rw-r--r-- | .cypress/cypress/integration/bathnes.js | 24 | ||||
-rwxr-xr-x | bin/browser-tests | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/BathNES.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Hounslow.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 6 | ||||
-rw-r--r-- | t/cobrand/hounslow.t | 14 | ||||
-rw-r--r-- | templates/web/bathnes/footer_extra_js.html | 8 |
7 files changed, 51 insertions, 16 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/perllib/FixMyStreet/Cobrand/Hounslow.pm b/perllib/FixMyStreet/Cobrand/Hounslow.pm index 18063c4aa..93512f2b9 100644 --- a/perllib/FixMyStreet/Cobrand/Hounslow.pm +++ b/perllib/FixMyStreet/Cobrand/Hounslow.pm @@ -16,7 +16,7 @@ sub enter_postcode_text { return "Enter a Hounslow street name and area, or postcode"; } -sub admin_user_domain { 'hounslowhighways.org' } +sub admin_user_domain { ('hounslowhighways.org', 'hounslow.gov.uk') } sub disambiguate_location { my $self = shift; diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 1fe346e43..794c3dec6 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -102,8 +102,10 @@ sub users_restriction { 'me.id' => [ { -in => $problem_user_ids }, { -in => $update_user_ids } ], ]; if ($self->can('admin_user_domain')) { - my $domain = $self->admin_user_domain; - push @$or_query, email => { ilike => "%\@$domain" }; + my @domains = $self->admin_user_domain; + @domains = map { { ilike => "%\@$_" } } @domains; + @domains = [ @domains ] if @domains > 1; + push @$or_query, email => @domains; } return $rs->search($or_query); diff --git a/t/cobrand/hounslow.t b/t/cobrand/hounslow.t index 43a5a5523..cb67ad397 100644 --- a/t/cobrand/hounslow.t +++ b/t/cobrand/hounslow.t @@ -9,7 +9,8 @@ $mech->create_contact_ok( email => 'pothole@example.org', ); -$mech->create_user_ok('staff@example.org', from_body => $hounslow_id); +my $user = $mech->create_user_ok('staff@example.org', from_body => $hounslow_id); +$user->user_body_permissions->create({ body_id => $hounslow_id, permission_type => 'user_edit' }); my $tfl = $mech->create_body_ok( 2483, 'TfL'); $mech->create_contact_ok( @@ -96,4 +97,15 @@ subtest "Shows external ID on report page to staff users only" => sub { }; }; +subtest "Admin searches right domains" => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => 'hounslow', + }, sub { + foreach ('hounslowhighways.org', 'hounslow.gov.uk') { + $mech->get_ok('/admin/users?search=xyz@' . $_); + $mech->content_contains('xyz@' . $_); + } + }; +}; + done_testing(); 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 +%] |