PointGroup related additions
parent
1e267e751c
commit
fa5f9ed1ff
|
@ -6,6 +6,10 @@ module Api
|
||||||
render json: your_point_groups
|
render json: your_point_groups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
render json: the_point_group
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
mutate PointGroups::Create.run(raw_json, point_group_params)
|
mutate PointGroups::Create.run(raw_json, point_group_params)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,22 +2,27 @@ module Devices
|
||||||
class Sync < Mutations::Command
|
class Sync < Mutations::Command
|
||||||
SEL = "SELECT id, updated_at FROM"
|
SEL = "SELECT id, updated_at FROM"
|
||||||
WHERE = "WHERE device_id = "
|
WHERE = "WHERE device_id = "
|
||||||
WHERE2 = "devices WHERE id = "
|
|
||||||
|
def self.basic_query(plural_resource, where = WHERE)
|
||||||
|
[SEL, plural_resource, where].join(" ")
|
||||||
|
end
|
||||||
|
|
||||||
QUERIES = {
|
QUERIES = {
|
||||||
devices: [SEL, WHERE2].join(" "),
|
devices: basic_query("devices", "WHERE id = "),
|
||||||
farm_events: [SEL, "farm_events", WHERE].join(" "),
|
farm_events: basic_query("farm_events"),
|
||||||
farmware_envs: [SEL, "farmware_envs", WHERE].join(" "),
|
farmware_envs: basic_query("farmware_envs"),
|
||||||
farmware_installations: [SEL, "farmware_installations", WHERE].join(" "),
|
farmware_installations: basic_query("farmware_installations"),
|
||||||
peripherals: [SEL, "peripherals", WHERE].join(" "),
|
peripherals: basic_query("peripherals"),
|
||||||
pin_bindings: [SEL, "pin_bindings", WHERE].join(" "),
|
pin_bindings: basic_query("pin_bindings"),
|
||||||
points: [SEL, "points", WHERE].join(" "),
|
points: basic_query("points"),
|
||||||
regimens: [SEL, "regimens", WHERE].join(" "),
|
regimens: basic_query("regimens"),
|
||||||
sensor_readings: [SEL, "sensor_readings", WHERE].join(" "),
|
sensor_readings: basic_query("sensor_readings"),
|
||||||
sensors: [SEL, "sensors", WHERE].join(" "),
|
sensors: basic_query("sensors"),
|
||||||
sequences: [SEL, "sequences", WHERE].join(" "),
|
sequences: basic_query("sequences"),
|
||||||
tools: [SEL, "tools", WHERE].join(" "),
|
tools: basic_query("tools"),
|
||||||
fbos_configs: [SEL, "fbos_configs", WHERE].join(" "),
|
fbos_configs: basic_query("fbos_configs"),
|
||||||
firmware_configs: [SEL, "firmware_configs", WHERE].join(" "),
|
firmware_configs: basic_query("firmware_configs"),
|
||||||
|
point_groups: basic_query("point_groups"),
|
||||||
}
|
}
|
||||||
|
|
||||||
STUB_FARMWARES = Api::FirstPartyFarmwaresController::STUBS.values.map do |x|
|
STUB_FARMWARES = Api::FirstPartyFarmwaresController::STUBS.values.map do |x|
|
||||||
|
|
|
@ -18,7 +18,7 @@ FarmBot::Application.routes.draw do
|
||||||
peripherals: [:create, :destroy, :index, :show, :update],
|
peripherals: [:create, :destroy, :index, :show, :update],
|
||||||
pin_bindings: [:create, :destroy, :index, :show, :update],
|
pin_bindings: [:create, :destroy, :index, :show, :update],
|
||||||
plant_templates: [:create, :destroy, :index, :update],
|
plant_templates: [:create, :destroy, :index, :update],
|
||||||
point_groups: [:index, :create, :update, :destroy],
|
point_groups: [:index, :show, :create, :update, :destroy],
|
||||||
regimens: [:create, :destroy, :index, :show, :update],
|
regimens: [:create, :destroy, :index, :show, :update],
|
||||||
sensor_readings: [:create, :destroy, :index, :show],
|
sensor_readings: [:create, :destroy, :index, :show],
|
||||||
sensors: [:create, :destroy, :index, :show, :update],
|
sensors: [:create, :destroy, :index, :show, :update],
|
||||||
|
|
|
@ -28,6 +28,7 @@ describe Api::DevicesController do
|
||||||
FactoryBot.create(:sensor, device: device)
|
FactoryBot.create(:sensor, device: device)
|
||||||
FactoryBot.create(:tool_slot, device: device)
|
FactoryBot.create(:tool_slot, device: device)
|
||||||
FactoryBot.create(:tool, device: device)
|
FactoryBot.create(:tool, device: device)
|
||||||
|
FactoryBot.create(:point_group, device: device)
|
||||||
FakeSequence.create(device: device)
|
FakeSequence.create(device: device)
|
||||||
|
|
||||||
get :sync, params: {}, session: { format: :json }
|
get :sync, params: {}, session: { format: :json }
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe Api::PointGroupsController do
|
||||||
|
include Devise::Test::ControllerHelpers
|
||||||
|
|
||||||
|
let(:user) { FactoryBot.create(:user) }
|
||||||
|
let(:device) { user.device }
|
||||||
|
let(:old_point_ids) do rando_points end
|
||||||
|
|
||||||
|
it "shows a single point group" do
|
||||||
|
PointGroup.destroy_all
|
||||||
|
PointGroupItem.destroy_all
|
||||||
|
sign_in device.users.first
|
||||||
|
pg = PointGroups::Create
|
||||||
|
.run!(device: device, point_ids: [], name: "PointGroups#show test")
|
||||||
|
get :show, params: { id: pg.id }
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
expect(json.fetch(:name)).to eq pg.name
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,6 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :point_group do
|
factory :point_group do
|
||||||
point_group_items
|
name { Faker::Games::Pokemon.name }
|
||||||
|
# point_group_items # TODO: Broke - RC 23 Sept 19
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,6 +20,7 @@ describe Devices::Sync do
|
||||||
:sensors,
|
:sensors,
|
||||||
:sequences,
|
:sequences,
|
||||||
:tools,
|
:tools,
|
||||||
|
:point_groups,
|
||||||
])
|
])
|
||||||
|
|
||||||
it "is different this time!" do
|
it "is different this time!" do
|
||||||
|
|
Loading…
Reference in New Issue