Skip to content

Commit

Permalink
Merge pull request #329 from voormedia/kerrizor/add-rails-6-support
Browse files Browse the repository at this point in the history
Add Rails 6 support
  • Loading branch information
kerrizor committed May 14, 2019
2 parents d4ad8f2 + 77a2c9f commit 360fc51
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .travis.yml
Expand Up @@ -11,6 +11,7 @@ gemfile:
- gemfiles/Gemfile-rails.5.0.x
- gemfiles/Gemfile-rails.5.1.x
- gemfiles/Gemfile-rails.5.2.x
- gemfiles/Gemfile-rails.6.0.x
- gemfiles/Gemfile-rails.edge
before_install:
- gem install bundler -v '< 2'
Expand All @@ -22,4 +23,17 @@ matrix:
- rvm: jruby
- gemfile: gemfiles/Gemfile-rails.edge
fast_finish: true
exclude:
- rvm: 2.2
gemfile: gemfiles/Gemfile-rails.6.0.x
- rvm: 2.2
gemfile: gemfiles/Gemfile-rails.edge
- rvm: 2.3
gemfile: gemfiles/Gemfile-rails.6.0.x
- rvm: 2.3
gemfile: gemfiles/Gemfile-rails.edge
- rvm: 2.4
gemfile: gemfiles/Gemfile-rails.6.0.x
- rvm: 2.4
gemfile: gemfiles/Gemfile-rails.edge
cache: bundler
21 changes: 21 additions & 0 deletions gemfiles/Gemfile-rails.6.0.x
@@ -0,0 +1,21 @@
source "http://rubygems.org"

gemspec :path => ".."

gem "activerecord", "~> 6.0.0rc1"

group :development do
gem 'mocha'
gem "rake"
gem "yard"

platforms :ruby do
gem "sqlite3", '~> 1.4'
gem "redcarpet"
end

platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter"
gem "jruby-openssl", :require => false # Silence openssl warnings.
end
end
1 change: 1 addition & 0 deletions rails-erd.gemspec
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "choice", "~> 0.2.0"

s.add_development_dependency "pry"
s.add_development_dependency "pry-nav"

s.files = `git ls-files -- {bin,lib,test}/* CHANGES.rdoc LICENSE Rakefile README.md`.split("\n")
s.test_files = `git ls-files -- test/*`.split("\n")
Expand Down
13 changes: 12 additions & 1 deletion test/test_helper.rb
@@ -1,6 +1,7 @@
require "rubygems"
require "bundler/setup"
require 'pry'
require 'pry-nav'

require "active_record"

Expand Down Expand Up @@ -71,6 +72,7 @@ def create_model(name, *args, &block)
superklass = args.first.kind_of?(Class) ? args.shift : ActiveRecord::Base
columns = args.first || {}
klass = Object.const_set name.to_sym, Class.new(superklass)

if superklass == ActiveRecord::Base || superklass.abstract_class?
create_table Object.const_get(name.to_sym).table_name, columns, Object.const_get(name.to_sym).primary_key rescue nil
end
Expand Down Expand Up @@ -192,10 +194,19 @@ def reset_domain
model.reset_column_information
remove_fully_qualified_constant(model.name)
end

tables_and_views.each do |table|
ActiveRecord::Base.connection.drop_table table
end
ActiveRecord::Base.direct_descendants.clear

if ActiveRecord.version >= Gem::Version.new("6.0.0.rc1")
cv = ActiveSupport::DescendantsTracker.class_variable_get(:@@direct_descendants)
cv.delete(ActiveRecord::Base)
ActiveSupport::DescendantsTracker.class_variable_set(:@@direct_descendants, cv)
else
ActiveRecord::Base.direct_descendants.clear
end

ActiveSupport::Dependencies::Reference.clear!
ActiveRecord::Base.clear_cache!
end
Expand Down

0 comments on commit 360fc51

Please sign in to comment.