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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-22 18:09:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-22 18:09:49 +0300
commitf2dfd9ee819afb07bf11bd36a5f9d23009be0d39 (patch)
treeedd9468dc9c6c55f9882175fd83a1aadec22edf0 /spec/migrations
parent058c34839488502fcec48d805b83728f928a318c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/active_record/schema_spec.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/spec/migrations/active_record/schema_spec.rb b/spec/migrations/active_record/schema_spec.rb
index 086d6317c32..a3348424f47 100644
--- a/spec/migrations/active_record/schema_spec.rb
+++ b/spec/migrations/active_record/schema_spec.rb
@@ -2,27 +2,29 @@
require 'spec_helper'
-# Check consistency of db/schema.rb version, migrations' timestamps, and the latest migration timestamp
+# Check consistency of db/structure.sql version, migrations' timestamps, and the latest migration timestamp
# stored in the database's schema_migrations table.
describe ActiveRecord::Schema, schema: :latest do
- let(:latest_migration_timestamp) do
+ let(:all_migrations) do
migrations_paths = %w[db/migrate db/post_migrate]
.map { |path| Rails.root.join(*path, '*') }
migrations = Dir[*migrations_paths]
- migrations.map { |migration| File.basename(migration).split('_').first.to_i }.max
+ migrations.map { |migration| File.basename(migration).split('_').first.to_i }.sort
end
- it '> schema version equals last migration timestamp' do
- defined_schema_version = File.open(Rails.root.join('db', 'schema.rb')) do |file|
- file.find { |line| line =~ /ActiveRecord::Schema.define/ }
- end.match(/(\d{4}_\d{2}_\d{2}_\d{6})/)[0].to_i
-
- expect(defined_schema_version).to eq(latest_migration_timestamp)
+ let(:latest_migration_timestamp) do
+ all_migrations.max
end
it '> schema version should equal the latest migration timestamp stored in schema_migrations table' do
expect(latest_migration_timestamp).to eq(ActiveRecord::Migrator.current_version.to_i)
end
+
+ it 'the schema_migrations table contains all schema versions' do
+ versions = ActiveRecord::Base.connection.execute('SELECT version FROM schema_migrations ORDER BY version').map { |m| Integer(m['version']) }
+
+ expect(versions).to eq(all_migrations)
+ end
end