diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-26 10:29:12 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-26 10:29:12 +0200 |
commit | f7aba153164618522232c912eb833bd7596f5f53 (patch) | |
tree | d73170b595cca79ad5a2d45a043b98ff985dd0bd /spec/migrations/migrate_pipeline_stages_spec.rb | |
parent | acc22a8422cd1471819510aa375c455b5ea009c5 (diff) | |
download | gitlab-ce-f7aba153164618522232c912eb833bd7596f5f53.tar.gz |
Make migration specs by using migrator in around hook
Diffstat (limited to 'spec/migrations/migrate_pipeline_stages_spec.rb')
-rw-r--r-- | spec/migrations/migrate_pipeline_stages_spec.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/spec/migrations/migrate_pipeline_stages_spec.rb b/spec/migrations/migrate_pipeline_stages_spec.rb index 038e5d7fc6b..d6d26ab52ad 100644 --- a/spec/migrations/migrate_pipeline_stages_spec.rb +++ b/spec/migrations/migrate_pipeline_stages_spec.rb @@ -2,10 +2,23 @@ require 'spec_helper' require Rails.root.join('db', 'migrate', '20170525132202_migrate_pipeline_stages.rb') describe MigratePipelineStages, :migration, schema: 20170523091700 do + ## + # TODO, extract to migrations helper + # def table(name) Class.new(ActiveRecord::Base) { self.table_name = name } end + def migrations_paths + ActiveRecord::Migrator.migrations_paths + end + + def migrate! + ActiveRecord::Migrator.up(migrations_paths) do |migration| + migration.name == described_class.name + end + end + ## # Create test data # @@ -13,10 +26,10 @@ describe MigratePipelineStages, :migration, schema: 20170523091700 do table(:ci_pipelines).create!(ref: 'master', sha: 'adf43c3a') end - it 'correctly migrates pipeline stages' do + it 'correctly migrates pipeline stages' do |migration, meta| expect(ActiveRecord::Base.connection.table_exists?('ci_stages')).to eq false - described_class.new.migrate(:up) + migrate! expect(ActiveRecord::Base.connection.table_exists?('ci_stages')).to eq true end |