File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -73,8 +73,9 @@ def process_localized_attributes(klass, attrs)
73
73
next unless attrs . present? && attrs [ association . key ] . present?
74
74
75
75
if association . is_a? ( Association ::Embedded ::EmbedsMany )
76
- attrs [ association . name . to_s ] . each_with_index do |attr , index |
77
- process_localized_attributes ( send ( association . name ) [ index ] . class , attr )
76
+ attrs [ association . name . to_s ] . each do |attr |
77
+ embedded_klass = attr . fetch ( '_type' , association . class_name ) . constantize
78
+ process_localized_attributes ( embedded_klass , attr )
78
79
end
79
80
else
80
81
process_localized_attributes ( association . klass , attrs [ association . key ] )
Original file line number Diff line number Diff line change 35
35
person . build_game ( name : "Tron" )
36
36
end
37
37
38
+ let! ( :name_translations ) do
39
+ person . name . translations . build ( language : 'en' )
40
+ end
41
+
38
42
context "when the document has an id field in the database" do
39
43
40
44
let! ( :band ) do
245
249
expect ( copy . addresses ) . to eq ( person . addresses )
246
250
end
247
251
252
+ it "copys deep embeds many documents" do
253
+ expect ( copy . name . translations ) . to eq ( person . name . translations )
254
+ end
255
+
248
256
it "sets the embedded many documents as new" do
249
257
expect ( copy . addresses . first ) . to be_new_record
250
258
end
251
259
260
+ it "sets the deep embedded many documents as new" do
261
+ expect ( copy . name . translations . first ) . to be_new_record
262
+ end
263
+
252
264
it "creates new embeds many instances" do
253
265
expect ( copy . addresses ) . to_not equal ( person . addresses )
254
266
end
255
267
268
+ it "creates new deep embeds many instances" do
269
+ expect ( copy . name . translations ) . to_not equal ( person . name . translations )
270
+ end
271
+
256
272
it "copys embeds one documents" do
257
273
expect ( copy . name ) . to eq ( person . name )
258
274
end
You can’t perform that action at this time.
0 commit comments