copyable 0.1.1 → 0.1.2

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: 4e51f2b73f6b3f642d8b9174567c245c2f875b6a
4
- data.tar.gz: c56647390d32496da7fbe0f971d9e86d2299b070
3
+ metadata.gz: 0859ce58af81fc332e91f2bbd28a5b366bf4ea39
4
+ data.tar.gz: f8f723985693eb36ef020438477df278bd5d6cd7
5
5
  SHA512:
6
- metadata.gz: 236d9f5a60f236f49d99b2a8f47586ea2678bbd1c2a97c86d2e0dd7eaabf4dafe90065f8e09b9fd32b6f8c9c75188e4ee27c4977c9e3ffd198a85124ed1c13c5
7
- data.tar.gz: b59f9f190720c3dbc37646795017d52953078f7bf8d7a2726fef9aa891e29c67579e911d021029b9b2def2f9898f4a5f05b163644bbba2e7fcdea506b50bcb6d
6
+ metadata.gz: 29faf86afe9848520ee195c143d11ae2d0e4b9f58c957394e00cd4f05399d4b75639c6aef3a274e63ebf7264900d83a6f81562ab6864806aec9a949738868173
7
+ data.tar.gz: 4160086a9126941852f26add5112e3ee6ad91a9fd7318d4a1e3dde1b81c00f3c3a360ea23c14cea43381ee82a796728d9b4c648840b3b7e552071187b1e6a8c2
@@ -8,6 +8,7 @@ module Copyable
8
8
  # instructions given in the copyable declaration
9
9
  def execute(association_list, original_model, new_model, skip_validations, skip_associations)
10
10
  @skip_validations = skip_validations
11
+ @skip_associations = skip_associations
11
12
  association_list.each do |assoc_name, advice|
12
13
  association = original_model.class.reflections[assoc_name.to_sym]
13
14
  check_advice(association, advice, original_model)
@@ -78,7 +79,8 @@ module Copyable
78
79
  copied_record = original_record.create_copy!(
79
80
  override: { association.foreign_key => parent_model.id },
80
81
  __called_recursively: true,
81
- skip_validations: @skip_validations)
82
+ skip_validations: @skip_validations,
83
+ skip_associations: @skip_associations)
82
84
  else
83
85
  message = "Could not copy #{parent_model.class.name}#id:#{parent_model.id} "
84
86
  message << "because #{original_record.class.name} does not have a copyable declaration."
@@ -1,3 +1,3 @@
1
1
  module Copyable
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -89,6 +89,13 @@ describe 'complex model hierarchies:' do
89
89
  expect(CopyableWarranty.count).to eq(3) # Because the amenities weren't copied either
90
90
  end
91
91
 
92
+ it 'should skip nested branches of the tree when directed' do
93
+ @vehicle2 = @vehicle1.create_copy!(skip_associations: [:copyable_warranty])
94
+ expect(CopyableVehicle.count).to eq(2)
95
+ expect(CopyableAmenity.count).to eq(6)
96
+ expect(CopyableWarranty.count).to eq(3) # No new ones created
97
+ end
98
+
92
99
  it 'should create the expected records if copied multiple times' do
93
100
  # this test makes sure the SingleCopyEnforcer isn't too eager
94
101
  @vehicle1.create_copy!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copyable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wyatt Greene
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-08 00:00:00.000000000 Z
12
+ date: 2018-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord