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

Commit

Permalink
Merge pull request #114 from christhomson/fix-room-name-in-room_object
Browse files Browse the repository at this point in the history
Properly set the room name in received messages
  • Loading branch information
jimmycuadra authored Jan 6, 2017
2 parents 862ec72 + 436c74b commit 7af55c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/lita/adapters/slack/message_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def channel
end

def dispatch_message(user)
source = Source.new(user: user, room: channel)
room = Lita::Room.find_by_id(channel)
source = Source.new(user: user, room: room || channel)
source.private_message! if channel && channel[0] == "D"
message = Message.new(robot, body, source)
message.command! if source.private_message?
Expand Down
5 changes: 4 additions & 1 deletion spec/lita/adapters/slack/message_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
let(:message) { instance_double('Lita::Message', command!: false, extensions: {}) }
let(:source) { instance_double('Lita::Source', private_message?: false) }
let(:user) { instance_double('Lita::User', id: 'U023BECGF') }
let(:room) { instance_double('Lita::Room', id: "C2147483705", name: "general") }

before do
allow(Lita::User).to receive(:find_by_id).and_return(user)
allow(Lita::Room).to receive(:find_by_id).and_return(room)
allow(Lita::Source).to receive(:new).with(
user: user,
room: "C2147483705"
room: room
).and_return(source)
allow(Lita::Message).to receive(:new).with(robot, "Hello", source).and_return(message)
allow(robot).to receive(:receive).with(message)
Expand All @@ -69,6 +71,7 @@
end

before do
allow(Lita::Room).to receive(:find_by_id).and_return(nil)
allow(Lita::Source).to receive(:new).with(
user: user,
room: "D2147483705"
Expand Down

0 comments on commit 7af55c2

Please sign in to comment.