From eb10938a5e2769b020163bba68357190d050397a Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 3 Aug 2026 13:42:54 +1000 Subject: [PATCH] List the wrong release first in release lookup specs Both `#upload_release_assets` specs stubbed `client.releases` with the release they expect the helper to pick already in first position, so they passed against a lookup that just takes the first match and never exercised the deterministic selection they were added for. Putting the wrong candidate first makes them fail against such a lookup: verified by reverting `find_release` to `matches.first` over an unsorted list, which turns both red. --- Generated with the help of Claude Code, https://claude.ai/code Co-Authored-By: Claude Code Opus 5 --- spec/github_helper_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/github_helper_spec.rb b/spec/github_helper_spec.rb index e6f30b519..fd3bf46c7 100644 --- a/spec/github_helper_spec.rb +++ b/spec/github_helper_spec.rb @@ -737,7 +737,9 @@ def create_release(is_draft:, assets: [], name: nil) stale_release = sawyer_resource_stub(id: 1, url: 'stale-api-url', html_url: 'stale-html-url', tag_name: test_version, draft: true) latest_release = sawyer_resource_stub(id: 2, url: 'latest-api-url', html_url: 'latest-html-url', tag_name: test_version, draft: true) - allow(client).to receive(:releases).with(test_repo).and_return([latest_release, stale_release]) + # The stale release comes first, so that a lookup relying on the order the API happens to return the releases in + # would pick the wrong one. + allow(client).to receive(:releases).with(test_repo).and_return([stale_release, latest_release]) expect(client).not_to receive(:release_for_tag) allow(client).to receive(:release_assets).with(latest_release.url).and_return([]) @@ -757,7 +759,9 @@ def create_release(is_draft:, assets: [], name: nil) published_release = sawyer_resource_stub(id: 351_929_162, url: 'published-api-url', html_url: 'published-html-url', tag_name: test_version, draft: false) leftover_draft = sawyer_resource_stub(id: 352_002_205, url: 'draft-api-url', html_url: 'draft-html-url', tag_name: test_version, draft: true) - allow(client).to receive(:releases).with(test_repo).and_return([published_release, leftover_draft]) + # The leftover draft comes first, so that a lookup relying on the order the API happens to return the releases in + # would pick the wrong one. + allow(client).to receive(:releases).with(test_repo).and_return([leftover_draft, published_release]) allow(client).to receive(:release_assets).with(published_release.url).and_return([]) with_tmp_file(named: 'test-app.zip') do |file_path|