Set default `planted_at` value
parent
9f35dd9992
commit
87c22d4a96
|
@ -1,6 +1,10 @@
|
||||||
class PlantSerializer < BasePointSerializer
|
class PlantSerializer < BasePointSerializer
|
||||||
attributes :openfarm_slug, :plant_stage, :planted_at, :radius, :meta
|
attributes :openfarm_slug, :plant_stage, :planted_at, :radius, :meta
|
||||||
|
|
||||||
|
def planted_at
|
||||||
|
object.planted_at || object.created_at
|
||||||
|
end
|
||||||
|
|
||||||
def x
|
def x
|
||||||
object.x.round
|
object.x.round
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,8 @@ describe Api::PointsController do
|
||||||
end
|
end
|
||||||
let(:auth_token) do
|
let(:auth_token) do
|
||||||
params = { email: user.email,
|
params = { email: user.email,
|
||||||
password: "password123",
|
password: "password123",
|
||||||
fbos_version: Gem::Version.new("999.9.9") }
|
fbos_version: Gem::Version.new("999.9.9") }
|
||||||
Auth::CreateToken.run!(params)[:token].encoded
|
Auth::CreateToken.run!(params)[:token].encoded
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ describe Api::PointsController do
|
||||||
get :index
|
get :index
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(json.length).to eq(3)
|
expect(json.length).to eq(3)
|
||||||
|
json.map { |json| expect(json[:created_at]).to eq(json[:planted_at]) }
|
||||||
end
|
end
|
||||||
it "lists all tool slots" do
|
it "lists all tool slots" do
|
||||||
Point.destroy_all
|
Point.destroy_all
|
||||||
|
|
Loading…
Reference in New Issue