aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-10-24 20:44:56 +0100
committerMatthew Somerville <matthew@mysociety.org>2013-10-24 21:34:46 +0100
commit604d306f4fc0f0024fc9a493f391413811dfbb3f (patch)
tree37f387602688877a84614dfb16e0dda7684a6d3b
parentcd51c26830d4f6ba144874e2f26010f7b6b76636 (diff)
More accurate config overriding for Zurich.
-rw-r--r--perllib/FixMyStreet.pm3
-rw-r--r--perllib/FixMyStreet/App.pm8
-rw-r--r--t/cobrand/zurich.t8
-rw-r--r--templates/web/default/admin/body-form.html3
-rw-r--r--templates/web/zurich/admin/body-form.html3
5 files changed, 20 insertions, 5 deletions
diff --git a/perllib/FixMyStreet.pm b/perllib/FixMyStreet.pm
index 6c664f1d1..cc5286bbb 100644
--- a/perllib/FixMyStreet.pm
+++ b/perllib/FixMyStreet.pm
@@ -92,12 +92,13 @@ sub override_config($&) {
mySociety::MaPit::configure($config->{MAPIT_URL}) if $config->{MAPIT_URL};
- # For historical reasons, we have two ways of askig for config variables.
+ # For historical reasons, we have two ways of asking for config variables.
# Override them both, I'm sure we'll find time to get rid of one eventually.
my $override_guard1 = Sub::Override->new(
"FixMyStreet::config",
sub {
my ($class, $key) = @_;
+ return { %CONFIG, %$config } unless $key;
return $config->{$key} if exists $config->{$key};
my $orig_config = mySociety::Config::load_default();
return $orig_config->{$key} if exists $orig_config->{$key};
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index cf766348f..4f70d2c68 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -208,6 +208,14 @@ sub setup_request {
DateTime->DefaultLocale( 'en_US' );
}
+ if (FixMyStreet->test_mode) {
+ # Is there a better way of altering $c->config that may have
+ # override_config involved?
+ $c->setup_finished(0);
+ $c->config( %{ FixMyStreet->config() } );
+ $c->setup_finished(1);
+ }
+
return $c;
}
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index b1f3955be..edc99d758 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -377,7 +377,9 @@ subtest "only superuser can see 'Add body' form" => sub {
$user = $mech->log_in_ok( 'dm1@example.org' );
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],
- MAPIT_URL => 'http://mapit.mysociety.org/',
+ MAPIT_URL => 'http://global.mapit.mysociety.org/',
+ MAPIT_TYPES => [ 'O08' ],
+ MAPIT_ID_WHITELIST => [ 423017 ],
}, sub {
$mech->get_ok( '/admin/bodies' );
};
@@ -429,7 +431,9 @@ subtest "problems can't be assigned to deleted bodies" => sub {
$report->update;
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],
- MAPIT_URL => 'http://mapit.mysociety.org/',
+ MAPIT_URL => 'http://global.mapit.mysociety.org/',
+ MAPIT_TYPES => [ 'O08' ],
+ MAPIT_ID_WHITELIST => [ 423017 ],
}, sub {
$mech->get_ok( '/admin/body/' . $external_body->id );
$mech->submit_form_ok( { with_fields => { deleted => 1 } } );
diff --git a/templates/web/default/admin/body-form.html b/templates/web/default/admin/body-form.html
index 55a98105a..e876f3e5e 100644
--- a/templates/web/default/admin/body-form.html
+++ b/templates/web/default/admin/body-form.html
@@ -69,9 +69,10 @@
<label for="area_ids">[% loc('Area covered') %]</label>
<select name="area_ids" id="area_ids" multiple>
<option value=""> -- [% loc('Select an area') %] -- </option>
+ [% SET body_areas = body.areas %]
[% FOR area IN areas %]
[% SET aid = area.id %]
- <option value="[% area.id %]"[% ' selected' IF body.areas.$aid %]>[% area.name %]</option>
+ <option value="[% area.id %]"[% ' selected' IF body_areas.$aid %]>[% area.name %]</option>
[% END %]
</select>
</p>
diff --git a/templates/web/zurich/admin/body-form.html b/templates/web/zurich/admin/body-form.html
index 4e570a058..a31dffe7c 100644
--- a/templates/web/zurich/admin/body-form.html
+++ b/templates/web/zurich/admin/body-form.html
@@ -24,9 +24,10 @@
<label for="area_ids">[% loc('Area covered') %]</label>
<select name="area_ids" id="area_ids" multiple>
<option value=""> -- [% loc('Select an area') %] -- </option>
+ [% SET body_areas = body.areas %]
[% FOR area IN areas %]
[% SET aid = area.id %]
- <option value="[% area.id %]"[% ' selected' IF body.areas.$aid %]>[% area.name %]</option>
+ <option value="[% area.id %]"[% ' selected' IF body_areas.$aid %]>[% area.name %]</option>
[% END %]
</select>
</p>