2017-01-12 09:00:06 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe VersionCheckHelper do
|
|
|
|
describe '#version_status_badge' do
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'returns nil if not dev environment and not enabled' do
|
2017-01-12 09:00:06 -05:00
|
|
|
allow(Rails.env).to receive(:production?) { false }
|
2018-02-02 13:39:55 -05:00
|
|
|
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:version_check_enabled) { false }
|
2017-01-12 09:00:06 -05:00
|
|
|
|
|
|
|
expect(helper.version_status_badge).to be(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when production and enabled' do
|
|
|
|
before do
|
|
|
|
allow(Rails.env).to receive(:production?) { true }
|
2018-02-02 13:39:55 -05:00
|
|
|
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:version_check_enabled) { true }
|
2018-12-14 12:47:49 -05:00
|
|
|
allow(VersionCheck).to receive(:url) { 'https://version.host.com/check.svg?gitlab_info=xxx' }
|
2017-01-12 09:00:06 -05:00
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'returns an image tag' do
|
2018-12-14 12:47:49 -05:00
|
|
|
expect(helper.version_status_badge).to start_with('<img')
|
2017-01-12 09:00:06 -05:00
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'has a js prefixed css class' do
|
2018-12-14 12:47:49 -05:00
|
|
|
expect(helper.version_status_badge)
|
|
|
|
.to match(/class="js-version-status-badge lazy"/)
|
2017-01-12 09:00:06 -05:00
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'has a VersionCheck url as the src' do
|
2018-12-14 12:47:49 -05:00
|
|
|
expect(helper.version_status_badge)
|
|
|
|
.to include(%{src="https://version.host.com/check.svg?gitlab_info=xxx"})
|
2017-01-12 09:00:06 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|