Permalink
Browse files

Merge remote-tracking branch 'origin/pushq' into pushq

  • Loading branch information...
2 parents 35450db + 9e5d302 commit 11baf9c62f8ac9da63d50fff022baf8873b408b3 @treeder treeder committed Dec 28, 2012
Showing with 19 additions and 17 deletions.
  1. +1 −1 lib/iron_mq/messages.rb
  2. +10 −9 lib/iron_mq/subscribers.rb
  3. +8 −7 test/test_push_queues.rb
View
@@ -93,6 +93,7 @@ def release(message_id, options={})
end
class Message < ResponseBase
+ attr_reader :messages
def initialize(messages, res, options={})
super(res)
@@ -124,5 +125,4 @@ def subscribers(options={})
ret
end
end
-
end
View
@@ -1,19 +1,15 @@
module IronMQ
-
class Subscribers
-
def self.path(options)
path = "#{Messages.path(options)}/subscribers"
if options[:subscriber_id]
path << "/#{options[:subscriber_id]}"
end
path
end
-
end
class Subscriber < ResponseBase
-
attr_accessor :options
def initialize(raw, message, options={})
@@ -22,12 +18,17 @@ def initialize(raw, message, options={})
@options = options
end
- def delete(subscriber_id, options={})
- options[:subscriber_id] = subscriber_id
- res = @client.parse_response(@message.messages.client.delete(Subscribers.path(options)))
+ def delete(options={})
+ client = @message.messages.client
+
+ options[:subscriber_id] ||= @raw["id"]
+ options[:msg_id] ||= @message.id
+ options[:project_id] ||= client.project_id
+ options[:queue_name] ||= client.queue_name
+ path = Subscribers.path(options)
+ raw = client.delete(path)
+ res = client.parse_response(raw)
return ResponseBase.new(res)
end
-
end
end
-
View
@@ -131,14 +131,15 @@ def test_failure
subscribers = queue.messages.get(m.id).subscribers
p subscribers
assert_equal 2, subscribers.size
- subscribers.each_with_index do |s|
+ subscribers.each do |s|
p s
- assert_equal 200, s["status_code"]
- if i == 0
- assert_equal "deleted", s["status"]
- else
- # this one should error out
+
+ if s["url"] == "http://rest-test.iron.io/code/503"
+ assert_equal 503, s["status_code"]
assert_equal "error", s["status"]
+ else
+ assert_equal 200, s["status_code"]
+ assert_equal "deleted", s["status"]
end
end
@@ -195,7 +196,7 @@ def test_202
subscribers.each do |s|
p s
assert_equal 202, s["status_code"]
- assert_equal "retrying", s["status"]
+ assert_equal "reserved", s["status"]
# now let's delete it to say we're done with it
puts "Acking subscriber"
p s.delete

0 comments on commit 11baf9c

Please sign in to comment.