Skip to content

Commit

Permalink
Use default radius in other places
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Oct 31, 2023
1 parent ba8b2c8 commit a93beeb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def point
elsif params_area_size
params_area_size.to_f
else
2000.0
Alert::DEFAULT_RADIUS.to_f
end
location = Location.new(lat: params_lat.to_f, lng: params_lng.to_f)
location_text = location.to_s
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def address
params_time = T.cast(params[:time], T.nilable(String))

@q = T.let(params_q, T.nilable(String))
radius = params_radius ? params_radius.to_f : 2000.0
radius = params_radius ? params_radius.to_f : Alert::DEFAULT_RADIUS.to_f
# We don't want to allow a search radius that's too large
radius = [2000.0, radius].min
radius = [Alert::DEFAULT_RADIUS.to_f, radius].min
@radius = T.let(radius, T.nilable(Float))

time = params_time ? params_time.to_i : 365
Expand Down
2 changes: 1 addition & 1 deletion app/views/applications/_filter_options.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:ruby
component.with_menu do |menu|
Alert::VALID_RADIUS_METERS_VALUES.each do |radius_option|
menu.with_item(disabled: radius.to_i == radius_option) { link_to "within #{meters_in_words(radius_option)}", { q:, radius: (radius_option == 2000 ? nil : radius_option) } }
menu.with_item(disabled: radius.to_i == radius_option) { link_to "within #{meters_in_words(radius_option)}", { q:, radius: (radius_option == Alert::DEFAULT_RADIUS ? nil : radius_option) } }
end
end
- else
Expand Down
2 changes: 1 addition & 1 deletion spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
lat { -33.911105 }
lng { 151.155503 }
lonlat { RGeo::Geographic.spherical_factory(srid: 4326).point(151.155503, -33.911105) }
radius_meters { 2000 }
radius_meters { Alert::DEFAULT_RADIUS }
confirm_id { "1234" }

factory :unsubscribed_alert do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/manage_alerts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
alert = create(:alert,
address: "24 Bruce Rd, Glenbrook",
user: create(:user, email: "[email protected]"),
radius_meters: "2000", lat: 1.0, lng: 1.0)
radius_meters: Alert::DEFAULT_RADIUS, lat: 1.0, lng: 1.0)
visit unsubscribe_alert_url(confirm_id: alert.confirm_id, host: "dev.planningalerts.org.au")

expect(page).to have_content("You have been unsubscribed")
Expand All @@ -24,7 +24,7 @@
alert = create(:alert,
address: "24 Bruce Rd, Glenbrook",
user:,
radius_meters: "2000", lat: 1.0, lng: 1.0)
radius_meters: Alert::DEFAULT_RADIUS, lat: 1.0, lng: 1.0)
sign_in user
visit edit_profile_alert_url(alert, host: "dev.planningalerts.org.au")

Expand Down

0 comments on commit a93beeb

Please sign in to comment.