diff --git a/lib/gcloud/pubsub.rb b/lib/gcloud/pubsub.rb index 2f06bbdb696f..5e5648625e8a 100644 --- a/lib/gcloud/pubsub.rb +++ b/lib/gcloud/pubsub.rb @@ -161,16 +161,6 @@ def self.pubsub project = nil, keyfile = nil # sub = topic.subscribe "my-topic-sub" # puts sub.name # => "my-topic-sub" # - # The name is optional, and will be generated if not given. - # - # require "gcloud/pubsub" - # - # pubsub = Gcloud.pubsub - # - # topic = pubsub.topic "my-topic" - # sub = topic.subscribe "my-topic-sub" - # puts sub.name # => "generated-sub-name" - # # The subscription can be created that specifies the number of seconds to # wait to be acknowledged as well as an endpoint URL to push the messages to: # diff --git a/lib/gcloud/pubsub/connection.rb b/lib/gcloud/pubsub/connection.rb index bf880d0ed33e..5ccf06786015 100644 --- a/lib/gcloud/pubsub/connection.rb +++ b/lib/gcloud/pubsub/connection.rb @@ -88,7 +88,7 @@ def delete_topic topic ## # Creates a subscription on a given topic for a given subscriber. - def create_subscription topic, subscription_name = nil, options = {} + def create_subscription topic, subscription_name, options = {} data = subscription_data topic, options @client.execute( api_method: @pubsub.projects.subscriptions.create, diff --git a/lib/gcloud/pubsub/topic.rb b/lib/gcloud/pubsub/topic.rb index 1b1ff9c5e57a..b4d5c6936c85 100644 --- a/lib/gcloud/pubsub/topic.rb +++ b/lib/gcloud/pubsub/topic.rb @@ -104,9 +104,11 @@ def delete # === Parameters # # +subscription_name+:: - # Name of the new subscription. If the name is not provided in the - # request, the server will assign a random name for this subscription - # on the same project as the topic. (+String+) + # Name of the new subscription. Must start with a letter, and contain + # only letters ([A-Za-z]), numbers ([0-9], dashes (-), underscores (_), + # periods (.), tildes (~), plus (+) or percent signs (%). It must be + # between 3 and 255 characters in length, and it must not start with + # "goog". (+String+) # +options+:: # An optional Hash for controlling additional behavior. (+Hash+) # options[:deadline]:: @@ -152,7 +154,7 @@ def delete # deadline: 120, # endpoint: "https://example.com/push" # - def subscribe subscription_name = nil, options = {} + def subscribe subscription_name, options = {} ensure_connection! resp = connection.create_subscription name, subscription_name, options if resp.success? diff --git a/test/gcloud/pubsub/test_topic.rb b/test/gcloud/pubsub/test_topic.rb index db48d4d160c6..2582be029e61 100644 --- a/test/gcloud/pubsub/test_topic.rb +++ b/test/gcloud/pubsub/test_topic.rb @@ -70,19 +70,6 @@ sub.must_be_kind_of Gcloud::Pubsub::Subscription end - it "creates a subscription without giving a name" do - mock_connection.put "/v1/projects/#{project}/subscriptions/" do |env| - JSON.parse(env.body)["topic"].must_equal topic_path(topic_name) - JSON.parse(env.body)["name"].must_be :nil? - [200, {"Content-Type"=>"application/json"}, - subscription_json(topic_name, nil)] - end - - sub = topic.subscribe - sub.wont_be :nil? - sub.must_be_kind_of Gcloud::Pubsub::Subscription - end - it "creates a subscription with a deadline" do new_sub_name = "new-sub-#{Time.now.to_i}" deadline = 42