acts_as_tree 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1195db0f542f5b2a66b53ed35a6a3d0e821f282f
4
- data.tar.gz: 4564ce6846efa1aeb4f03dc632a1e8f151273757
3
+ metadata.gz: cd2799e03637580aeb10e75af1924473df069822
4
+ data.tar.gz: 495ff7f53a6386537161d2157c80e3fd7f5b8b73
5
5
  SHA512:
6
- metadata.gz: 4fd0449d5a36b43d11738b6a3d7097a69977e08464530d374b55dd6120bd65f4baeaae3f4122726e609cab2168383def9be5e8c9f6be3f42760e665032105e54
7
- data.tar.gz: aec46f7ee97a3731221c21f625efea8bbf7fc86f5ded9e8e7abe77305722711171beaf61d61b412a62ee4e2640980a5c8956a604ef62160ae44830b89a0c165f
6
+ metadata.gz: edf84e997d0163d04b8e8d46fc11a82f5700312062f7daef2d23b0e1a3cb537cb464f93921933f577c551868768c0ed8722e331309d978c705d5054e76d86d67
7
+ data.tar.gz: 0ae085569ca95ddf40c24086d75e5c4ccfee6c0c8f9f6ba722c33814959b0efbc3aae0bbea025ef856c9918dc8cc770d583d5f13adbe0728b6c47095db70079c
data/README.md CHANGED
@@ -74,6 +74,9 @@ We no longer support Ruby 1.8 or versions of Rails/ActiveRecord older than 3.0.
74
74
  Moving forward we will do our best to support the latest versions of ActiveRecord and Ruby.
75
75
 
76
76
  ## Change Log
77
+ * 2.3.0 - November 6, 2015
78
+ * Added touch option to acts\_as\_tree relation. See #40 -- mbenitezm
79
+ * Fix tests on rails 3.x with ruby 1.9.2. See #41 -- felixbuenemann
77
80
  * 2.2.0 - June 15, 2015
78
81
  * Added TreeWalker.walk\_tree instance method. See #32, #37, #38 -- felixbuenemann, genewoo
79
82
  * Fix tests on rails 3.x. See #36 -- marshall-lee
@@ -3,5 +3,6 @@ source "https://rubygems.org"
3
3
  gem "rails", "~> 3.1.0"
4
4
  gem "acts_as_tree", path: "../"
5
5
  gem "i18n", "< 0.7"
6
+ gem "rack-cache", "< 1.3"
6
7
 
7
8
  gemspec path: "../"
@@ -3,5 +3,6 @@ source "https://rubygems.org"
3
3
  gem "rails", "~> 3.2.0"
4
4
  gem "acts_as_tree", path: "../"
5
5
  gem "i18n", "< 0.7"
6
+ gem "rack-cache", "< 1.3"
6
7
 
7
8
  gemspec path: "../"
@@ -1,3 +1,3 @@
1
1
  module ActsAsTree
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.0"
3
3
  end
data/lib/acts_as_tree.rb CHANGED
@@ -66,7 +66,8 @@ module ActsAsTree
66
66
  foreign_key: "parent_id",
67
67
  order: nil,
68
68
  counter_cache: nil,
69
- dependent: :destroy
69
+ dependent: :destroy,
70
+ touch: false
70
71
  }
71
72
 
72
73
  configuration.update(options) if options.is_a?(Hash)
@@ -78,6 +79,7 @@ module ActsAsTree
78
79
  belongs_to :parent, class_name: name,
79
80
  foreign_key: configuration[:foreign_key],
80
81
  counter_cache: configuration[:counter_cache],
82
+ touch: configuration[:touch],
81
83
  inverse_of: :children
82
84
 
83
85
  if ActiveRecord::VERSION::MAJOR >= 4
@@ -56,6 +56,7 @@ def setup_db(counter_cache = false)
56
56
  t.column :type, :string
57
57
  t.column :parent_id, :integer
58
58
  t.column(:children_count, :integer, default: 0) if counter_cache
59
+ t.timestamps null: false
59
60
  end
60
61
  end
61
62
 
@@ -94,6 +95,10 @@ class RecursivelyCascadedTreeMixin < Mixin
94
95
  has_one :first_child, class_name: 'RecursivelyCascadedTreeMixin', foreign_key: :parent_id
95
96
  end
96
97
 
98
+ class TreeMixinWithTouch < Mixin
99
+ acts_as_tree foreign_key: "parent_id", order: "id", touch: true
100
+ end
101
+
97
102
  class TreeTest < MiniTest::Unit::TestCase
98
103
 
99
104
  def setup
@@ -507,3 +512,26 @@ class TreeTestWithCounterCache < MiniTest::Unit::TestCase
507
512
  assert_no_queries { @child2.leaf? }
508
513
  end
509
514
  end
515
+
516
+
517
+ class TreeTestWithTouch < MiniTest::Unit::TestCase
518
+ def setup
519
+ teardown_db
520
+ setup_db
521
+
522
+ @root = TreeMixinWithTouch.create!
523
+ @child = TreeMixinWithTouch.create! parent_id: @root.id
524
+ end
525
+
526
+ def teardown
527
+ teardown_db
528
+ end
529
+
530
+ def test_updated_at
531
+ previous_root_updated_at = @root.updated_at
532
+ @child.update_attributes(:type => "new_type")
533
+ @root.reload
534
+
535
+ assert @root.updated_at != previous_root_updated_at
536
+ end
537
+ 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: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Dahlstrand
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-06-14 00:00:00.000000000 Z
15
+ date: 2015-11-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.4.6
119
+ rubygems_version: 2.4.8
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Provides a simple tree behaviour to active_record models.