discourse/spec/requests/admin/versions_controller_spec.rb
David Taylor c9dab6fd08
DEV: Automatically require 'rails_helper' in all specs (#16077)
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors.

By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
2022-03-01 17:50:50 +00:00

39 lines
1.1 KiB
Ruby

# frozen_string_literal: true
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 = response.parsed_body
expect(json['latest_version']).to eq('1.2.33')
end
it "should return the installed version" do
get "/admin/version_check.json"
json = response.parsed_body
expect(response.status).to eq(200)
expect(json['installed_version']).to eq(Discourse::VERSION::STRING)
end
end
end
end