2019-03-02 22:35:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
RSpec.shared_examples 'cluster application version specs' do |application_name|
|
2019-03-02 22:35:43 +05:30
|
|
|
describe 'update_available?' do
|
2020-04-08 14:13:33 +05:30
|
|
|
let_it_be(:cluster) { create(:cluster, :provided_by_gcp) }
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
let(:version) { '0.0.0' }
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
subject { build(application_name, :installed, version: version, cluster: cluster).update_available? }
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
context 'version is not the same as VERSION' do
|
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'version is the same as VERSION' do
|
2020-04-08 14:13:33 +05:30
|
|
|
let(:application) { build(application_name, cluster: cluster) }
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:version) { application.class.const_get(:VERSION, false) }
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
describe '#make_installed' do
|
|
|
|
subject { create(application_name, :installing) }
|
|
|
|
|
|
|
|
it 'sets the correct version of the application' do
|
|
|
|
subject.update!(version: '0.0.0')
|
|
|
|
|
|
|
|
subject.make_installed!
|
|
|
|
|
|
|
|
subject.reload
|
|
|
|
|
|
|
|
expect(subject.version).to eq(subject.class.const_get(:VERSION, false))
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'application is updating' do
|
|
|
|
subject { create(application_name, :updating) }
|
|
|
|
|
|
|
|
it 'updates the version of the application' do
|
|
|
|
subject.update!(version: '0.0.0')
|
|
|
|
|
|
|
|
subject.make_installed!
|
|
|
|
|
|
|
|
subject.reload
|
|
|
|
|
|
|
|
expect(subject.version).to eq(subject.class.const_get(:VERSION, false))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|