Search by type

pull/867/head
Rick Carlino 2018-05-25 09:24:34 -05:00
parent 3bf9ea8416
commit b49b128c60
2 changed files with 16 additions and 0 deletions

View File

@ -15,6 +15,7 @@ module Points
float :z
hstore :meta
string :name
string :pointer_type, in: Point::POINTER_KINDS
end
def execute

View File

@ -62,5 +62,20 @@ describe Api::PointsController do
expect(json).to be_kind_of(Array)
expect(json.length).to eq(0)
end
it 'filters by point_type' do
sign_in user
d = user.device
tool_slot = FactoryBot.create(:tool_slot, device: d)
plant = FactoryBot.create(:plant, device: d)
generic_pointer = FactoryBot.create(:generic_pointer, device: d)
post :search,
body: { pointer_type: "Plant" }.to_json,
params: {format: :json }
expect(response.status).to eq(200)
expect(json).to be_kind_of(Array)
expect(json.length).to eq(1)
expect(json.first[:pointer_type]).to eq("Plant")
end
end
end