Skip to content

Commit 7b44331

Browse files
authored
Merge pull request #25 from zendesk/testdouble/update_for_rails6
update for rails 6
2 parents 98f9903 + 9efdd03 commit 7b44331

File tree

10 files changed

+116
-50
lines changed

10 files changed

+116
-50
lines changed

.travis.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ script: "bundle exec rake test"
22
bundler_args: ""
33
cache: bundler
44
sudo: false
5+
before_install:
6+
- gem install bundler
57
branches:
68
only: master
79
rvm:
8-
- 2.2
9-
- 2.3
1010
- 2.4
11+
- 2.5
12+
- 2.6
13+
- ruby-head
1114
gemfile:
12-
- gemfiles/rails3.2.gemfile
1315
- gemfiles/rails4.2.gemfile
1416
- gemfiles/rails5.0.gemfile
1517
- gemfiles/rails5.1.gemfile
1618
- gemfiles/rails5.2.gemfile
19+
- gemfiles/rails6.0.gemfile
1720
matrix:
1821
allow_failures:
19-
gemfile: gemfiles/rails5.2.gemfile
22+
- rvm: ruby-head
2023
exclude:
2124
- rvm: 2.4
22-
gemfile: gemfiles/rails3.2.gemfile
23-
- rvm: 2.4
24-
gemfile: gemfiles/rails4.2.gemfile
25+
gemfile: gemfiles/rails6.0.gemfile

Gemfile.lock

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,38 @@ PATH
22
remote: .
33
specs:
44
migration_tools (1.5.0)
5-
activerecord (>= 3.2.6, < 6.0)
5+
activerecord (>= 3.2.6, < 6.1)
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
activemodel (5.2.0)
11-
activesupport (= 5.2.0)
12-
activerecord (5.2.0)
13-
activemodel (= 5.2.0)
14-
activesupport (= 5.2.0)
15-
arel (>= 9.0)
16-
activesupport (5.2.0)
10+
activemodel (6.0.2.1)
11+
activesupport (= 6.0.2.1)
12+
activerecord (6.0.2.1)
13+
activemodel (= 6.0.2.1)
14+
activesupport (= 6.0.2.1)
15+
activesupport (6.0.2.1)
1716
concurrent-ruby (~> 1.0, >= 1.0.2)
1817
i18n (>= 0.7, < 2)
1918
minitest (~> 5.1)
2019
tzinfo (~> 1.1)
21-
arel (9.0.0)
22-
bump (0.5.3)
23-
concurrent-ruby (1.0.5)
24-
i18n (1.0.1)
20+
zeitwerk (~> 2.2)
21+
bump (0.9.0)
22+
concurrent-ruby (1.1.6)
23+
i18n (1.8.2)
2524
concurrent-ruby (~> 1.0)
26-
iconv (1.0.4)
27-
metaclass (0.0.4)
28-
minitest (5.8.3)
25+
iconv (1.0.8)
26+
minitest (5.14.0)
2927
minitest-rg (5.2.0)
3028
minitest (~> 5.0)
31-
mocha (1.1.0)
32-
metaclass (~> 0.0.1)
33-
rake (10.4.2)
34-
sqlite3 (1.3.11)
29+
mocha (1.11.2)
30+
rake (13.0.1)
31+
sqlite3 (1.4.2)
3532
thread_safe (0.3.6)
36-
tzinfo (1.2.5)
33+
tzinfo (1.2.6)
3734
thread_safe (~> 0.1)
38-
wwtd (1.3.0)
35+
wwtd (1.4.1)
36+
zeitwerk (2.3.0)
3937

4038
PLATFORMS
4139
ruby
@@ -52,4 +50,4 @@ DEPENDENCIES
5250
wwtd
5351

5452
BUNDLED WITH
55-
1.16.2
53+
2.1.4

gemfiles/rails4.2.gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
migration_tools (1.4.0)
5-
activerecord (>= 3.2.6, < 6.0)
4+
migration_tools (1.5.0)
5+
activerecord (>= 3.2.6, < 6.1)
66

77
GEM
88
remote: https://rubygems.org/
@@ -55,4 +55,4 @@ DEPENDENCIES
5555
wwtd
5656

5757
BUNDLED WITH
58-
1.16.2
58+
1.17.3

gemfiles/rails5.0.gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
migration_tools (1.4.0)
5-
activerecord (>= 3.2.6, < 6.0)
4+
migration_tools (1.5.0)
5+
activerecord (>= 3.2.6, < 6.1)
66

77
GEM
88
remote: https://rubygems.org/
@@ -50,4 +50,4 @@ DEPENDENCIES
5050
wwtd
5151

5252
BUNDLED WITH
53-
1.16.2
53+
1.17.3

