Skip to content

Commit

Permalink
update date error message
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Jun 27, 2024
1 parent a441727 commit eaa6bb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/v0/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def check_date_param_format(param_name)
Time.parse(params[param_name])
return true
rescue
message = "The #{param_name} parameter must be an ISO8601 format datetime or an integer number of seconds since the start of the UNIX epoch."
message = "The #{param_name} parameter must be an ISO8601 format date or datetime or an integer number of seconds since the start of the UNIX epoch."
render json: { message: message, status: 400 }, status: 400
return false
end
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/v0/readings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
it "rejects from dates in unrecognised format" do
api_get "devices/#{device.id}/readings?sensor_id=#{device.sensors.first.id}&rollup=avg&from=2020-15"
expect(response.status).to eq(400)
expect(response.body).to match("The from parameter must be an ISO8601 format datetime or an integer number of seconds since the start of the UNIX epoch.")
expect(response.body).to match("The from parameter must be an ISO8601 format date or datetime or an integer number of seconds since the start of the UNIX epoch.")
end

it "allows to dates in unix epoch format" do
Expand All @@ -62,7 +62,7 @@
it "rejects to dates in unrecognised format" do
api_get "devices/#{device.id}/readings?sensor_id=#{device.sensors.first.id}&rollup=avg&to=2020-15"
expect(response.status).to eq(400)
expect(response.body).to match("The to parameter must be an ISO8601 format datetime or an integer number of seconds since the start of the UNIX epoch.")
expect(response.body).to match("The to parameter must be an ISO8601 format date or datetime or an integer number of seconds since the start of the UNIX epoch.")
end
end

Expand Down

0 comments on commit eaa6bb3

Please sign in to comment.