composite_primary_keys 14.0.8 → 14.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +3 -0
- data/lib/composite_primary_keys/nested_attributes.rb +2 -2
- data/lib/composite_primary_keys/version.rb +1 -1
- data/test/test_nested_attributes.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4675084d63630478cb5ad93843fe68c06e1820cc228fd8a1f95338851b901bd
|
4
|
+
data.tar.gz: ed8a13dcf2aee66e3fcf20f89e14049660eb7ee00341f9967a95cfd23dbbd259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18089b861f3fd8bf7d6adf998c92235f34e3e786aa7de12590988f68580a63eb0551e338b59cc491e6d322a429e143f67245bebc85137d11f5bc087faa5abbfe
|
7
|
+
data.tar.gz: 5bb22276acefd46ed09e078bb999df86d7e1885304b855c7e6493733d13f859cd9a31b58177c971825d874b57fb5388d33dc6d3f715d58aa344b1f3f8e415f67
|
data/History.rdoc
CHANGED
@@ -61,12 +61,12 @@ module ActiveRecord
|
|
61
61
|
unless reject_new_record?(association_name, attributes)
|
62
62
|
association.reader.build(attributes.except(*UNASSIGNABLE_KEYS))
|
63
63
|
end
|
64
|
-
elsif existing_record =
|
64
|
+
elsif existing_record = cpk_detect_record(attributes['id'], existing_records)
|
65
65
|
unless call_reject_if(association_name, attributes)
|
66
66
|
# Make sure we are operating on the actual object which is in the association's
|
67
67
|
# proxy_target array (either by finding it, or adding it if not found)
|
68
68
|
# Take into account that the proxy_target may have changed due to callbacks
|
69
|
-
target_record =
|
69
|
+
target_record = cpk_detect_record(attributes['id'], association.target)
|
70
70
|
if target_record
|
71
71
|
existing_record = target_record
|
72
72
|
else
|
@@ -64,4 +64,27 @@ class TestNestedAttributes < ActiveSupport::TestCase
|
|
64
64
|
assert_equal(reference_code.code_label, 'XX')
|
65
65
|
assert_equal(reference_code.abbreviation, 'Xx')
|
66
66
|
end
|
67
|
+
|
68
|
+
def test_nested_atttribute_update_4
|
69
|
+
code_id = 1003
|
70
|
+
|
71
|
+
reference_type = reference_types(:name_prefix)
|
72
|
+
reference_type.update :reference_codes_attributes => [{
|
73
|
+
:reference_code => code_id,
|
74
|
+
:code_label => 'XX',
|
75
|
+
:abbreviation => 'Xx'
|
76
|
+
}]
|
77
|
+
assert_not_nil ReferenceCode.find_by_reference_code(code_id)
|
78
|
+
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
79
|
+
# directly pass :id as a array
|
80
|
+
reference_type.update :reference_codes_attributes => [{
|
81
|
+
:id => [reference_type.reference_type_id, code_id],
|
82
|
+
:code_label => 'AAA',
|
83
|
+
:abbreviation => 'Aaa'
|
84
|
+
}]
|
85
|
+
|
86
|
+
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
87
|
+
assert_kind_of(ReferenceCode, reference_code)
|
88
|
+
assert_equal(reference_code.code_label, 'AAA')
|
89
|
+
end
|
67
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composite_primary_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.0.
|
4
|
+
version: 14.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Savage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|