gemfiles/rails5.1.gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
migration_tools (1.4.0)
5-
activerecord (>= 3.2.6, < 6.0)
4+
migration_tools (1.5.0)
5+
activerecord (>= 3.2.6, < 6.1)
66

77
GEM
88
remote: https://rubygems.org/
@@ -50,4 +50,4 @@ DEPENDENCIES
5050
wwtd
5151

5252
BUNDLED WITH
53-
1.16.2
53+
1.17.3

gemfiles/rails5.2.gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
migration_tools (1.4.0)
5-
activerecord (>= 3.2.6, < 6.0)
4+
migration_tools (1.5.0)
5+
activerecord (>= 3.2.6, < 6.1)
66

77
GEM
88
remote: https://rubygems.org/
@@ -51,4 +51,4 @@ DEPENDENCIES
5151
wwtd
5252

5353
BUNDLED WITH
54-
1.16.2
54+
1.17.3

gemfiles/rails6.0.gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source "https://rubygems.org"
2+
3+
gem "activerecord", "~> 6.0.0"
4+
5+
gemspec path: "../"

gemfiles/rails6.0.gemfile.lock

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
PATH
2+
remote: ..
3+
specs:
4+
migration_tools (1.5.0)
5+
activerecord (>= 3.2.6, < 6.1)
6+
7+
GEM
8+
remote: https://rubygems.org/
9+
specs:
10+
activemodel (6.0.2.1)
11+
activesupport (= 6.0.2.1)
12+
activerecord (6.0.2.1)
13+
activemodel (= 6.0.2.1)
14+
activesupport (= 6.0.2.1)
15+
activesupport (6.0.2.1)
16+
concurrent-ruby (~> 1.0, >= 1.0.2)
17+
i18n (>= 0.7, < 2)
18+
minitest (~> 5.1)
19+
tzinfo (~> 1.1)
20+
zeitwerk (~> 2.2)
21+
bump (0.9.0)
22+
concurrent-ruby (1.1.6)
23+
i18n (1.8.2)
24+
concurrent-ruby (~> 1.0)
25+
minitest (5.14.0)
26+
minitest-rg (5.2.0)
27+
minitest (~> 5.0)
28+
mocha (1.11.2)
29+
rake (13.0.1)
30+
sqlite3 (1.4.2)
31+
thread_safe (0.3.6)
32+
tzinfo (1.2.6)
33+
thread_safe (~> 0.1)
34+
wwtd (1.4.1)
35+
zeitwerk (2.3.0)
36+
37+
PLATFORMS
38+
ruby
39+
40+
DEPENDENCIES
41+
activerecord (~> 6.0.0)
42+
bump
43+
migration_tools!
44+
minitest
45+
minitest-rg
46+
mocha
47+
rake
48+
sqlite3
49+
wwtd
50+
51+
BUNDLED WITH
52+
2.1.4

lib/migration_tools/tasks.rb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,25 @@ def migrations_paths
2828
end
2929

3030
def migrator(target_version = nil)
31-
if ActiveRecord::VERSION::MAJOR > 3
32-
migrations = if defined?(::ActiveRecord::MigrationContext)
33-
ActiveRecord::MigrationContext.new(migrations_paths).migrations
34-
else
35-
ActiveRecord::Migrator.migrations(migrations_paths)
36-
end
37-
ActiveRecord::Migrator.new(:up, migrations, target_version)
31+
if ActiveRecord::VERSION::MAJOR >= 6
32+
migrate_up(ActiveRecord::MigrationContext.new(
33+
migrations_paths,
34+
ActiveRecord::SchemaMigration
35+
).migrations, target_version)
36+
elsif ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 2
37+
migrate_up(ActiveRecord::MigrationContext.new(migrations_paths).migrations, target_version)
38+
elsif ActiveRecord::VERSION::MAJOR > 3
39+
migrate_up(ActiveRecord::Migrator.migrations(migrations_paths), target_version)
3840
else
39-
ActiveRecord::Migrator.new(:up, migrations_paths, target_version)
41+
migrate_up(migrations_paths, target_version)
42+
end
43+
end
44+
45+
def migrate_up(migrations, target_version)
46+
if ActiveRecord::VERSION::MAJOR >= 6
47+
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version)
48+
else
49+
ActiveRecord::Migrator.new(:up, migrations, target_version)
4050
end
4151
end
4252

migration_tools.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Gem::Specification.new "migration_tools", "1.5.0" do |s|
77
s.files = `git ls-files lib`.split("\n")
88
s.license = "Apache-2.0"
99

10-
s.add_runtime_dependency "activerecord", '>= 3.2.6', '< 6.0'
10+
s.add_runtime_dependency "activerecord", '>= 3.2.6', '< 6.1'
1111

1212
s.add_development_dependency "rake"
1313
s.add_development_dependency "bump"

0 commit comments

Comments
 (0)