acts_as_tree 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,4 +2,21 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
- - ruby-head
5
+ - 2.0.0
6
+
7
+ gemfile:
8
+ - gemfiles/rails-3.0.gemfile
9
+ - gemfiles/rails-3.1.gemfile
10
+ - gemfiles/rails-3.2.gemfile
11
+ - gemfiles/rails-4.0.gemfile
12
+
13
+ matrix:
14
+ exclude:
15
+ # rails 4.0 requries ruby 1.9.3 or newer
16
+ - rvm: 1.9.2
17
+ gemfile: gemfiles/rails-4.0.gemfile
18
+ # rails < 3.2 is unsupported on ruby 2.0
19
+ - rvm: 2.0.0
20
+ gemfile: gemfiles/rails-3.0.gemfile
21
+ - rvm: 2.0.0
22
+ gemfile: gemfiles/rails-3.1.gemfile
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
- # ActsAsTree [![Build Status](https://secure.travis-ci.org/amerine/acts_as_tree.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/amerine/acts_as_tree.png?travis)][gemnasium]
1
+ # ActsAsTree [![Build Status](https://secure.travis-ci.org/amerine/acts_as_tree.png?branch=master)][travis]
2
2
  [travis]: (http://travis-ci.org/amerine/acts_as_tree)
3
- [gemnasium]: (https://gemnasium.com/amerine/acts_as_tree)
4
3
 
5
4
 
6
5
  ActsAsTree extends ActiveRecord to add simple support for organizing items into
@@ -8,28 +7,33 @@ parent–children relationships.
8
7
 
9
8
  ## Example
10
9
 
11
- class Category < ActiveRecord::Base
12
- include ActsAsTree
10
+ ```ruby
11
+ class Category < ActiveRecord::Base
12
+ include ActsAsTree
13
13
 
14
- acts_as_tree order: "name"
15
- end
14
+ acts_as_tree order: "name"
15
+ end
16
16
 
17
- root = Category.create("name" => "root")
18
- child1 = root.children.create("name" => "child1")
19
- subchild1 = child1.children.create("name" => "subchild1")
17
+ root = Category.create("name" => "root")
18
+ child1 = root.children.create("name" => "child1")
19
+ subchild1 = child1.children.create("name" => "subchild1")
20
20
 
21
- root.parent # => nil
22
- child1.parent # => root
23
- root.children # => [child1]
24
- root.children.first.children.first # => subchild1
21
+ root.parent # => nil
22
+ child1.parent # => root
23
+ root.children # => [child1]
24
+ root.children.first.children.first # => subchild1
25
+ ```
25
26
 
26
27
  ## Compatibility
27
28
 
28
- We no longer support Ruby 1.8 or versions if Rails/ActiveRecord older than 3.0. If you're using a version of ActiveRecord older than 3.0 please use 0.1.1.
29
+ We no longer support Ruby 1.8 or versions of Rails/ActiveRecord older than 3.0. If you're using a version of ActiveRecord older than 3.0 please use 0.1.1.
29
30
 
30
31
  Moving forward we will do our best to support the latest versions of ActiveRecord and Ruby.
31
32
 
32
33
  ## Change Log
34
+ * 1.3.0 - March 29th, 2013
35
+ * Rails 4.0 Support! -- mischa78
36
+ * Readme Fixes -- mischa78 & seanhussey
33
37
  * 1.2.0 - October 29th, 2012
34
38
  * Adding new `self_with_ancestors` accessor -- fbuenemann
35
39
  * `roots` is now a scope.
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 3.0"
4
+ gem "acts_as_tree", path: "../"
5
+
6
+ gemspec path: "../"
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 3.1"
4
+ gem "acts_as_tree", path: "../"
5
+
6
+ gemspec path: "../"
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 3.2"
4
+ gem "acts_as_tree", path: "../"
5
+
6
+ gemspec path: "../"
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 4.0.0.beta1"
4
+ gem "acts_as_tree", path: "../"
5
+
6
+ gemspec path: "../"
@@ -75,11 +75,19 @@ module ActsAsTree
75
75
  counter_cache: configuration[:counter_cache],
76
76
  inverse_of: :children
77
77
 
78
- has_many :children, class_name: name,
79
- foreign_key: configuration[:foreign_key],
80
- order: configuration[:order],
81
- dependent: configuration[:dependent],
82
- inverse_of: :parent
78
+ if ActiveRecord::VERSION::MAJOR >= 4
79
+ has_many :children, lambda { order configuration[:order] },
80
+ class_name: name,
81
+ foreign_key: configuration[:foreign_key],
82
+ dependent: configuration[:dependent],
83
+ inverse_of: :parent
84
+ else
85
+ has_many :children, class_name: name,
86
+ foreign_key: configuration[:foreign_key],
87
+ order: configuration[:order],
88
+ dependent: configuration[:dependent],
89
+ inverse_of: :parent
90
+ end
83
91
 
84
92
  class_eval <<-EOV
85
93
  include ActsAsTree::InstanceMethods
@@ -1,3 +1,3 @@
1
1
  module ActsAsTree
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -204,9 +204,9 @@ class TreeTestWithEagerLoading < Test::Unit::TestCase
204
204
  end
205
205
 
206
206
  def test_eager_association_loading
207
- roots = TreeMixin.find :all, include: :children,
208
- conditions: "mixins.parent_id IS NULL",
209
- order: "mixins.id"
207
+ roots = TreeMixin.includes(:children)
208
+ .where('mixins.parent_id IS NULL')
209
+ .order('mixins.id')
210
210
 
211
211
  assert_equal [@root1, @root2, @root3], roots
212
212
 
@@ -218,25 +218,25 @@ class TreeTestWithEagerLoading < Test::Unit::TestCase
218
218
  end
219
219
 
220
220
  def test_eager_association_loading_with_recursive_cascading_three_levels_has_many
221
- root_node = RecursivelyCascadedTreeMixin.find :first,
222
- include: {children: {children: :children}},
223
- order: 'mixins.id'
221
+ root_node = RecursivelyCascadedTreeMixin.includes({children: {children: :children}})
222
+ .order('mixins.id')
223
+ .first
224
224
 
225
225
  assert_equal @rc4, assert_no_queries { root_node.children.first.children.first.children.first }
226
226
  end
227
227
 
228
228
  def test_eager_association_loading_with_recursive_cascading_three_levels_has_one
229
- root_node = RecursivelyCascadedTreeMixin.find :first,
230
- include: {first_child: {first_child: :first_child}},
231
- order: 'mixins.id'
229
+ root_node = RecursivelyCascadedTreeMixin.includes({first_child: {first_child: :first_child}})
230
+ .order('mixins.id')
231
+ .first
232
232
 
233
233
  assert_equal @rc4, assert_no_queries { root_node.first_child.first_child.first_child }
234
234
  end
235
235
 
236
236
  def test_eager_association_loading_with_recursive_cascading_three_levels_belongs_to
237
- leaf_node = RecursivelyCascadedTreeMixin.find :first,
238
- include: {parent: {parent: :parent}},
239
- order: 'mixins.id DESC'
237
+ leaf_node = RecursivelyCascadedTreeMixin.includes({parent: {parent: :parent}})
238
+ .order('mixins.id DESC')
239
+ .first
240
240
 
241
241
  assert_equal @rc1, assert_no_queries { leaf_node.parent.parent.parent }
242
242
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-10-29 00:00:00.000000000 Z
15
+ date: 2013-03-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
@@ -78,6 +78,10 @@ files:
78
78
  - README.md
79
79
  - Rakefile
80
80
  - acts_as_tree.gemspec
81
+ - gemfiles/rails-3.0.gemfile
82
+ - gemfiles/rails-3.1.gemfile
83
+ - gemfiles/rails-3.2.gemfile
84
+ - gemfiles/rails-4.0.gemfile
81
85
  - lib/acts_as_tree.rb
82
86
  - lib/acts_as_tree/active_record/acts/tree.rb
83
87
  - lib/acts_as_tree/railtie.rb