92 lines
3.5 KiB
Diff
92 lines
3.5 KiB
Diff
|
|
From b310986f9a3b7547c98e54db97600f8128e28ff5 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Elliot Winkler <elliot.winkler@gmail.com>
|
||
|
|
Date: Thu, 28 Sep 2017 00:50:32 -0500
|
||
|
|
Subject: [PATCH] Use correct migration class in acceptance tests
|
||
|
|
|
||
|
|
In Rails 5.0, migration classes changed so that they were versioned:
|
||
|
|
instead of inheriting from `ActiveRecord::Migration`, you inherited from
|
||
|
|
`ActiveRecord::Migration[5.0]`. The old way wasn't removed, however --
|
||
|
|
that is, until Rails 5.1. Hence, our acceptance tests that use the old
|
||
|
|
style no longer work under the 5.1 Appraisal.
|
||
|
|
---
|
||
|
|
.../multiple_libraries_integration_spec.rb | 2 +-
|
||
|
|
spec/acceptance/rails_integration_spec.rb | 2 +-
|
||
|
|
spec/support/acceptance/helpers.rb | 2 ++
|
||
|
|
.../helpers/rails_migration_helpers.rb | 21 +++++++++++++++++++
|
||
|
|
4 files changed, 25 insertions(+), 2 deletions(-)
|
||
|
|
create mode 100644 spec/support/acceptance/helpers/rails_migration_helpers.rb
|
||
|
|
|
||
|
|
diff --git a/spec/acceptance/multiple_libraries_integration_spec.rb b/spec/acceptance/multiple_libraries_integration_spec.rb
|
||
|
|
index d03babac..376e1291 100644
|
||
|
|
--- a/spec/acceptance/multiple_libraries_integration_spec.rb
|
||
|
|
+++ b/spec/acceptance/multiple_libraries_integration_spec.rb
|
||
|
|
@@ -5,7 +5,7 @@
|
||
|
|
create_rails_application
|
||
|
|
|
||
|
|
write_file 'db/migrate/1_create_users.rb', <<-FILE
|
||
|
|
- class CreateUsers < ActiveRecord::Migration
|
||
|
|
+ class CreateUsers < #{migration_class_name}
|
||
|
|
def self.up
|
||
|
|
create_table :users do |t|
|
||
|
|
t.string :name
|
||
|
|
diff --git a/spec/acceptance/rails_integration_spec.rb b/spec/acceptance/rails_integration_spec.rb
|
||
|
|
index f18a6725..79d6e197 100644
|
||
|
|
--- a/spec/acceptance/rails_integration_spec.rb
|
||
|
|
+++ b/spec/acceptance/rails_integration_spec.rb
|
||
|
|
@@ -5,7 +5,7 @@
|
||
|
|
create_rails_application
|
||
|
|
|
||
|
|
write_file 'db/migrate/1_create_users.rb', <<-FILE
|
||
|
|
- class CreateUsers < ActiveRecord::Migration
|
||
|
|
+ class CreateUsers < #{migration_class_name}
|
||
|
|
def self.up
|
||
|
|
create_table :users do |t|
|
||
|
|
t.string :name
|
||
|
|
diff --git a/spec/support/acceptance/helpers.rb b/spec/support/acceptance/helpers.rb
|
||
|
|
index 2b5160d6..c09a1dfa 100644
|
||
|
|
--- a/spec/support/acceptance/helpers.rb
|
||
|
|
+++ b/spec/support/acceptance/helpers.rb
|
||
|
|
@@ -3,6 +3,7 @@
|
||
|
|
require_relative 'helpers/command_helpers'
|
||
|
|
require_relative 'helpers/gem_helpers'
|
||
|
|
require_relative 'helpers/n_unit_helpers'
|
||
|
|
+require_relative 'helpers/rails_migration_helpers'
|
||
|
|
require_relative 'helpers/rails_version_helpers'
|
||
|
|
require_relative 'helpers/rspec_helpers'
|
||
|
|
require_relative 'helpers/ruby_version_helpers'
|
||
|
|
@@ -23,6 +24,7 @@ def self.configure_example_group(example_group)
|
||
|
|
include CommandHelpers
|
||
|
|
include GemHelpers
|
||
|
|
include NUnitHelpers
|
||
|
|
+ include RailsMigrationHelpers
|
||
|
|
include RailsVersionHelpers
|
||
|
|
include RspecHelpers
|
||
|
|
include RubyVersionHelpers
|
||
|
|
diff --git a/spec/support/acceptance/helpers/rails_migration_helpers.rb b/spec/support/acceptance/helpers/rails_migration_helpers.rb
|
||
|
|
new file mode 100644
|
||
|
|
index 00000000..211bc01b
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/spec/support/acceptance/helpers/rails_migration_helpers.rb
|
||
|
|
@@ -0,0 +1,21 @@
|
||
|
|
+require_relative 'gem_helpers'
|
||
|
|
+
|
||
|
|
+module AcceptanceTests
|
||
|
|
+ module RailsMigrationHelpers
|
||
|
|
+ include RailsVersionHelpers
|
||
|
|
+
|
||
|
|
+ def migration_class_name
|
||
|
|
+ if rails_version >= 5
|
||
|
|
+ "ActiveRecord::Migration[#{rails_version_for_migration}]"
|
||
|
|
+ else
|
||
|
|
+ 'ActiveRecord::Migration'
|
||
|
|
+ end
|
||
|
|
+ end
|
||
|
|
+
|
||
|
|
+ private
|
||
|
|
+
|
||
|
|
+ def rails_version_for_migration
|
||
|
|
+ rails_version.to_s.split('.')[0..1].join('.')
|
||
|
|
+ end
|
||
|
|
+ end
|
||
|
|
+end
|