Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Convert nil messages to the empty string. Fixes #8.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Dec 18, 2014
1 parent 4ba773a commit 1bf8970
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lita/adapters/slack/message_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def handle
attr_reader :type

def body
data["text"].sub(/^\s*<@#{robot_id}>/, "@#{robot.mention_name}")
data["text"].to_s.sub(/^\s*<@#{robot_id}>/, "@#{robot.mention_name}")
end

def channel
Expand Down
20 changes: 20 additions & 0 deletions spec/lita/adapters/slack/message_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@
subject.handle
end
end

context "when the message is nil" do
let(:data) do
{
"type" => "message",
"channel" => "C2147483705",
"user" => "U023BECGF",
}
end

it "dispatches an empty message to Lita" do
expect(Lita::Message).to receive(:new).with(
robot,
"",
source
).and_return(message)

subject.handle
end
end
end

context "with a message with an unsupported subtype" do
Expand Down

0 comments on commit 1bf8970

Please sign in to comment.