discourse/spec/requests/admin/versions_controller_spec.rb
Krzysztof Kotlarek 427d54b2b0 DEV: Upgrading Discourse to Zeitwerk (#8098)
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. 

We no longer need to use Rails "require_dependency" anywhere and instead can just use standard 
Ruby patterns to require files.

This is a far reaching change and we expect some followups here.
2019-10-02 14:01:53 +10:00

41 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe Admin::VersionsController do
before do
Jobs::VersionCheck.any_instance.stubs(:execute).returns(true)
DiscourseUpdates.stubs(:updated_at).returns(2.hours.ago)
DiscourseUpdates.stubs(:latest_version).returns('1.2.33')
DiscourseUpdates.stubs(:critical_updates_available?).returns(false)
end
it "is a subclass of AdminController" do
expect(Admin::VersionsController < Admin::AdminController).to eq(true)
end
context 'while logged in as an admin' do
fab!(:admin) { Fabricate(:admin) }
before do
sign_in(admin)
end
describe 'show' do
it 'should return the currently available version' do
get "/admin/version_check.json"
expect(response.status).to eq(200)
json = JSON.parse(response.body)
expect(json['latest_version']).to eq('1.2.33')
end
it "should return the installed version" do
get "/admin/version_check.json"
json = JSON.parse(response.body)
expect(response.status).to eq(200)
expect(json['installed_version']).to eq(Discourse::VERSION::STRING)
end
end
end
end