Skip to content

Commit

Permalink
Merge pull request octokit#895 from greysteil/add-find-user-installat…
Browse files Browse the repository at this point in the history
…ions

Add Octokit::Client::Apps#find_user_installations method
  • Loading branch information
tarebyte authored Aug 21, 2017
2 parents 0f13944 + c778ea2 commit 19482da
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rvm:
- 2.1
- 2.2
- 2.3.3
- 2.4.0
- 2.4.1

bundler_args: --without development

Expand Down
12 changes: 12 additions & 0 deletions lib/octokit/client/apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ def find_integration_installations(options = {})
find_app_installations(options)
end

# Find all installations that are accessible to the authenticated user
#
# @param options [Hash] An customizable set of options
#
# @see https://developer.github.com/v3/apps/#list-installations-for-user
#
# @return [Array<Sawyer::Resource>] A list of installations
def find_user_installations(options = {})
opts = ensure_api_media_type(:integrations, options)
paginate "/user/installations", opts
end

# Get a single installation
#
# @param id [Integer] Installation id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions":[{"request":{"method":"get","uri":"https://api.github.com/user/installations","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["Accept: application/vnd.github.machine-man-preview+json"],"User-Agent":["Octokit Ruby Gem 4.6.2"],"Content-Type":["application/json"],"Authorization":["Bearer <JWT_BEARER_TOKEN>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Server":["GitHub.com"],"Date":["Mon, 06 Mar 2017 22:17:47 GMT"],"Content-Type":["application/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Status":["200 OK"],"Cache-Control":["public, max-age=60, s-maxage=60"],"Vary":["Accept","Accept-Encoding"],"Etag":["W/\"47870164deaaf2f565734db32ec45e97\""],"X-Github-Media-Type":["github.machine-man-preview; format=json"],"Access-Control-Expose-Headers":["ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"],"Access-Control-Allow-Origin":["*"],"Content-Security-Policy":["default-src 'none'"],"Strict-Transport-Security":["max-age=31536000; includeSubdomains; preload"],"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["deny"],"X-Xss-Protection":["1; mode=block"],"X-Served-By":["2811da37fbdda4367181b328b22b2499"],"X-Github-Request-Id":["A9F9:6D38:14B3D9B:1A5EEFB:58BDE00B"]},"body":{"encoding":"ASCII-8BIT","base64_string":"W3siaWQiOjxHSVRIVUJfVEVTVF9JTlRFR1JBVElPTl9JTlNUQUxMQVRJT04+\nLCJhY2NvdW50Ijp7ImxvZ2luIjoiPEdJVEhVQl9URVNUX09SR0FOSVpBVElP\nTj4iLCJpZCI6MTc1Mjk4MTQsImF2YXRhcl91cmwiOiJodHRwczovL2F2YXRh\ncnMwLmdpdGh1YnVzZXJjb250ZW50LmNvbS91LzE3NTI5ODE0P3Y9MyIsImdy\nYXZhdGFyX2lkIjoiIiwidXJsIjoiaHR0cHM6Ly9hcGkuZ2l0aHViLmNvbS91\nc2Vycy88R0lUSFVCX1RFU1RfT1JHQU5JWkFUSU9OPiIsImh0bWxfdXJsIjoi\naHR0cHM6Ly9naXRodWIuY29tLzxHSVRIVUJfVEVTVF9PUkdBTklaQVRJT04+\nIiwiZm9sbG93ZXJzX3VybCI6Imh0dHBzOi8vYXBpLmdpdGh1Yi5jb20vdXNl\ncnMvPEdJVEhVQl9URVNUX09SR0FOSVpBVElPTj4vZm9sbG93ZXJzIiwiZm9s\nbG93aW5nX3VybCI6Imh0dHBzOi8vYXBpLmdpdGh1Yi5jb20vdXNlcnMvPEdJ\nVEhVQl9URVNUX09SR0FOSVpBVElPTj4vZm9sbG93aW5ney9vdGhlcl91c2Vy\nfSIsImdpc3RzX3VybCI6Imh0dHBzOi8vYXBpLmdpdG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vYXBpLmdpdGh1\nYi5jb20vaW5zdGFsbGF0aW9uL3JlcG9zaXRvcmllcyIsImh0bWxfdXJsIjoi\naHR0cHM6Ly9naXRodWIuY29tL29yZ2FuaXphdGlvbnMvPEdJVEhVQl9URVNU\nX09SR0FOSVpBVElPTj4vc2V0dGluZ3MvaW5zdGFsbGF0aW9ucy88R0lUSFVC\nX1RFU1RfSU5URUdSQVRJT05fSU5TVEFMTEFUSU9OPiJ9XQ==\n"},"http_version":null},"recorded_at":"Mon, 06 Mar 2017 22:17:47 GMT"}],"recorded_with":"VCR 2.9.3"}
10 changes: 9 additions & 1 deletion spec/octokit/client/apps_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@

describe ".find_app_installations", :vcr do
it "returns installations for an app" do
installations = @jwt_client.find_integration_installations
installations = @jwt_client.find_app_installations
expect(installations).to be_kind_of Array
assert_requested :get, github_url("/app/installations")
end
end # .find_app_installations

describe ".find_user_installations", :vcr do
it "returns installations for a user" do
installations = @client.find_user_installations
expect(installations).to be_kind_of Array
assert_requested :get, github_url("/user/installations")
end
end # .find_user_installations

context "with app installation", :vcr do
let(:installation) { test_github_integration_installation }

Expand Down

0 comments on commit 19482da

Please sign in to comment.