2013-02-06 03:16:51 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
require_dependency 'version'
|
|
|
|
|
|
|
|
describe Admin::VersionsController do
|
|
|
|
|
|
|
|
before do
|
2013-07-03 23:06:07 +08:00
|
|
|
DiscourseUpdates.stubs(:updated_at).returns(2.hours.ago)
|
2013-02-20 04:16:50 +08:00
|
|
|
DiscourseUpdates.stubs(:latest_version).returns('1.2.33')
|
2013-03-06 23:34:15 +08:00
|
|
|
DiscourseUpdates.stubs(:critical_updates_available?).returns(false)
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is a subclass of AdminController" do
|
|
|
|
(Admin::VersionsController < Admin::AdminController).should be_true
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'while logged in as an admin' do
|
|
|
|
before do
|
|
|
|
@user = log_in(:admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'show' do
|
2013-02-20 04:16:50 +08:00
|
|
|
subject { xhr :get, :show }
|
|
|
|
it { should be_success }
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2013-02-20 04:16:50 +08:00
|
|
|
it 'should return the currently available version' do
|
|
|
|
json = JSON.parse(subject.body)
|
|
|
|
json['latest_version'].should == '1.2.33'
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2013-02-20 04:16:50 +08:00
|
|
|
it "should return the installed version" do
|
|
|
|
json = JSON.parse(subject.body)
|
|
|
|
json['installed_version'].should == Discourse::VERSION::STRING
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|