Skip to content

Commit

Permalink
Merge pull request octokit#393 from joeyw/fix-subscriptions-method
Browse files Browse the repository at this point in the history
Fix #subscriptions method.
  • Loading branch information
pengwynn committed Dec 27, 2013
2 parents 22d042b + 56b8d25 commit d93bd97
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
6 changes: 5 additions & 1 deletion lib/octokit/client/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,11 @@ def remove_email(email)
# @example
# @client.subscriptions("pengwynn")
def subscriptions(user=login, options = {})
path = user_authenticated? ? "user/subscriptions" : "users/#{user}/subscriptions"
if user == login && user_authenticated?
path = "user/subscriptions"
else
path = "users/#{user}/subscriptions"
end
paginate path, options
end
alias :watched :subscriptions
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

22 changes: 16 additions & 6 deletions spec/octokit/client/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,23 @@
end # .remove_email

describe ".subscriptions", :vcr do
it "returns the repositories a user watches for notifications" do
subscriptions = Octokit.subscriptions("pengwynn")
assert_requested :get, github_url("/users/pengwynn/subscriptions")
context "not authenticated" do
it "returns the repositories a user watches for notifications" do
subscriptions = Octokit.subscriptions("pengwynn")
assert_requested :get, github_url("/users/pengwynn/subscriptions")
end
end
it "returns the repositories the authenticated user watches for notifications" do
subscriptions = @client.subscriptions
assert_requested :get, github_url("/user/subscriptions")

context "authenticated" do
it "returns the repositories the authenticated user watches for notifications" do
subscriptions = @client.subscriptions
assert_requested :get, github_url("/user/subscriptions")
end

it "returns the repositories a user watches for notifications" do
subscriptions = @client.subscriptions("pengwynn")
assert_requested :get, github_url("/users/pengwynn/subscriptions")
end
end
end # .subscriptions

Expand Down

0 comments on commit d93bd97

Please sign in to comment.