Skip to content

Commit

Permalink
Made suggestions methods consistent with API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Oct 18, 2010
1 parent 5c2e197 commit 8393a06
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions lib/twitter/authenticated.rb
Expand Up @@ -311,12 +311,12 @@ def lists(list_owner_screen_name=nil, options={})
def suggestions(category_slug=nil, options={})
path = case category_slug
when nil
"suggestions.#{Twitter.format}"
"users/suggestions.#{Twitter.format}"
when Hash
options = category_slug
"suggestions.#{Twitter.format}"
"users/suggestions.#{Twitter.format}"
else
"users/suggestions/#{category_slug}/members.#{Twitter.format}"
"users/suggestions/#{category_slug}.#{Twitter.format}"
end
perform_get(path, options)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/twitter/unauthenticated.rb
Expand Up @@ -30,12 +30,12 @@ def profile_image(screen_name, options={})
def suggestions(category_slug=nil, options={})
path = case category_slug
when nil
"suggestions.#{Twitter.format}"
"users/suggestions.#{Twitter.format}"
when Hash
options = category_slug
"suggestions.#{Twitter.format}"
"users/suggestions.#{Twitter.format}"
else
"users/suggestions/#{category_slug}/members.#{Twitter.format}"
"users/suggestions/#{category_slug}.#{Twitter.format}"
end
results = connection.get do |request|
request.url path, options
Expand Down
Expand Up @@ -369,22 +369,22 @@ class AuthenticatedTest < Test::Unit::TestCase
end

should "get suggestions" do
stub_get("/1/suggestions.#{format}", "array.#{format}")
stub_get("/1/users/suggestions.#{format}", "array.#{format}")
assert @client.suggestions
end

should "get suggestions by category_slug" do
stub_get("/1/users/suggestions/technology/members.#{format}", "array.#{format}")
stub_get("/1/users/suggestions/technology.#{format}", "array.#{format}")
assert @client.suggestions('technology')
end

should "get suggestions with a cursor" do
stub_get("/1/suggestions.#{format}?cursor=-1", "array.#{format}")
stub_get("/1/users/suggestions.#{format}?cursor=-1", "array.#{format}")
assert @client.suggestions(:cursor => -1)
end

should "get suggestions by category_slug with a cursor" do
stub_get("/1/users/suggestions/technology/members.#{format}?cursor=-1", "array.#{format}")
stub_get("/1/users/suggestions/technology.#{format}?cursor=-1", "array.#{format}")
assert @client.suggestions('technology', :cursor => -1)
end

Expand Down
8 changes: 4 additions & 4 deletions test/twitter/unauthenticated_test.rb
Expand Up @@ -29,22 +29,22 @@ class UnauthenticatedTest < Test::Unit::TestCase
end

should "get suggestions" do
stub_get("/1/suggestions.#{format}", "hash.#{format}")
stub_get("/1/users/suggestions.#{format}", "hash.#{format}")
assert Twitter.suggestions
end

should "get suggestions by category_slug" do
stub_get("/1/users/suggestions/technology/members.#{format}", "hash.#{format}")
stub_get("/1/users/suggestions/technology.#{format}", "hash.#{format}")
assert Twitter.suggestions('technology')
end

should "get suggestions with a cursor" do
stub_get("/1/suggestions.#{format}?cursor=-1", "hash.#{format}")
stub_get("/1/users/suggestions.#{format}?cursor=-1", "hash.#{format}")
assert Twitter.suggestions(:cursor => -1)
end

should "get suggestions by category_slug with a cursor" do
stub_get("/1/users/suggestions/technology/members.#{format}?cursor=-1", "hash.#{format}")
stub_get("/1/users/suggestions/technology.#{format}?cursor=-1", "hash.#{format}")
assert Twitter.suggestions('technology', :cursor => -1)
end

Expand Down

0 comments on commit 8393a06

Please sign in to comment.