From 363b24be8feaaaf0001b50dc44f11b59b4205dca Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Mon, 23 Jul 2018 10:52:49 -0500 Subject: [PATCH] WIP --- app/models/celery_script_settings_bag.rb | 1 + .../resources/resources_preprocessor_spec.rb | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/models/celery_script_settings_bag.rb b/app/models/celery_script_settings_bag.rb index d615028ad..91b2dbc96 100644 --- a/app/models/celery_script_settings_bag.rb +++ b/app/models/celery_script_settings_bag.rb @@ -181,6 +181,7 @@ module CeleryScriptSettingsBag node.invalidate!(NO_PIN_ID % [klass]) if (id == 0) bad_node = !klass.exists?(id) node.invalidate!(BAD_PIN_ID % [klass, id]) if bad_node + # binding.pry if [BoxLed3, BoxLed4].includes(klass) end .node(:nothing, []) .node(:tool, [:tool_id]) diff --git a/spec/lib/resources/resources_preprocessor_spec.rb b/spec/lib/resources/resources_preprocessor_spec.rb index d8dffddcb..f8c91e649 100644 --- a/spec/lib/resources/resources_preprocessor_spec.rb +++ b/spec/lib/resources/resources_preprocessor_spec.rb @@ -63,12 +63,13 @@ describe Resources::PreProcessor do it "handles semantic errors using step2" do Transport.current.connection.clear! - x = Resources::Service.step2(action: "wrong_action", - device: FactoryBot.create(:device), - body: "wrong_body", - resource_id: 0, - resource: "wrong_resource", - uuid: "wrong_uuid") + dev = FactoryBot.create(:device) + x = Resources::Service.step2(action: "wrong_action", + device: dev, + body: "wrong_body", + resource_id: 0, + resource: "wrong_resource", + uuid: "wrong_uuid") call_args = x.calls[:publish].last message = JSON.parse(call_args.first) options = call_args.last @@ -78,6 +79,11 @@ describe Resources::PreProcessor do message.dig("body").pluck("args").pluck("message") errors = message.dig("body").pluck("args").pluck("message") expect(errors).to include("Action isn't an option") + segment = options.fetch(:routing_key).split(".") + expect(segment[0]).to eq("bot") + expect(segment[1]).to eq("device_#{devi.id}") + expect(segment[2]).to eq("from_api") + expect(segment[3]).to eq("wrong_uuid") end it "processes resources" do