Permalink
Browse files

Custom origin is now available for sub and pub. Added test for the same.

  • Loading branch information...
1 parent 4caa7a6 commit 98fc4070ecd3ff03800ff9c5d51bd66e76a8301e geremy committed Feb 26, 2013
View
@@ -2,6 +2,7 @@
. errors logged to /tmp/pubnubError.log by default
. selectively retry based on operation type
. adjust request timeouts based on operation type
+. publish and subscribe both take origin argument
02-25-13
. graceful recover on bad json
View
@@ -11,7 +11,7 @@ gem 'sqlite3'
gem 'em-http-request'
gem "uuid", "~> 2.3.5"
gem 'yajl-ruby'
-gem 'pubnub'
+gem 'pubnub', "3.3.0.5"
gem 'linecache19'
gem 'ruby_core_source'
gem 'ruby-debug19'
View
@@ -73,7 +73,7 @@ GEM
rack
rake (>= 0.8.1)
polyglot (0.3.3)
- pubnub (3.3.0.4)
+ pubnub (3.3.0.5)
activesupport
em-http-request
eventmachine
@@ -156,7 +156,7 @@ DEPENDENCIES
httparty
linecache19
passenger
- pubnub
+ pubnub (= 3.3.0.5)
rails (= 3.2.6)
rr (= 1.0.4)
rspec-rails (~> 2.0)

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -118,6 +118,7 @@ def subscribe(options)
#TODO: refactor into initializer code on request instantiation
subscribe_request.ssl = @ssl
+ subscribe_request.set_origin(options)
subscribe_request.set_channel(options)
subscribe_request.set_callback(options)
subscribe_request.set_cipher_key(options, self.cipher_key) unless subscribe_request.operation == "presence"
View
Binary file not shown.
View
Binary file not shown.
View
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = "pubnub"
- s.version = "3.3.0.4"
+ s.version = "3.3.0.5"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["PubNub"]
@@ -22,6 +22,15 @@
end
end
+ it "should publish without ssl with custom origin" do
+ my_response = [1, "Sent", "13619174360247577"]
+ mock(@my_callback).call(my_response) {}
+
+ VCR.use_cassette("integration_publish_10", :record => :none) do
+ @pn.publish(:origin => "a.pubnub.com", :channel => :hello_world, :message => "hi", :callback => @my_callback)
+ end
+ end
+
it "should publish with ssl" do
my_response = [1, "Sent", "13451428018571368"]
@@ -29,6 +29,18 @@
end
+ it "should allow a custom origin at subscribe time" do
+ my_response = [[], "13619080213373042"]
+ mock(@my_callback).call(my_response) {EM.stop}
+
+ VCR.use_cassette("integration_subscribe_6", :record => :none) do
+ @pn.subscribe(:origin => "myorigin.pubnub.com", :channel => :hello_world, :callback => @my_callback)
+ end
+
+ # Test will fail if origin breaks per VCR tape
+
+ end
+
it "should retry on a non 200 server response" do
my_response = [[], "13617798873598999"]
mock(@my_callback).call(my_response) {EM.stop}
@@ -70,6 +82,21 @@
context "with basic subscribe config" do
+
+ it "should continue with a custom origin" do
+ my_response = [[], "13619080213373042"]
+ mock(@my_callback).call(my_response) {}
+ mock(@my_callback).call(my_response) {EM.stop}
+
+ VCR.use_cassette("integration_subscribe_7", :record => :none) do
+ @pn.subscribe(:origin => "myorigin.pubnub.com", :channel => :hello_world, :callback => @my_callback)
+ end
+
+ # Test will fail if origin breaks per VCR tape
+
+ end
+
+
it "should sub without ssl" do
my_response = [[{"text" => "bo"}], "13455067954018816"]
mock(@my_callback).call(my_response) { EM.stop}

0 comments on commit 98fc407

Please sign in to comment.