Skip to content

Commit

Permalink
Allow negative cost_per_unit for geofences
Browse files Browse the repository at this point in the history
  • Loading branch information
ayonix committed Oct 3, 2020
1 parent 35add49 commit 7a0609b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion lib/teslamate/locations/geo_fence.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ defmodule TeslaMate.Locations.GeoFence do
])
|> validate_required([:name, :latitude, :longitude, :radius])
|> validate_number(:radius, greater_than: 0, less_than: 5000)
|> validate_number(:cost_per_unit, greater_than_or_equal_to: 0)
|> validate_number(:session_fee, greater_than_or_equal_to: 0)
end
end
2 changes: 1 addition & 1 deletion lib/teslamate_web/live/geofence_live/form.html.leex
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</p>
<p class="control is-expanded">
<%= text_input f, :cost_per_unit, class: "input",
type: :number, inputmode: :decimal, min: 0.0, step: 0.0001,
type: :number, inputmode: :decimal, step: 0.0001,
placeholder: "0.00" %>
</p>
<%= if @show_errors do %>
Expand Down
2 changes: 0 additions & 2 deletions test/teslamate/locations/geofences_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ defmodule TeslaMate.LocationsGeofencesTest do
longitude: nil,
radius: nil,
billing_type: :per_hour,
cost_per_unit: -0.01,
session_fee: -0.01
}

Expand Down Expand Up @@ -67,7 +66,6 @@ defmodule TeslaMate.LocationsGeofencesTest do
name: ["can't be blank"],
radius: ["can't be blank"],
billing_type: ["is invalid"],
cost_per_unit: ["must be greater than or equal to 0"],
session_fee: ["must be greater than or equal to 0"]
}

Expand Down

0 comments on commit 7a0609b

Please sign in to comment.