FIX: Regression introduced in #14715 (#14842)

* FIX: Regression introduced in #14715

Wrong method names were used to get Redis keys.

* DEV: Remove more stubs
This commit is contained in:
Dan Ungureanu 2021-11-09 08:20:09 +02:00 committed by GitHub
parent 337ef60303
commit 46fed1303f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 18 deletions

View File

@ -62,7 +62,7 @@ module DiscourseUpdates
end
def last_installed_version=(arg)
Discourse.redis.set(last_installed_version, arg)
Discourse.redis.set(last_installed_version_key, arg)
end
def latest_version
@ -70,7 +70,7 @@ module DiscourseUpdates
end
def latest_version=(arg)
Discourse.redis.set(latest_version, arg)
Discourse.redis.set(latest_version_key, arg)
end
def missing_versions_count

View File

@ -3,27 +3,18 @@
require 'rails_helper'
describe DiscourseUpdates do
let(:latest_version_key) { DiscourseUpdates.send(:latest_version_key) }
let(:missing_versions_count_key) { DiscourseUpdates.send(:missing_versions_count_key) }
let(:critical_updates_available_key) { DiscourseUpdates.send(:critical_updates_available_key) }
let(:updated_at_key) { DiscourseUpdates.send(:updated_at_key) }
def stub_data(latest, missing, critical, updated_at)
Discourse.redis.set(latest_version_key, latest)
Discourse.redis.set(missing_versions_count_key, missing)
Discourse.redis.set(critical_updates_available_key, critical)
Discourse.redis.set(updated_at_key, updated_at)
end
before do
Jobs::VersionCheck.any_instance.stubs(:execute).returns(true)
DiscourseUpdates.latest_version = latest
DiscourseUpdates.missing_versions_count = missing
DiscourseUpdates.critical_updates_available = critical
DiscourseUpdates.updated_at = updated_at
end
subject { DiscourseUpdates.check_version }
context 'version check was done at the current installed version' do
before do
DiscourseUpdates.stubs(:last_installed_version).returns(Discourse::VERSION::STRING)
DiscourseUpdates.last_installed_version = Discourse::VERSION::STRING
end
context 'a good version check request happened recently' do
@ -119,7 +110,7 @@ describe DiscourseUpdates do
context 'version check was done at a different installed version' do
before do
DiscourseUpdates.stubs(:last_installed_version).returns('0.9.1')
DiscourseUpdates.last_installed_version = '0.9.1'
end
shared_examples "when last_installed_version is old" do
@ -215,7 +206,7 @@ describe DiscourseUpdates do
]
Discourse.redis.set('new_features', MultiJson.dump(features_with_versions))
DiscourseUpdates.stubs(:last_installed_version).returns("2.7.0.beta2")
DiscourseUpdates.last_installed_version = "2.7.0.beta2"
result = DiscourseUpdates.new_features
expect(result.length).to eq(3)