0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/spec/jobs/call_discourse_hub_spec.rb
discoursebot 483b197ae9
FIX: Handle boolean values in version check response [backport 2026.1] (#38788)
Backport of #38786 to release/2026.1.

---

Since our update to redis gem v5.x in March 2025, the CallDiscourseHub
job has been raising an error because it fails to store
`TrueClass`/`FalseClass` values which are returned from the API. This
means that new-version emails were not sent.

We don't have any need to store the `critical: true|false` values, so
this commit slices the response to only include the strings we need. It
also adds a spec which would've caught the error.

---------

Co-authored-by: David Taylor <david@taylorhq.com>
2026-03-23 16:14:23 +00:00

49 lines
1.5 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe Jobs::CallDiscourseHub do
describe "#execute" do
context "when `include_in_discourse_discover setting` enabled" do
it "calls `discover_enrollment` method in DiscourseHub" do
SiteSetting.version_checks = false
SiteSetting.include_in_discourse_discover = true
DiscourseHub.stubs(:discover_enrollment).returns(true)
described_class.new.execute({})
end
end
context "when version_checks enabled" do
before do
SiteSetting.version_checks = true
SiteSetting.include_in_discourse_discover = false
end
it "stores missing versions from the hub response" do
DiscourseHub.stubs(:discourse_version_check).returns(
{
"latestVersion" => "2026.3.1",
"criticalUpdates" => false,
"missingVersionsCount" => 2,
"versions" => [
{ "version" => "2026.3.1", "notes" => "Latest release", "critical" => true },
{ "version" => "2026.2.5", "notes" => "Security patch", "critical" => false },
],
},
)
described_class.new.execute({})
expect(DiscourseUpdates).to have_attributes(
latest_version: "2026.3.1",
missing_versions_count: 2,
missing_versions:
contain_exactly(
{ "version" => "2026.3.1", "notes" => "Latest release" },
{ "version" => "2026.2.5", "notes" => "Security patch" },
),
)
end
end
end
end