Skip to content

Commit

Permalink
Merge pull request #19 from octokit-cr/feat/pull_requests
Browse files Browse the repository at this point in the history
Implement PullRequests
  • Loading branch information
GrantBirki authored Aug 12, 2024
2 parents 97033c3 + e83eeb0 commit 0eb439d
Show file tree
Hide file tree
Showing 13 changed files with 573 additions and 60 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ There are a lot of pieces of the GitHub API to cover. Here are the ones that nee
- [ ] [Pages]()
- [ ] [Projects]()
- [x] [PubSubHubbub](https://octokit-cr.github.io/octokit.cr/Octokit/Client/PubSubHubbub.html)
- [ ] [PullRequests]()
- [x] [PullRequests](https://octokit-cr.github.io/octokit.cr/Octokit/Client/PullRequests.html)
- [x] [RateLimit](https://octokit-cr.github.io/octokit.cr/Octokit/Client/RateLimit.html)
- [ ] [Reactions]()
- [ ] [Refs]()
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: octokit
version: 0.2.5
version: 0.3.0

authors:
- Grant Birkinbine
Expand Down
92 changes: 92 additions & 0 deletions spec/acceptance/acceptance.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ require "spec"

describe Octokit do
github = Octokit.client
github.auto_paginate = true
github.per_page = 100

describe ".get" do
context "when fetching info about the octokit.cr repo" do
Expand All @@ -23,4 +25,94 @@ describe Octokit do
end
end
end

describe "pull requests" do
context "fetches closed pull requests" do
pulls = github.pull_requests("octokit-cr/octokit.cr", state: "closed").records

it "should find at least one closed pull request" do
pulls.size.should be > 0
end

it "should fetch the title of the first closed pull request" do
pulls.first.title.should_not be_nil
end
end

context "fetches pull request comments" do
comments = github.pull_request_comments("octokit-cr/octokit.cr", 15).records

it "should find at least one comment" do
comments.size.should be > 0
end

it "should fetch the body of the first comment" do
comments.first.body.should_not be_nil
end

it "should fetch the diff_hunk of the first comment" do
comments.first.diff_hunk.should_not be_nil
end

it "should fetch the path of the first comment" do
comments.first.path.should_not be_nil
end

it "should fetch the position of the first comment" do
comments.first.position.should_not be_nil
end

it "should fetch the ID of the first comment" do
comments.first.id.should_not be_nil
end
end

context "fetches pull request files" do
files = github.pull_request_files("octokit-cr/octokit.cr", 15).records

it "should find at least one file" do
files.size.should be > 0
end

it "should fetch the filename of the first file" do
files.first.filename.should_not be_nil
end

it "should fetch the sha of the first file" do
files.first.sha.should_not be_nil
end

it "should fetch the status of the first file" do
files.first.status.should_not be_nil
end

it "should fetch the additions of the first file" do
files.first.additions.should_not be_nil
end

it "should fetch the deletions of the first file" do
files.first.deletions.should_not be_nil
end

it "should fetch the contents_url of the first file" do
files.first.contents_url.should_not be_nil
end

it "should fetch the patch of the first file" do
files.first.patch.should_not be_nil
end

it "should fetch the sha of the second file" do
files[1].sha.should_not be_nil
end
end

context "merged pull request" do
pull = github.pull_merged?("octokit-cr/octokit.cr", 15)

it "checks if the pull request is merged and finds that it is" do
pull.should eq true
end
end
end
end
1 change: 1 addition & 0 deletions src/octokit/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ module Octokit
include Octokit::Client::Issues
include Octokit::Client::Markdown
include Octokit::Client::PubSubHubbub
include Octokit::Client::PullRequests
include Octokit::Client::Users
include Octokit::Client::RateLimit
include Octokit::Client::Repositories
Expand Down
Loading

0 comments on commit 0eb439d

Please sign in to comment.