Skip to content

Commit

Permalink
Merge pull request octokit#815 from octokit/add-missing-pages-endpoints
Browse files Browse the repository at this point in the history
Add Pages.request_page_build
  • Loading branch information
joeyw authored Oct 23, 2016
2 parents 466b971 + 163fed1 commit fff6882
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/octokit/client/pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module Pages
# @return Sawyer::Resource A GitHub Pages resource
# @see https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site
def pages(repo, options = {})
get "#{Repository.path repo}/pages", options
opts = ensure_api_media_type(:pages, options)
get "#{Repository.path repo}/pages", opts
end

# List Pages builds for a repository
Expand All @@ -33,6 +34,18 @@ def pages_builds(repo, options = {})
def latest_pages_build(repo, options = {})
get "#{Repository.path repo}/pages/builds/latest", options
end

# Request a page build for the latest revision of the default branch
#
# You can only request builds for your repositories
#
# @param repo [Integer, String, Repository, Hash] A GitHub repository
# @return [Sawyer::Resource] Request result
# @see https://developer.github.com/v3/repos/pages/#request-a-page-build
def request_page_build(repo, options = {})
opts = ensure_api_media_type(:pages, options)
post "#{Repository.path repo}/pages/builds", opts
end
end
end
end
1 change: 1 addition & 0 deletions lib/octokit/preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Preview
:reactions => 'application/vnd.github.squirrel-girl-preview'.freeze,
:repository_invitations => 'application/vnd.github.swamp-thing-preview+json'.freeze,
:issue_timelines => 'application/vnd.github.mockingbird-preview+json'.freeze,
:pages => 'application/vnd.github.mister-fantastic-preview+json'.freeze
}

def ensure_api_media_type(type, options)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions":[{"request":{"method":"post","uri":"https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/pages/builds","body":{"encoding":"UTF-8","base64_string":"e30=\n"},"headers":{"Accept":["application/vnd.github.mister-fantastic-preview+json"],"User-Agent":["Octokit Ruby Gem 4.3.1.pre1"],"Content-Type":["application/json"],"Authorization":["token <<ACCESS_TOKEN>>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":201,"message":"Created"},"headers":{"Server":["GitHub.com"],"Date":["Sun, 23 Oct 2016 06:11:33 GMT"],"Content-Type":["application/json; charset=utf-8"],"Content-Length":["92"],"Status":["201 Created"],"X-Ratelimit-Limit":["5000"],"X-Ratelimit-Remaining":["4974"],"X-Ratelimit-Reset":["1477206631"],"Cache-Control":["private, max-age=60, s-maxage=60"],"Vary":["Accept, Authorization, Cookie, X-GitHub-OTP","Accept-Encoding"],"Etag":["\"027fd5762767c67526942449e705dd9e\""],"X-Oauth-Scopes":["admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user"],"X-Accepted-Oauth-Scopes":[""],"Location":["https://api.github.com/repositories/71685143/pages/builds/latest"],"X-Github-Media-Type":["github.mister-fantastic-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":["4C6B2AEE:3E51:127AF2E5:580C5494"]},"body":{"encoding":"UTF-8","base64_string":"eyJzdGF0dXMiOiJxdWV1ZWQiLCJ1cmwiOiJodHRwczovL2FwaS5naXRodWIu\nY29tL3JlcG9zaXRvcmllcy83MTY4NTE0My9wYWdlcy9idWlsZHMvbGF0ZXN0\nIn0=\n"},"http_version":null},"recorded_at":"Sun, 23 Oct 2016 06:11:33 GMT"}],"recorded_with":"VCR 2.9.3"}
10 changes: 10 additions & 0 deletions spec/octokit/client/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@
assert_requested :get, github_url("/repos/github/developer.github.com/pages/builds/latest")
end
end # .latest_pages_build

describe ".request_page_build", :vcr do
# This test requires some manual setup in your test repository,
# ensure it has pages site enabled and setup.
it "requests a build for the latest revision" do
request = @client.request_page_build(@test_repo)
expect(request.status).not_to be_nil
assert_requested :post, github_url("/repos/#{@test_repo}/pages/builds")
end
end # .request_page_build
end

0 comments on commit fff6882

Please sign in to comment.