mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|queues] adding id alias for identity; fixed bug in message#identity that returned the id along with the claim_id query string; removed redundant code.
This commit is contained in:
parent
1e39b45121
commit
903eacfbeb
4 changed files with 24 additions and 6 deletions
|
@ -12,6 +12,8 @@ module Fog
|
|||
attribute :limit
|
||||
attribute :messages
|
||||
|
||||
alias :id :identity
|
||||
|
||||
def save
|
||||
if identity.nil?
|
||||
create
|
||||
|
|
|
@ -12,12 +12,12 @@ module Fog
|
|||
attribute :claim_id
|
||||
|
||||
def identity
|
||||
if href
|
||||
href.split('/').last
|
||||
else
|
||||
nil
|
||||
end
|
||||
return nil unless href
|
||||
|
||||
match = href.match(/(\/(\w+))*\??/)
|
||||
match ? match[-1] : nil
|
||||
end
|
||||
alias :id :identity
|
||||
|
||||
def save
|
||||
requires :queue, :client_id, :body, :ttl
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
|
||||
#Helper method to enqueue a single message
|
||||
def enqueue(body, ttl, options = {})
|
||||
messages.create(options.merge(options.merge({:body => body, :ttl => ttl})))
|
||||
messages.create(options.merge({:body => body, :ttl => ttl}))
|
||||
end
|
||||
|
||||
#Helper method to claim (dequeue) a single message, including destroying it
|
||||
|
|
|
@ -32,4 +32,20 @@ Shindo.tests('Fog::Rackspace::Queues | message', ['rackspace']) do
|
|||
ensure
|
||||
queue.destroy
|
||||
end
|
||||
|
||||
tests('identity') do
|
||||
tests('nil') do
|
||||
message = Fog::Rackspace::Queues::Message.new :href => nil
|
||||
returns(nil) { message.id }
|
||||
end
|
||||
tests('with claim id') do
|
||||
message = Fog::Rackspace::Queues::Message.new :href => '/v1/queues/queue1/messages/528b7e4bb04a584f2eb805a3?claim_id=528b7e6aef913e6d2977ee6d'
|
||||
returns('528b7e4bb04a584f2eb805a3') { message.id }
|
||||
end
|
||||
tests('without claim id') do
|
||||
message = Fog::Rackspace::Queues::Message.new :href => '/v1/queues/queue1/messages/528b7e4bb04a584f2eb805a3'
|
||||
returns('528b7e4bb04a584f2eb805a3') { message.id }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue