diff --git a/.travis.yml b/.travis.yml index 30a095a..17b8fc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ gemfile: - gemfiles/rails-4.2.gemfile - gemfiles/rails-5.0.gemfile - gemfiles/rails-5.1.gemfile + - gemfiles/rails-5.2.gemfile matrix: exclude: @@ -62,3 +63,12 @@ matrix: gemfile: gemfiles/rails-5.1.gemfile - rvm: 2.1.8 gemfile: gemfiles/rails-5.1.gemfile + # rails 5.2 requires ruby 2.2.2+ + - rvm: 1.9.2 + gemfile: gemfiles/rails-5.2.gemfile + - rvm: 1.9.3 + gemfile: gemfiles/rails-5.2.gemfile + - rvm: 2.0.0 + gemfile: gemfiles/rails-5.2.gemfile + - rvm: 2.1.8 + gemfile: gemfiles/rails-5.2.gemfile diff --git a/gemfiles/rails-5.2.gemfile b/gemfiles/rails-5.2.gemfile new file mode 100644 index 0000000..6522b0f --- /dev/null +++ b/gemfiles/rails-5.2.gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "rails", "~> 5.2.0" + +gemspec path: "../" diff --git a/lib/acts_as_tree.rb b/lib/acts_as_tree.rb index c933dbc..6021e34 100644 --- a/lib/acts_as_tree.rb +++ b/lib/acts_as_tree.rb @@ -355,7 +355,10 @@ def leaf? private - if ActiveRecord::VERSION::MAJOR > 5 || ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 5 || ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR >= 2 + def update_parents_counter_cache + end + elsif ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 1 def update_parents_counter_cache counter_cache_column = self.class.children_counter_cache_column