Fork `Weed` pointer_type from GenericPointer, not Plant
parent
3700406687
commit
2a04803dc6
|
@ -1,4 +1,2 @@
|
|||
class Weed < Point
|
||||
DEFAULT_ICON = "/app-resources/img/icons/generic-plant.svg"
|
||||
ATTRS = %w(meta name plant_stage planted_at pointer_type radius x y z)
|
||||
end
|
||||
|
|
|
@ -1,19 +1,3 @@
|
|||
class WeedSerializer < BasePointSerializer
|
||||
attributes :plant_stage, :planted_at, :radius, :meta
|
||||
|
||||
def x
|
||||
object.x.round
|
||||
end
|
||||
|
||||
def y
|
||||
object.y.round
|
||||
end
|
||||
|
||||
def z
|
||||
object.z.round
|
||||
end
|
||||
|
||||
def meta
|
||||
object.meta || {}
|
||||
end
|
||||
attributes :radius, :discarded_at
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"coveralls": "3.0.11",
|
||||
"enzyme": "3.11.0",
|
||||
"enzyme-adapter-react-16": "1.15.2",
|
||||
"farmbot": "9.2.0-rc1",
|
||||
"farmbot": "9.2.0-rc2",
|
||||
"i18next": "19.3.3",
|
||||
"install": "0.13.0",
|
||||
"lodash": "4.17.15",
|
||||
|
|
|
@ -48,25 +48,25 @@ describe Api::PointsController do
|
|||
|
||||
it "creates a weed" do
|
||||
sign_in user
|
||||
time = (DateTime.now - 1.day).to_json
|
||||
p = { x: 23,
|
||||
y: 45,
|
||||
name: "unwelcomed guest",
|
||||
pointer_type: "Weed",
|
||||
planted_at: time,
|
||||
plant_stage: "sprouted" }
|
||||
post :create, body: p.to_json, params: { format: :json }
|
||||
body = { x: 1,
|
||||
y: 2,
|
||||
z: 3,
|
||||
radius: 3,
|
||||
name: "test weed",
|
||||
pointer_type: "Weed",
|
||||
meta: { foo: "BAR" } }
|
||||
post :create, body: body.to_json, params: { format: :json }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json[:name]).to eq(body[:name])
|
||||
expect(json[:x]).to eq(body[:x])
|
||||
expect(json[:y]).to eq(body[:y])
|
||||
expect(json[:z]).to eq(body[:z])
|
||||
expect(json[:radius]).to eq(body[:radius])
|
||||
expect(json[:meta][:foo]).to eq(body[:meta][:foo])
|
||||
weed = Weed.last
|
||||
expect(weed.x).to eq(p[:x])
|
||||
expect(weed.y).to eq(p[:y])
|
||||
expect(weed.name).to eq(p[:name])
|
||||
expect(weed.plant_stage).to eq("sprouted")
|
||||
expect(p[:plant_stage]).to eq("sprouted")
|
||||
expect(weed.created_at).to be_truthy
|
||||
p.keys.each do |key|
|
||||
expect(json).to have_key(key)
|
||||
end
|
||||
expect(weed.id).to eq(json[:id])
|
||||
expect(weed.device).to eq(device)
|
||||
expect(json[:pointer_type]).to eq(body[:pointer_type])
|
||||
end
|
||||
|
||||
it "validates pointer_type" do
|
||||
|
|
Loading…
Reference in New Issue