2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-11 05:41:23 -04:00
|
|
|
require 'rails_helper'
|
2013-02-05 14:16:51 -05:00
|
|
|
require_dependency 'version'
|
|
|
|
|
|
|
|
describe Admin::VersionsController do
|
|
|
|
|
|
|
|
before do
|
2013-11-04 12:51:01 -05:00
|
|
|
Jobs::VersionCheck.any_instance.stubs(:execute).returns(true)
|
2013-07-03 11:06:07 -04:00
|
|
|
DiscourseUpdates.stubs(:updated_at).returns(2.hours.ago)
|
2013-02-19 15:16:50 -05:00
|
|
|
DiscourseUpdates.stubs(:latest_version).returns('1.2.33')
|
2013-03-06 10:34:15 -05:00
|
|
|
DiscourseUpdates.stubs(:critical_updates_available?).returns(false)
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is a subclass of AdminController" do
|
2015-01-09 12:04:02 -05:00
|
|
|
expect(Admin::VersionsController < Admin::AdminController).to eq(true)
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'while logged in as an admin' do
|
2019-05-06 23:12:20 -04:00
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
2013-02-05 14:16:51 -05:00
|
|
|
before do
|
2018-06-11 00:35:05 -04:00
|
|
|
sign_in(admin)
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'show' do
|
2013-02-19 15:16:50 -05:00
|
|
|
it 'should return the currently available version' do
|
2018-06-11 00:35:05 -04:00
|
|
|
get "/admin/version_check.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
json = JSON.parse(response.body)
|
2015-01-09 12:04:02 -05:00
|
|
|
expect(json['latest_version']).to eq('1.2.33')
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
2013-02-19 15:16:50 -05:00
|
|
|
it "should return the installed version" do
|
2018-06-11 00:35:05 -04:00
|
|
|
get "/admin/version_check.json"
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|
expect(response.status).to eq(200)
|
2015-01-09 12:04:02 -05:00
|
|
|
expect(json['installed_version']).to eq(Discourse::VERSION::STRING)
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-11-05 13:04:47 -05:00
|
|
|
end
|