diff options
author | Sean McGivern <sean@gitlab.com> | 2017-04-25 13:28:55 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-04-26 12:50:32 +0100 |
commit | 5069682d8ed892705ec1a933554cc4060e5691af (patch) | |
tree | e2f286cf4ebd2678acf845d066146854885126ab /spec/migrations/active_record | |
parent | 6dc424c949ab3de9395d821b05d2e1cc5f632ed2 (diff) | |
download | gitlab-ce-5069682d8ed892705ec1a933554cc4060e5691af.tar.gz |
Enable RSpec/FilePath copenable-spec-file-name-cop
- Ignore JS fixtures
- Ignore qa directory
- Rewrite concern specs to put concern name first
Diffstat (limited to 'spec/migrations/active_record')
-rw-r--r-- | spec/migrations/active_record/schema_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/migrations/active_record/schema_spec.rb b/spec/migrations/active_record/schema_spec.rb new file mode 100644 index 00000000000..e132529d8d8 --- /dev/null +++ b/spec/migrations/active_record/schema_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +# Check consistency of db/schema.rb version, migrations' timestamps, and the latest migration timestamp +# stored in the database's schema_migrations table. + +describe ActiveRecord::Schema do + let(:latest_migration_timestamp) do + migrations = Dir[Rails.root.join('db', 'migrate', '*'), Rails.root.join('db', 'post_migrate', '*')] + migrations.map { |migration| File.basename(migration).split('_').first.to_i }.max + 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+)/)[0].to_i + + expect(defined_schema_version).to eq(latest_migration_timestamp) + 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 +end |