Skip to content
Open
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
6 changes: 3 additions & 3 deletions lib/fbe/github_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def pull_requests_with_reviews(owner, name, since, cursor: nil)
id
number
updatedAt
timelineItems(first: 1, itemTypes: [PULL_REQUEST_REVIEW], since: "#{since.utc.iso8601}") {
timelineItems(first: 1, itemTypes: [PULL_REQUEST_REVIEW], since: "#{since.getutc.iso8601}") {
nodes {
... on PullRequestReview { id }
}
Expand Down Expand Up @@ -463,7 +463,7 @@ def total_commits_pushed(owner, name, since, till = Time.now)
defaultBranchRef {
target {
... on Commit {
history(#{after}first: 100, since: "#{since.utc.iso8601}", until: "#{till.utc.iso8601}") {
history(#{after}first: 100, since: "#{since.getutc.iso8601}", until: "#{till.getutc.iso8601}") {
totalCount
nodes {
oid
Expand Down Expand Up @@ -507,7 +507,7 @@ def total_commits_pushed(owner, name, since, till = Time.now)
# @param [Time] till The datetime to
# @return [Hash] A hash with total issues and pulls
def total_issues_created(owner, name, since, till = Time.now)
window = "created:#{since.utc.iso8601}..#{till.utc.iso8601}"
window = "created:#{since.getutc.iso8601}..#{till.getutc.iso8601}"
result = query(
<<~GRAPHQL
{
Expand Down
2 changes: 1 addition & 1 deletion lib/fbe/if_absent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def Fbe.if_absent(fb: Fbe.fb, always: false)
if v.is_a?(String)
vv = "'#{vv.gsub('"', '\\\\"').gsub("'", "\\\\'")}'"
elsif v.is_a?(Time)
vv = v.utc.iso8601
vv = v.getutc.iso8601
end
"(eq #{k} #{vv})"
end.join(' ')
Expand Down
2 changes: 1 addition & 1 deletion lib/fbe/just_one.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def Fbe.just_one(fb: Fbe.fb)
if v.is_a?(String)
vv = "'#{vv.gsub('"', '\\\\"').gsub("'", "\\\\'")}'"
elsif v.is_a?(Time)
vv = v.utc.iso8601
vv = v.getutc.iso8601
end
"(eq #{k} #{vv})"
end.join(' ')
Expand Down
37 changes: 37 additions & 0 deletions test/fbe/test_github_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1058,4 +1058,41 @@ def test_fake_total_releases_published_dont_count_after_till
h = graph.total_releases_published(owner, name, since, till: since + 60)
assert_equal(1, h['releases'], "the fake counts releases published after the till moment, seed: #{seed}")
end

def test_time_arguments_keep_their_utc_offsets
since = Time.new(2026, 10, 4, 12, 0, 0, '+03:00')
till = Time.new(2026, 10, 5, 12, 0, 0, '+05:00')
graph = Fbe::Graph.new(token: 'test')
graph.define_singleton_method(:query) do |qry|
if qry.include?('pullRequests')
{
'repository' => {
'pullRequests' => {
'nodes' => [], 'pageInfo' => { 'hasNextPage' => false, 'endCursor' => nil }
}
}
}
elsif qry.include?('history(')
{
'repository' => {
'defaultBranchRef' => {
'target' => {
'history' => {
'nodes' => [], 'totalCount' => 0,
'pageInfo' => { 'hasNextPage' => false, 'endCursor' => nil }
}
}
}
}
}
else
{ 'issues' => { 'issueCount' => 0 }, 'pulls' => { 'issueCount' => 0 } }
end
end
graph.pull_requests_with_reviews('owner', 'repo', since)
graph.total_commits_pushed('owner', 'repo', since, till)
graph.total_issues_created('owner', 'repo', since, till)
assert_equal(10_800, since.utc_offset)
assert_equal(18_000, till.utc_offset)
end
end
13 changes: 13 additions & 0 deletions test/fbe/test_if_absent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ def test_ignores_with_time
assert_nil(n)
end

def test_does_not_change_time_utc_offset
fb = Factbase.new
stored = fb.insert
stored.what = 'meeting'
stored.when = Time.utc(2026, 10, 4, 9, 0, 0)
at = Time.new(2026, 10, 4, 12, 0, 0, '+03:00')
Fbe.if_absent(fb:) do |fact|
fact.what = 'meeting'
fact.when = at
end
assert_equal(10_800, at.utc_offset)
end

def test_injects
fb = Factbase.new
n =
Expand Down
13 changes: 13 additions & 0 deletions test/fbe/test_just_one.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ def test_tells_apart_two_times_inside_one_second
assert_equal(2, fb.size)
end

def test_does_not_change_time_utc_offset
fb = Factbase.new
stored = fb.insert
stored.what = 'meeting'
stored.when = Time.utc(2026, 10, 4, 9, 0, 0)
at = Time.new(2026, 10, 4, 12, 0, 0, '+03:00')
Fbe.just_one(fb:) do |fact|
fact.what = 'meeting'
fact.when = at
end
assert_equal(10_800, at.utc_offset)
end

def test_ignores
fb = Factbase.new
fb.insert.foo = 'hello dude'
Expand Down
Loading