activerecord_cloneable 0.3.14 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 542c3fd1f7118f3b18ffa541100d785820b2ed07
4
- data.tar.gz: 57b4408f0f9ec1369be643865d962110604c2959
3
+ metadata.gz: 700597ad7e34f2e24f51a08af394003c8657a0d6
4
+ data.tar.gz: 658530761cfad7f8fea4291e44ee7c24fbae9636
5
5
  SHA512:
6
- metadata.gz: 260055200f773a2acfe7e8f56465d6610955b7b4339dc38c391493901eafc6dfa6c765916cbc6a1e80fefa2b8cd286ff3d7dc5babc1c380388d98b67e6f30992
7
- data.tar.gz: 06865c020f895ab5e99a778bc2780e2a413f4f0bc655a04573c485941302d004e69f8e48c9f7d2ce9d7381523ce1b0deb8528a9fb2e3176e91607687a080d302
6
+ metadata.gz: 5d84b1baf0a9f5199977b952151c17acec2f16ec23972a38a13d3fa44a72bec317f3c265e6a1faa1945475714a07481de6eb12504d343bea6f86e785c19450e2
7
+ data.tar.gz: 2377a1e6eb8d22dbdb6bf2021283a0ff8470e26a6ce06f7517f5762258245e11437e7670f739348b11536d9a030be4d6af7a64ddb88bbe6110a795e22ac453a7
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'activerecord_cloneable'
3
- s.version = '0.3.14'
3
+ s.version = '0.3.15'
4
4
  s.summary = "A library to help clone active records - that is, generate active new record objects with the data copied from an existing record."
5
5
  s.authors = ["Adam Palmblad"]
6
6
  s.email = 'apalmblad@gmail.com'
@@ -111,7 +111,7 @@ module ActiveRecord::Cloneable
111
111
  ((data[:has_many] || []) + (data[:has_and_belongs_to_many]||[]) ).each do |child_relation|
112
112
  next if child_relation.through_reflection
113
113
  next if !clone_child_relation?( child_relation.name, args[:skipped_child_relations] )
114
- kids = send( child_relation.name )
114
+ kids = send( child_relation.name ).to_a
115
115
  next if kids.nil?
116
116
  kids.each do |child_record|
117
117
  next if args[:skipped_children].include?( child_record )
@@ -5,14 +5,23 @@ class ActiveRecordCloneableTest < ActiveSupport::TestCase
5
5
  class Apple < ActiveRecord::Base
6
6
  cloneable
7
7
  belongs_to :banana
8
+ belongs_to :apple_variety
8
9
  validates_presence_of :banana
9
10
  validates_associated :banana
11
+ end
12
+ class AppleVariety
13
+ belongs
14
+
15
+ end
16
+ class FruitBasket
17
+
10
18
  end
11
19
  class Banana < ActiveRecord::Base
12
20
  cloneable
13
21
  has_many :apples
14
22
  has_one :bread
15
23
  end
24
+
16
25
  class NonCloneableThing < ActiveRecord::Base
17
26
  belongs_to :apple
18
27
  end
@@ -36,8 +45,8 @@ class ActiveRecordCloneableTest < ActiveSupport::TestCase
36
45
  Apple.has_many( :non_cloneable_things )
37
46
  original = Banana.new
38
47
  original.save
39
- a = original.apples.create
40
- a.non_cloneable_things.create
48
+ a = original.apples.create!
49
+ a.non_cloneable_things.create!
41
50
  original.save
42
51
  clone = original.clone_record( :skipped_child_relations => [{ :apples => :non_cloneable_things}] )
43
52
  assert( clone.apples.any? )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_cloneable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.14
4
+ version: 0.3.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Palmblad