diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-12-14 20:01:04 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-12-19 13:24:54 +0300 |
commit | 25ef6f51c9899cc26661a2daac7ca0d47b95d443 (patch) | |
tree | 18b1a6dce0d2f32cff459f514d1179931e920b4e /spec/support | |
parent | 0ff27ce05960598e5a1c0a1115180db0feeb689a (diff) |
Use fake application settings for migration tests
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/helpers/migrations_helpers.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/support/helpers/migrations_helpers.rb b/spec/support/helpers/migrations_helpers.rb index 5887c3eab74..cc1a28cb264 100644 --- a/spec/support/helpers/migrations_helpers.rb +++ b/spec/support/helpers/migrations_helpers.rb @@ -62,6 +62,22 @@ module MigrationsHelpers klass.reset_column_information end + # In some migration tests, we're using factories to create records, + # however those models might be depending on a schema version which + # doesn't have the columns we want in application_settings. + # In these cases, we'll need to use the fake application settings + # as if we have migrations pending + def use_fake_application_settings + # We stub this way because we can't stub on + # `current_application_settings` due to `method_missing` is + # depending on current_application_settings... + allow(ActiveRecord::Base.connection) + .to receive(:active?) + .and_return(false) + + stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') + end + def previous_migration migrations.each_cons(2) do |previous, migration| break previous if migration.name == described_class.name |