[STABLE] Refactoring and tweaks to message handling

pull/75/head
Rick Carlino 2015-03-19 16:17:12 -05:00
parent bdc1994620
commit 64fbb2aafb
3 changed files with 2 additions and 25 deletions

View File

@ -12,28 +12,16 @@ class MessageHandlerSchedule < MessageHandlerBase
WHITELIST = ["single_command","crop_schedule_update"]
def single_command(message)
omg = 0
puts omg += 1
command = message.payload['command']
puts omg += 1
if command
puts omg += 1
command = message.payload['command']
puts omg += 1
command_obj = MessageHandlerScheduleCmdLine.new
puts omg += 1
command_obj.split_command_line( message.payload['command'])
puts omg += 1
command_obj.write_to_log()
puts omg += 1
save_single_command(command_obj, message.delay)
puts omg += 1
Status.current.command_refresh += 1;
puts omg += 1
message.handler.send_confirmation(message.sender, message.time_stamp)
puts omg += 1
else
puts omg += 1
raise 'No command in message'
end
end

View File

@ -24,7 +24,7 @@ describe MessageHandlerEmergencyStop do
## messaging
it "has a white list" do
expect(MessageHandlerEmergencyStop::WHITELIST.list).to eq(2)
expect(MessageHandlerEmergencyStop::WHITELIST.length).to eq(2)
end
it "message handler emergency stop" do

View File

@ -236,21 +236,10 @@ describe MessageHandlerSchedule do
end
it "handle empty command" do
# create a message
message.handled = false
message.handler = @main_handler
message.payload = {}
# execute the message
@handler.single_command(message)
# do the checks
expect(@handler.messaging.message[:message_type]).to eq('error')
expect{ @handler.single_command(message) }.to raise_error(RuntimeError)
end
# save_command_with_lines