mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 23:48:45 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
42 lines
1.2 KiB
Ruby
42 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
require_dependency 'version'
|
|
|
|
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
|
|
let(: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
|