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 end
def last_installed_version=(arg) def last_installed_version=(arg)
Discourse.redis.set(last_installed_version, arg) Discourse.redis.set(last_installed_version_key, arg)
end end
def latest_version def latest_version
@ -70,7 +70,7 @@ module DiscourseUpdates
end end
def latest_version=(arg) def latest_version=(arg)
Discourse.redis.set(latest_version, arg) Discourse.redis.set(latest_version_key, arg)
end end
def missing_versions_count def missing_versions_count

View File

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