Skip to content

Commit

Permalink
Tidy up turbo streams
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
jdudley1123 committed Nov 18, 2024
1 parent bfc7e62 commit 3b6d56c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
13 changes: 0 additions & 13 deletions app/controllers/forecasts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ def show

private

def forecast_for_day(day, forecasts)
case day
when "today"
forecasts.first
when "tomorrow"
forecasts.second
when "day_after_tomorrow"
forecasts.third
else
raise ArgumentError, "Invalid day: #{day}"
end
end

def zone
return Zone.default unless params[:zone]

Expand Down
8 changes: 3 additions & 5 deletions spec/controllers/forecasts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@

expect(response).to render_template("show")
end
end

describe "GET :update" do
context "when a recognised _day_ parameter is received" do
it "renders the turbo update template" do
allow(CercForecastService).to receive(:latest_forecasts_for).and_return(forecasts)

get :update, params: {day: :today}, format: :turbo_stream
get :show, params: {day: :today}

expect(CercForecastService).to have_received(:latest_forecasts_for).with(southwark)
expect(response).to render_template("forecasts/update")
expect(response).to render_template("show")
end
end

Expand All @@ -58,7 +56,7 @@
allow(CercForecastService).to receive(:latest_forecasts_for).and_return(forecasts)

expect {
get :update, params: {day: :yesterday}
get :show, params: {day: :yesterday}
}.to raise_error(ArgumentError, "Invalid day: yesterday")
end
end
Expand Down

0 comments on commit 3b6d56c

Please sign in to comment.