Skip to content

Commit

Permalink
Adjust locations endpoint filter requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanTG committed Dec 21, 2024
1 parent 3e84128 commit 318b5f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def suggest
param :regionless_only, Integer, desc: 'Show only regionless locations', required: false
formats ['json']
def index
return return_response(FILTERING_REQUIRED_MSG, 'errors') unless %i[region by_location_name by_location_id by_machine_id by_ipdb_id by_opdb_id by_machine_name by_city_id by_machine_group_id by_zone_id by_operator_id by_type_id by_at_least_n_machines_type by_at_least_n_machines by_is_stern_army regionless_only].any? { params[_1].present? }
return return_response(FILTERING_REQUIRED_MSG, 'errors') unless %i[region by_location_name by_location_id by_machine_id by_ipdb_id by_opdb_id by_machine_name by_city_id by_machine_group_id by_zone_id by_operator_id by_type_id by_is_stern_army regionless_only].any? { params[_1].present? }

except = params[:no_details] ? %i[phone website description created_at updated_at date_last_updated last_updated_by_user_id region_id] : nil

Expand Down
8 changes: 8 additions & 0 deletions spec/requests/api/v1/locations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
get '/api/v1/locations.json'

expect(JSON.parse(response.body)['errors']).to eq(Api::V1::LocationsController::FILTERING_REQUIRED_MSG)

get '/api/v1/locations.json?by_at_least_n_machines=1'

expect(JSON.parse(response.body)['errors']).to eq(Api::V1::LocationsController::FILTERING_REQUIRED_MSG)

get '/api/v1/locations.json?by_at_least_n_machines_type=1'

expect(JSON.parse(response.body)['errors']).to eq(Api::V1::LocationsController::FILTERING_REQUIRED_MSG)
end

it 'forces filters to have a param value' do
Expand Down

0 comments on commit 318b5f9

Please sign in to comment.