discourse/spec/controllers/admin/versions_controller_spec.rb

38 lines
1.0 KiB
Ruby
Raw Normal View History

2016-04-01 05:33:25 +08:00
require 'rails_helper'
2013-02-06 03:16:51 +08:00
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)
2013-02-06 03:16:51 +08:00
end
it "is a subclass of AdminController" do
2015-01-10 01:04:02 +08:00
expect(Admin::VersionsController < Admin::AdminController).to eq(true)
2013-02-06 03:16:51 +08:00
end
context 'while logged in as an admin' do
before do
@user = log_in(:admin)
end
describe 'show' do
subject { xhr :get, :show }
2015-01-10 01:04:02 +08:00
it { is_expected.to be_success }
2013-02-06 03:16:51 +08:00
it 'should return the currently available version' do
json = JSON.parse(subject.body)
2015-01-10 01:04:02 +08:00
expect(json['latest_version']).to eq('1.2.33')
2013-02-06 03:16:51 +08:00
end
it "should return the installed version" do
json = JSON.parse(subject.body)
2015-01-10 01:04:02 +08:00
expect(json['installed_version']).to eq(Discourse::VERSION::STRING)
2013-02-06 03:16:51 +08:00
end
end
end
2013-11-06 02:04:47 +08:00
end