Set default `planted_at` value

pull/1770/head
Rick Carlino 2020-04-27 15:05:53 -05:00
parent 9f35dd9992
commit 87c22d4a96
2 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,10 @@
class PlantSerializer < BasePointSerializer
attributes :openfarm_slug, :plant_stage, :planted_at, :radius, :meta
def planted_at
object.planted_at || object.created_at
end
def x
object.x.round
end

View File

@ -9,8 +9,8 @@ describe Api::PointsController do
end
let(:auth_token) do
params = { email: user.email,
password: "password123",
fbos_version: Gem::Version.new("999.9.9") }
password: "password123",
fbos_version: Gem::Version.new("999.9.9") }
Auth::CreateToken.run!(params)[:token].encoded
end
@ -130,6 +130,7 @@ describe Api::PointsController do
get :index
expect(response.status).to eq(200)
expect(json.length).to eq(3)
json.map { |json| expect(json[:created_at]).to eq(json[:planted_at]) }
end
it "lists all tool slots" do
Point.destroy_all