Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-03-13 18:53:55 +0300
committerAndreas Brandl <abrandl@gitlab.com>2018-03-16 15:35:26 +0300
commitd374d0be1af0e6cef4a150425cd73189f9960f54 (patch)
tree7414a0ad008ff73e33aff322bb33a0dcb9887bef /spec/models/internal_id_spec.rb
parentd4bb363f7c2747d15e496aee98bc7cc3fde77a77 (diff)
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/internal_id_spec.rb')
-rw-r--r--spec/models/internal_id_spec.rb19
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