Skip to content

Commit

Permalink
Change default zone from Southwark to Central London
Browse files Browse the repository at this point in the history
We need the zone to be a top level zone because the map starts zoomed out.
  • Loading branch information
jdudley1123 committed Nov 25, 2024
1 parent dc83fa8 commit d6c2074
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/models/zone.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Zone < ApplicationRecord
DEFAULT_ZONE_SOUTHWARK_CERC_ID = 29
DEFAULT_ZONE_CENTRAL_LONDON_CERC_ID = 55

def self.default
find_by!(cerc_id: DEFAULT_ZONE_SOUTHWARK_CERC_ID)
find_by!(cerc_id: DEFAULT_ZONE_CENTRAL_LONDON_CERC_ID)
end
end
8 changes: 4 additions & 4 deletions spec/controllers/forecasts_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
RSpec.describe ForecastsController do
let(:southwark) { double("Southwark") }
let(:central_london) { double("Central London") }
let(:barnet) { double("Barnet") }

before do
allow(Zone).to receive(:find_by).and_return(barnet)
allow(Zone).to receive(:default).and_return(southwark)
allow(Zone).to receive(:default).and_return(central_london)
allow(CercForecastService).to receive(:latest_forecasts_for).and_return(forecasts)
end

Expand All @@ -14,10 +14,10 @@

describe "GET :show" do
context "when NO zone is given" do
it "obtains forecasts for the default zone (Southwark) from the CercForecastService" do
it "obtains forecasts for the default zone (Central London) from the CercForecastService" do
get :show

expect(CercForecastService).to have_received(:latest_forecasts_for).with(southwark)
expect(CercForecastService).to have_received(:latest_forecasts_for).with(central_london)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/factories/forecast_zones.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

FactoryBot.define do
factory :forecast_zone do
id { 29 }
name { "Southwark" }
id { 55 }
name { "Central London" }
type { 1 }

initialize_with { new(**attributes) }
Expand Down
2 changes: 1 addition & 1 deletion spec/feature_steps/zone_steps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
def create_default_zone
FactoryBot.create(:zone, name: "Southwark", cerc_id: 29)
FactoryBot.create(:zone, name: "Central London", cerc_id: 55)
end
4 changes: 2 additions & 2 deletions spec/fixtures/api/forecasts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def all_forecasts(forecasts = [])
}
end

def zone_object(zone_id: 29, forecasts: [])
def zone_object(zone_id: 55, forecasts: [])
{
"forecasts" => forecasts.presence || [zone_forecast],
"zone_id" => zone_id,
"zone_name" => "Southwark",
"zone_name" => "Central London",
"zone_type" => 1
}
end
Expand Down
6 changes: 3 additions & 3 deletions spec/models/zone_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
RSpec.describe Zone do
describe "::default" do
before { FactoryBot.create(:zone, cerc_id: Zone::DEFAULT_ZONE_SOUTHWARK_CERC_ID) }
before { FactoryBot.create(:zone, cerc_id: Zone::DEFAULT_ZONE_CENTRAL_LONDON_CERC_ID) }

it "returns Southwark's Zone record" do
expect(Zone.default.cerc_id).to eq(Zone::DEFAULT_ZONE_SOUTHWARK_CERC_ID)
it "returns Central London zone record" do
expect(Zone.default.cerc_id).to eq(Zone::DEFAULT_ZONE_CENTRAL_LONDON_CERC_ID)
end
end
end
6 changes: 3 additions & 3 deletions spec/services/cerc_forecast_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.describe CercForecastService do
describe "::latest_forecasts_for(zone)" do
let(:zone) { FactoryBot.create(:zone, cerc_id: 29) }
let(:zone) { FactoryBot.create(:zone, cerc_id: 55) }

context "when the cache is stale" do
let(:latest_forecasts_from_api) { Fixtures::API.all_forecasts }
Expand Down Expand Up @@ -64,8 +64,8 @@
"wind_am" => 4.9,
"wind_pm" => 5.3}
],
"zone_id" => 29,
"zone_name" => "Southwark",
"zone_id" => 55,
"zone_name" => "Central London",
"zone_type" => 1}
end

Expand Down

0 comments on commit d6c2074

Please sign in to comment.