Permalink
Browse files

Don't fetch recent conversation messages if the room info has already…

… been sent
  • Loading branch information...
1 parent 3876047 commit 38d405710f1a4d714721c41d21a3edfc013cf379 @blakesmith committed May 16, 2011
Showing with 12 additions and 3 deletions.
  1. +4 −2 lib/flamethrower/campfire/room.rb
  2. +8 −1 spec/unit/campfire/room_spec.rb
@@ -58,9 +58,11 @@ def fetch_room_info
@users << Flamethrower::Campfire::User.new(user)
end
resolve_renames(old_users, @users)
- send_info unless @room_info_sent
+ unless @room_info_sent
+ send_info
+ fetch_recent_messages
+ end
@room_info_sent = true
- fetch_recent_messages
end
end
end
@@ -139,10 +139,17 @@
assert_requested(:get, "https://mydomain.campfirenow.com/room/347348.json") {|req| req.headers['Authorization'].should == ["mytoken", "x"]}
end
- it "calls fetch_recent_messages after the room info has been sent" do
+ it "calls fetch_recent_messages if the room_info_set is false" do
+ @room.instance_variable_set("@room_info_sent", false)
@room.should_receive(:fetch_recent_messages)
EM.run_block { @room.fetch_room_info }
end
+
+ it "doesn't call fetch_recent_messages if the room_info_sent = true" do
+ @room.instance_variable_set("@room_info_sent", true)
+ @room.should_not_receive(:fetch_recent_messages)
+ EM.run_block { @room.fetch_room_info }
+ end
end
describe "#fetch_recent_messages" do

0 comments on commit 38d4057

Please sign in to comment.