Skip to content

Commit

Permalink
Fix tests for paginate check runs refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
solojavier committed May 27, 2024
1 parent 8c7a4e4 commit 3623994
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions test/models/commits_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,11 @@ class CommitsTest < ActiveSupport::TestCase
completed_at: Time.now,
started_at: Time.now - 1.minute,
)
response = mock(
response = stub(rels: {}, data: mock(
check_runs: [check_run],
)
Shipit.github.api.expects(:check_runs).with(@stack.github_repo_name, @commit.sha).returns(response)
))
Shipit.github.api.expects(:check_runs).with(@stack.github_repo_name, @commit.sha, per_page: 100).returns(response.data)
Shipit.github.api.expects(:last_response).returns(response)

assert_difference -> { @commit.check_runs.count }, 1 do
@commit.refresh_check_runs!
Expand Down
4 changes: 3 additions & 1 deletion test/models/merge_request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class MergeRequestTest < ActiveSupport::TestCase
created_at: 1.day.ago,
)])

Shipit.github.api.expects(:check_runs).with(@stack.github_repo_name, head_sha).returns(stub(
response = stub(rels: {}, data: stub(
check_runs: [stub(
id: 123456,
name: 'check run',
Expand All @@ -140,6 +140,8 @@ class MergeRequestTest < ActiveSupport::TestCase
)]
))

Shipit.github.api.expects(:last_response).returns(response)
Shipit.github.api.expects(:check_runs).with(@stack.github_repo_name, head_sha, per_page: 100).returns(response.data)
merge_request.refresh!

assert_predicate merge_request, :mergeable?
Expand Down

0 comments on commit 3623994

Please sign in to comment.