Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## Unreleased

- Minimum supported Ruby version updated to 3.2
## 2.0.0

- Changed: Minimum supported Ruby version updated to 3.2.
- Fix: Responses that don't have a `last_url` in the link no longer error.

## 1.0.1

Expand Down
1 change: 1 addition & 0 deletions lib/git_hub_bub/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def first_url

def last_page?
return true if next_url.nil?
return false if last_url.nil? # A next page exists, but no "last" page, keep going.
last_page_number = page_number_from_url(last_url)
next_page_number = page_number_from_url(next_url)
next_page_number > last_page_number
Expand Down
2 changes: 1 addition & 1 deletion lib/git_hub_bub/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module GitHubBub
VERSION = "1.0.1"
VERSION = "2.0.0"
end
19 changes: 19 additions & 0 deletions test/git_hub_bub/response_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ def test_rate_limit_reset_time_left
end
end

def test_last_page_with_next_but_no_last_url
# This reproduces a real response from the GitHub API where the Link header
# only contains rel="next" but no rel="last"
data = {
body: "[{\"url\":\"https://api.github.com/repos/puma/puma/issues/3643\"}]",
headers: {
"Link" => "<https://api.github.com/repositories/2441517/issues?direction=desc&page=2&sort=comments&state=open&after=Y3Vyc29yOnYyOpIIzpU4Fek%3D&per_page=30>; rel=\"next\""
},
status: 200
}
response = GitHubBub::Response.new(data)

assert_equal "https://api.github.com/repositories/2441517/issues?direction=desc&page=2&sort=comments&state=open&after=Y3Vyc29yOnYyOpIIzpU4Fek%3D&per_page=30",
response.next_url
assert_nil response.last_url

refute response.last_page?
end

def test_rate_limit_sleep
epoch_time = 1504196685

Expand Down