Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Allow compound join commands. Fixes gh-1.

ZNC's stickychan plugin was issuing
  JOIN #foo,#bar
rather than the normal RFC
  JOIN #foo #bar
  • Loading branch information...
commit 81754e9789687cad80187fec4313ba900a04d612 1 parent c681400
Nathan Witmer authored July 06, 2011
1  lib/camper_van/ircd.rb
@@ -179,6 +179,7 @@ def shutdown
179 179
     end
180 180
 
181 181
     handle :join do |args|
  182
+      args = args.map { |args| args.split(",")}.flatten
182 183
       args.each do |channel|
183 184
         join_channel channel
184 185
       end
36  spec/camper_van/ircd_spec.rb
@@ -106,9 +106,39 @@ def user(*args)
106 106
         @server.handle :user => ["nathan", 0, 0, "Nathan"]
107 107
       end
108 108
 
109  
-      # it "connects to the campfire API" do
110  
-      #   skip "campfire api next!"
111  
-      # end
  109
+      context "with a JOIN command" do
  110
+        before :each do
  111
+          @server.campfire = Class.new do
  112
+            def rooms
  113
+              yield [
  114
+                OpenStruct.new(:name => "Test"),
  115
+                OpenStruct.new(:name => "Day Job")
  116
+              ]
  117
+            end
  118
+          end.new
  119
+          @connection.sent.clear
  120
+        end
  121
+
  122
+        it "joins the given room" do
  123
+          @server.handle :join => ["#test"]
  124
+          @server.channels["#test"].must_be_instance_of CamperVan::Channel
  125
+        end
  126
+
  127
+        it "returns an error if the room doesn't exist" do
  128
+          @server.handle :join => ["#foo"]
  129
+          @server.channels["#foo"].must_equal nil
  130
+          @connection.sent.last.must_match /no such.*room/i
  131
+        end
  132
+
  133
+        it "joins multiple channels if given" do
  134
+          @server.handle :join => ["#test,#day_job"]
  135
+          @connection.sent.must_be_empty
  136
+          @server.channels["#test"].must_be_instance_of CamperVan::Channel
  137
+          @server.channels["#day_job"].must_be_instance_of CamperVan::Channel
  138
+          @ser
  139
+        end
  140
+      end
  141
+
112 142
     end
113 143
 
114 144
     context "with a MODE command" do

0 notes on commit 81754e9

Please sign in to comment.
Something went wrong with that request. Please try again.