Add version checking that shows on the admin dashboard

This commit is contained in:
Neil Lalonde
2013-02-19 15:16:50 -05:00
parent bb1156cee1
commit c0371ff427
16 changed files with 195 additions and 48 deletions

View File

@ -4,7 +4,8 @@ require_dependency 'version'
describe Admin::VersionsController do
before do
RestClient.stubs(:get).returns( {success: 'OK', version: '1.2.33'}.to_json )
DiscourseUpdates.stubs(:latest_version).returns('1.2.33')
DiscourseUpdates.stubs(:critical_update_available?).returns(false)
end
it "is a subclass of AdminController" do
@ -17,38 +18,17 @@ describe Admin::VersionsController do
end
describe 'show' do
context 'when discourse_org_access_key is set' do
before do
SiteSetting.stubs(:discourse_org_access_key).returns('asdf')
end
subject { xhr :get, :show }
it { should be_success }
subject { xhr :get, :show }
it { should be_success }
it 'should return the currently available version' do
json = JSON.parse(subject.body)
json['latest_version'].should == '1.2.33'
end
it "should return the installed version" do
json = JSON.parse(subject.body)
json['installed_version'].should == Discourse::VERSION::STRING
end
it 'should return the currently available version' do
json = JSON.parse(subject.body)
json['latest_version'].should == '1.2.33'
end
context 'when discourse_org_access_key is blank' do
subject { xhr :get, :show }
it { should be_success }
it 'should return the installed version as the currently available version' do
json = JSON.parse(subject.body)
json['latest_version'].should == Discourse::VERSION::STRING
end
it "should return the installed version" do
json = JSON.parse(subject.body)
json['installed_version'].should == Discourse::VERSION::STRING
end
it "should return the installed version" do
json = JSON.parse(subject.body)
json['installed_version'].should == Discourse::VERSION::STRING
end
end
end