mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
REFACTOR: Avoid duplicated logic on server and client.
This commit is contained in:
parent
c390169b71
commit
f7642e076d
6 changed files with 64 additions and 56 deletions
|
@ -14,7 +14,7 @@ describe DiscourseUpdates do
|
|||
Jobs::VersionCheck.any_instance.stubs(:execute).returns(true)
|
||||
end
|
||||
|
||||
subject { DiscourseUpdates.check_version.instance_values }
|
||||
subject { DiscourseUpdates.check_version }
|
||||
|
||||
context 'version check was done at the current installed version' do
|
||||
before do
|
||||
|
@ -26,14 +26,15 @@ describe DiscourseUpdates do
|
|||
before { stub_data(Discourse::VERSION::STRING, 0, false, 12.hours.ago) }
|
||||
|
||||
it 'returns all the version fields' do
|
||||
expect(subject['latest_version']).to eq(Discourse::VERSION::STRING)
|
||||
expect(subject['missing_versions_count']).to eq(0)
|
||||
expect(subject['critical_updates']).to eq(false)
|
||||
expect(subject['installed_version']).to eq(Discourse::VERSION::STRING)
|
||||
expect(subject.latest_version).to eq(Discourse::VERSION::STRING)
|
||||
expect(subject.missing_versions_count).to eq(0)
|
||||
expect(subject.critical_updates).to eq(false)
|
||||
expect(subject.installed_version).to eq(Discourse::VERSION::STRING)
|
||||
expect(subject.stale_data).to eq(false)
|
||||
end
|
||||
|
||||
it 'returns the timestamp of the last version check' do
|
||||
expect(subject['updated_at']).to be_within_one_second_of(12.hours.ago)
|
||||
expect(subject.updated_at).to be_within_one_second_of(12.hours.ago)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,14 +42,14 @@ describe DiscourseUpdates do
|
|||
before { stub_data('0.9.0', 2, false, 12.hours.ago) }
|
||||
|
||||
it 'returns all the version fields' do
|
||||
expect(subject['latest_version']).to eq('0.9.0')
|
||||
expect(subject['missing_versions_count']).to eq(2)
|
||||
expect(subject['critical_updates']).to eq(false)
|
||||
expect(subject['installed_version']).to eq(Discourse::VERSION::STRING)
|
||||
expect(subject.latest_version).to eq('0.9.0')
|
||||
expect(subject.missing_versions_count).to eq(2)
|
||||
expect(subject.critical_updates).to eq(false)
|
||||
expect(subject.installed_version).to eq(Discourse::VERSION::STRING)
|
||||
end
|
||||
|
||||
it 'returns the timestamp of the last version check' do
|
||||
expect(subject['updated_at']).to be_within_one_second_of(12.hours.ago)
|
||||
expect(subject.updated_at).to be_within_one_second_of(12.hours.ago)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -57,18 +58,18 @@ describe DiscourseUpdates do
|
|||
before { stub_data(nil, nil, false, nil) }
|
||||
|
||||
it 'returns the installed version' do
|
||||
expect(subject['installed_version']).to eq(Discourse::VERSION::STRING)
|
||||
expect(subject.installed_version).to eq(Discourse::VERSION::STRING)
|
||||
end
|
||||
|
||||
it 'indicates that version check has not been performed' do
|
||||
expect(subject).to have_key('updated_at')
|
||||
expect(subject['updated_at']).to eq(nil)
|
||||
expect(subject.updated_at).to eq(nil)
|
||||
expect(subject.stale_data).to eq(true)
|
||||
end
|
||||
|
||||
it 'does not return latest version info' do
|
||||
expect(subject).not_to have_key('latest_version')
|
||||
expect(subject).not_to have_key('missing_versions_count')
|
||||
expect(subject).not_to have_key('critical_updates')
|
||||
expect(subject.latest_version).to eq(nil)
|
||||
expect(subject.missing_versions_count).to eq(nil)
|
||||
expect(subject.critical_updates).to eq(nil)
|
||||
end
|
||||
|
||||
it 'queues a version check' do
|
||||
|
@ -87,11 +88,11 @@ describe DiscourseUpdates do
|
|||
end
|
||||
|
||||
it 'reports 0 missing versions' do
|
||||
expect(subject['missing_versions_count']).to eq(0)
|
||||
expect(subject.missing_versions_count).to eq(0)
|
||||
end
|
||||
|
||||
it 'reports that a version check will be run soon' do
|
||||
expect(subject['version_check_pending']).to eq(true)
|
||||
expect(subject.version_check_pending).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -119,11 +120,11 @@ describe DiscourseUpdates do
|
|||
end
|
||||
|
||||
it 'reports 0 missing versions' do
|
||||
expect(subject['missing_versions_count']).to eq(0)
|
||||
expect(subject.missing_versions_count).to eq(0)
|
||||
end
|
||||
|
||||
it 'reports that a version check will be run soon' do
|
||||
expect(subject['version_check_pending']).to eq(true)
|
||||
expect(subject.version_check_pending).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue