diff --git a/lib/tentacat/organizations/members.ex b/lib/tentacat/organizations/members.ex index 1997848..97084f5 100644 --- a/lib/tentacat/organizations/members.ex +++ b/lib/tentacat/organizations/members.ex @@ -12,12 +12,13 @@ defmodule Tentacat.Organizations.Members do Tentacat.Organizations.Members.list "github" Tentacat.Organizations.Members.list client, "github" + Tentacat.Organizations.Members.list client, "github", %{page: 2} More info at: http://developer.github.com/v3/orgs/members/#members-list """ - @spec list(Client.t(), binary) :: Tentacat.response() - def list(client \\ %Client{}, organization) do - get("orgs/#{organization}/members", client) + @spec list(Client.t(), binary, Keyword.t()) :: Tentacat.response() + def list(client \\ %Client{}, organization, options \\ []) do + get("orgs/#{organization}/members", client, options) end @doc """ diff --git a/mix.exs b/mix.exs index e4ca5d0..8e5daa5 100644 --- a/mix.exs +++ b/mix.exs @@ -11,10 +11,19 @@ defmodule Tentacat.Mixfile do elixir: "~> 1.16", name: "Tentacat", test_coverage: [tool: ExCoveralls], - preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test], + preferred_cli_env: [ + coveralls: :test, + "coveralls.detail": :test, + "coveralls.post": :test, + c: :test + ], package: package(), deps: deps(), - docs: docs() + docs: docs(), + aliases: [ + t: ["test"], + c: ["coveralls.html"] + ] ] end diff --git a/test/fixture/vcr_cassettes/members#list_with_params.json b/test/fixture/vcr_cassettes/members#list_with_params.json new file mode 100644 index 0000000..4168791 --- /dev/null +++ b/test/fixture/vcr_cassettes/members#list_with_params.json @@ -0,0 +1,46 @@ +[ + { + "request": { + "body": "\"\"", + "headers": { + "User-agent": "tentacat", + "Authorization": "token yourtokencomeshere" + }, + "method": "get", + "options": [], + "request_body": "", + "url": "https://api.github.com/orgs/dwyl/members?page=2" + }, + "response": { + "body": "[{\"login\":\"josephwilk\",\"id\":9792,\"avatar_url\":\"https://avatars.githubusercontent.com/u/9792?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/josephwilk\",\"html_url\":\"https://github.com/josephwilk\",\"followers_url\":\"https://api.github.com/users/josephwilk/followers\",\"following_url\":\"https://api.github.com/users/josephwilk/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/josephwilk/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/josephwilk/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/josephwilk/subscriptions\",\"organizations_url\":\"https://api.github.com/users/josephwilk/orgs\",\"repos_url\":\"https://api.github.com/users/josephwilk/repos\",\"events_url\":\"https://api.github.com/users/josephwilk/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/josephwilk/received_events\",\"type\":\"User\",\"site_admin\":false}]", + "headers": { + "Server": "GitHub.com", + "Date": "Thu, 10 Dec 2015 22:17:43 GMT", + "Content-Type": "application/json; charset=utf-8", + "Content-Length": "1739", + "Status": "200 OK", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4993", + "X-RateLimit-Reset": "1449785982", + "Cache-Control": "private, max-age=60, s-maxage=60", + "ETag": "\"7a18009ec36ef8d2939950529c9a7fa5\"", + "X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org", + "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", + "X-GitHub-Media-Type": "github.v3; format=json", + "X-XSS-Protection": "1; mode=block", + "X-Frame-Options": "deny", + "Content-Security-Policy": "default-src 'none'", + "Access-Control-Allow-Credentials": "true", + "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": "*", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Served-By": "4c8b2d4732c413f4b9aefe394bd65569", + "X-GitHub-Request-Id": "5F5BD13E:A39A:484FE95:5669FA06" + }, + "status_code": 200, + "type": "ok" + } + } +] diff --git a/test/organizations/members_test.exs b/test/organizations/members_test.exs index cc6ea5d..38d6bd0 100644 --- a/test/organizations/members_test.exs +++ b/test/organizations/members_test.exs @@ -18,6 +18,13 @@ defmodule Tentacat.Organizations.MembersTest do end end + test "list/3 second page of people" do + use_cassette "members#list_with_params" do + {_, [%{"login" => login}], _} = list(@client, "dwyl", %{page: 2}) + assert login == "josephwilk" + end + end + test "member?/3" do use_cassette "members#member_" do {status_code, _, _} = member?(@client, "elixir-conspiracy", "josephwilk")