Modifications in prep. for table changes
parent
953e3620f5
commit
e4aea4d0f4
|
@ -33,8 +33,8 @@ module Api
|
|||
end
|
||||
|
||||
def destroy
|
||||
ids = params[:id].to_s.split(",")
|
||||
mutate Points::Destroy.run({ points: points.find(ids) }, device_params)
|
||||
ids = params[:id].to_s.split(",").map(&:to_i)
|
||||
mutate Points::Destroy.run({point_ids: ids}, device_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -114,7 +114,7 @@ module CeleryScript
|
|||
EdgeNode.where(kind: "sequence_id", value: sequence.id).exists? ||
|
||||
RegimenItem.where(sequence_id: sequence.id).exists? ||
|
||||
FarmEvent.where(executable: sequence).exists?
|
||||
s = HashWithIndifferentAccess.new(canonical_form)
|
||||
s = canonical_form.with_indifferent_access
|
||||
# HISTORICAL NOTE:
|
||||
# When I prototyped the variables declaration stuff, a few (failed)
|
||||
# iterations snuck into the DB. Gradually migrating is easier than
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# THIS IS A SQL VIEW. IT IS NOT A REAL TABLE.
|
||||
# Maps Tool <==> Sequence
|
||||
class InUseTool < ApplicationRecord
|
||||
def readonly?
|
||||
true
|
||||
|
|
|
@ -5,7 +5,7 @@ module Points
|
|||
|
||||
required do
|
||||
model :device, class: Device
|
||||
array :points, class: Point
|
||||
array :point_ids, class: Integer
|
||||
end
|
||||
|
||||
def validate
|
||||
|
@ -20,9 +20,13 @@ module Points
|
|||
|
||||
private
|
||||
|
||||
def points
|
||||
@points ||= Point.where(id: point_ids)
|
||||
end
|
||||
|
||||
def every_tool_id_as_json
|
||||
# TODO: If we unify Plant/ToolSlot/GenericPointer, this could be
|
||||
# simplified.
|
||||
# TODO: If we unify Plant/ToolSlot/GenericPointer,
|
||||
# this could be simplified.
|
||||
points
|
||||
.map { |x| x.pointer.try(:tool_id) }
|
||||
.compact
|
||||
|
|
|
@ -31,7 +31,7 @@ describe Points::Destroy do
|
|||
sequence = Sequences::Create.run!(params)
|
||||
before = Point.count
|
||||
# Attempt to delete
|
||||
result = Points::Destroy.run(points: points, device: device)
|
||||
result = Points::Destroy.run(point_ids: points.pluck(:id), device: device)
|
||||
# Expect error about point in use still.
|
||||
expect(result.success?).to be false
|
||||
expect(Point.count).to eq(before)
|
||||
|
@ -42,7 +42,8 @@ describe Points::Destroy do
|
|||
|
||||
it "prevents deletion of active tool slots" do
|
||||
s = Points::Scenario.new
|
||||
result = Points::Destroy.run(points: [s.tool_slot], device: s.device)
|
||||
point_ids = [s.tool_slot.id]
|
||||
result = Points::Destroy.run(point_ids: point_ids, device: s.device)
|
||||
expect(result.success?).to be(false)
|
||||
expect(result.errors.message_list)
|
||||
.to include(Points::Destroy::STILL_IN_USE % s.sequence[:name])
|
||||
|
|
Loading…
Reference in New Issue