summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-07-01 15:48:14 +1200
committerThong Kuah <tkuah@gitlab.com>2019-07-01 15:48:14 +1200
commitfbd987a97717d14a23b39d69aae910c9e55a8a93 (patch)
treee34f24caaa59e86e0d4a1ca186d6aef947b8ea39
parent68fc36d81118530043008bc1ede760628668f3a9 (diff)
downloadgitlab-ce-fbd987a97717d14a23b39d69aae910c9e55a8a93.tar.gz
Test schema_version_check directlytest_schema_version_check_directly
Testing via db:migrate causes side-effects like setting ActiveRecord::Base.configurations and also it runs schema dump into db/schema.rb. Rather than keep up, we test schema_version_check directly
-rw-r--r--spec/tasks/migrate/schema_check_rake_spec.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/spec/tasks/migrate/schema_check_rake_spec.rb b/spec/tasks/migrate/schema_check_rake_spec.rb
index 72fb1363dfb..1097a43cd8a 100644
--- a/spec/tasks/migrate/schema_check_rake_spec.rb
+++ b/spec/tasks/migrate/schema_check_rake_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
require 'rake'
-describe 'schema_version_check rake task', :quarantine do
+describe 'schema_version_check rake task' do
include StubENV
before :all do
@@ -15,8 +15,6 @@ describe 'schema_version_check rake task', :quarantine do
end
before do
- # Stub out db tasks
- allow(ActiveRecord::Tasks::DatabaseTasks).to receive(:migrate).and_return(true)
allow(ActiveRecord::Migrator).to receive(:current_version).and_return(Gitlab::Database::MIN_SCHEMA_VERSION)
# Ensure our check can re-run each time
@@ -24,23 +22,23 @@ describe 'schema_version_check rake task', :quarantine do
end
it 'allows migrations on databases meeting the min schema version requirement' do
- expect { run_rake_task('db:migrate') }.not_to raise_error
+ expect { run_rake_task('schema_version_check') }.not_to raise_error
end
it 'raises an error when schema version is too old to migrate' do
allow(ActiveRecord::Migrator).to receive(:current_version).and_return(25)
- expect { run_rake_task('db:migrate') }.to raise_error(RuntimeError, /current database version is too old to be migrated/)
+ expect { run_rake_task('schema_version_check') }.to raise_error(RuntimeError, /current database version is too old to be migrated/)
end
it 'skips running validation when passed the skip env variable' do
stub_env('SKIP_SCHEMA_VERSION_CHECK', 'true')
allow(ActiveRecord::Migrator).to receive(:current_version).and_return(25)
- expect { run_rake_task('db:migrate') }.not_to raise_error
+ expect { run_rake_task('schema_version_check') }.not_to raise_error
end
it 'allows migrations on fresh databases' do
allow(ActiveRecord::Migrator).to receive(:current_version).and_return(0)
- expect { run_rake_task('db:migrate') }.not_to raise_error
+ expect { run_rake_task('schema_version_check') }.not_to raise_error
end
def run_rake_task(task_name)