:thinking_face: Weird class var mutation issues ... ?

pull/915/head
Rick Carlino 2018-07-17 11:48:31 -05:00
parent 60b85e4d38
commit 903e3ce1b5
11 changed files with 33 additions and 18 deletions

View File

@ -4,8 +4,6 @@ module Resources
DESTROY = "destroy"
]
RESOURCES = { # Because I don't trust Kernel.const_get
# "DeviceConfig" => DeviceConfig,
# "DiagnosticDump" => DiagnosticDump,
"FarmEvent" => FarmEvent,
"FarmwareInstallations" => FarmwareInstallations,
"Image" => Image,

View File

@ -19,8 +19,6 @@ module Resources
when DESTROY then do_deletion
else; never
end
rescue => x
binding.pry
end
private
@ -33,6 +31,8 @@ module Resources
model_name = resource.model_name
mutation = Kernel.const_get(model_name.name.pluralize)::Destroy
mutation.run!(model_name.singular => model, device: device)
rescue => x
binding.pry
end
def model

View File

@ -10,6 +10,7 @@ class CreateDestroyer < Mutations::Command
end
def execute
# MAGIC AHEAD: Pull stuff into scope for block below.
symbolized_name = resource.model_name.singular
klass = resource
@ -27,6 +28,8 @@ class CreateDestroyer < Mutations::Command
def execute
self.send(@@resource_name).destroy! && ""
rescue => x
binding.pry
end
def not_yours

View File

@ -0,0 +1,3 @@
module DiagnosticDumps
Destroy = CreateDestroyer.run!(resource: DiagnosticDump)
end

View File

@ -0,0 +1,3 @@
module FarmEvents
Destroy = CreateDestroyer.run!(resource: FarmEvent)
end

View File

@ -0,0 +1,3 @@
module FarmwareInstallations
Destroy = CreateDestroyer.run!(resource: FarmwareInstallation)
end

View File

@ -0,0 +1,3 @@
module Images
Destroy = CreateDestroyer.run!(resource: Image)
end

View File

@ -0,0 +1,3 @@
module Logs
Destroy = CreateDestroyer.run!(resource: Log)
end

View File

@ -0,0 +1,3 @@
module PlantTemplates
Destroy = CreateDestroyer.run!(resource: PlantTemplate)
end

View File

@ -4,8 +4,6 @@ Not all resources support the experimental resource API.
|Resource |Delete? |Upsert? |
|-----------------------|---------|---------|
| DeviceConfig |No |No |
| DiagnosticDump |No |No |
| FarmEvent |No |No |
| FarmwareInstallations |No |No |
| Image |No |No |

View File

@ -8,22 +8,20 @@ describe Resources::Job do
{ body: {}, device: device, action: "destroy", uuid: SecureRandom.uuid }
test_cases = [
# DeviceConfig,
# DiagnosticDump,
# FarmEvent,
# FarmwareInstallation,
# Image,
# Log,
# PlantTemplate,
# Point,
# Regimen,
# SavedGarden,
# SensorReading,
FarmEvent,
FarmwareInstallation,
Image,
Log,
PlantTemplate,
SavedGarden,
SensorReading,
WebcamFeed,
Peripheral,
PinBinding,
Sensor,
Tool,
# Tool,
# Point,
# Regimen,
]
.each{ |k| k.destroy_all }
.map { |k| FactoryBot.create(k.model_name.singular.to_sym, device: device) }