diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-03-13 16:53:55 +0100 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-03-16 13:35:26 +0100 |
commit | d374d0be1af0e6cef4a150425cd73189f9960f54 (patch) | |
tree | 7414a0ad008ff73e33aff322bb33a0dcb9887bef /spec/models | |
parent | d4bb363f7c2747d15e496aee98bc7cc3fde77a77 (diff) | |
download | gitlab-ce-d374d0be1af0e6cef4a150425cd73189f9960f54.tar.gz |
Backwards-compat for migration specs.
The specs are based on a schema version that doesn't know about
`internal_ids` table. However, the actual code being execute relies on
it.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/internal_id_spec.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/models/internal_id_spec.rb b/spec/models/internal_id_spec.rb index 6d5a12c9d06..ef6db2daa95 100644 --- a/spec/models/internal_id_spec.rb +++ b/spec/models/internal_id_spec.rb @@ -12,9 +12,9 @@ describe InternalId do end describe '.generate_next' do - context 'in the absence of a record' do - subject { described_class.generate_next(issue, scope, usage, init) } + subject { described_class.generate_next(issue, scope, usage, init) } + context 'in the absence of a record' do it 'creates a record if not yet present' do expect { subject }.to change { described_class.count }.from(0).to(1) end @@ -47,6 +47,21 @@ describe InternalId do normalized = seq.map { |i| i - seq.min } expect(normalized).to eq((0..seq.size - 1).to_a) end + + context 'with an insufficient schema version' do + before do + described_class.reset_column_information + expect(ActiveRecord::Migrator).to receive(:current_version).and_return(InternalId::REQUIRED_SCHEMA_VERSION - 1) + end + + let(:init) { double('block') } + + it 'calculates next internal ids on the fly' do + val = rand(1..100) + expect(init).to receive(:call).with(issue).and_return(val) + expect(subject).to eq(val + 1) + end + end end describe '#increment_and_save!' do |