Skip to content

Commit

Permalink
Make api urls consistent in tests (for percy)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Feb 6, 2024
1 parent 5c1235b commit 400592e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/helpers/api_howto_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def api_example_latlong_url(
format:, key:, lat: Rails.configuration.planningalerts_api_example_lat, lng: Rails.configuration.planningalerts_api_example_lng,
radius: Rails.configuration.planningalerts_api_example_size
)
applications_url(host: api_host, format:, lat:, lng:, radius:, key:)
applications_url(
host: api_host, port: api_port,
format:, lat:, lng:, radius:, key:
)
end

sig do
Expand All @@ -58,7 +61,8 @@ def api_example_area_url(
top_right_lng: Rails.configuration.planningalerts_api_example_top_right_lng
)
applications_url(
host: api_host, format:,
host: api_host, port: api_port,
format:,
bottom_left_lat:, bottom_left_lng:,
top_right_lat:, top_right_lng:,
key:
Expand All @@ -68,7 +72,8 @@ def api_example_area_url(
sig { params(format: String, key: T.nilable(String), authority: String).returns(String) }
def api_example_authority_url(format:, key:, authority: Rails.configuration.planningalerts_api_example_authority)
authority_applications_url(
host: api_host, format:, authority_id: authority,
host: api_host, port: api_port,
format:, authority_id: authority,
key:
)
end
Expand All @@ -82,7 +87,7 @@ def api_example_authority_url(format:, key:, authority: Rails.configuration.plan
).returns(String)
end
def api_example_postcode_url(format:, key:, postcode: Rails.configuration.planningalerts_api_example_postcode, extra_params: {})
T.unsafe(self).applications_url({ host: api_host, format:, postcode:, key: }.merge(extra_params))
T.unsafe(self).applications_url({ host: api_host, port: api_port, format:, postcode:, key: }.merge(extra_params))
end

sig do
Expand All @@ -102,7 +107,7 @@ def api_example_suburb_state_and_postcode_url(
postcode: Rails.configuration.planningalerts_api_example_postcode
)
applications_url(
host: api_host, format:, suburb:, state:, postcode:,
host: api_host, port: api_port, format:, suburb:, state:, postcode:,
key:
)
end
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/applications_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,9 @@ def sign_gmap_bus_api_url(url_to_sign, google_cryptographic_key)
def api_host
Rails.env.development? ? "localhost" : "api.planningalerts.org.au"
end

sig { returns(T.nilable(Integer)) }
def api_port
Rails.env.development? ? 3000 : nil
end
end

0 comments on commit 400592e

Please sign in to comment.