Skip to content

Commit f587414

Browse files
committed
closes #105
1 parent a37bcc5 commit f587414

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

ruby/hyper-component/lib/hyperstack/internal/component/class_methods.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def collect_other_params_as(name)
203203

204204
alias other_params collect_other_params_as
205205
alias others collect_other_params_as
206+
alias other collect_other_params_as
206207
alias opts collect_other_params_as
207208

208209
def fires(name, opts = {})

ruby/hyper-model/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def self.gather_records(records_to_process, force, record_being_saved)
243243
end if record.new? || record.changed? || (record == record_being_saved && force)
244244
record_index += 1
245245
end
246-
[models, associations, backing_records]
246+
[models.sort_by { |model| model[:id] }, associations, backing_records]
247247
end
248248

249249
def save_or_validate(save, validate, force, &block)

ruby/hyper-model/spec/batch2/relationships_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,30 @@ def self.add_child
120120
evaluate_ruby("TestComponent2.add_child")
121121
page.should have_content("parent has 3 children")
122122
end
123+
124+
it "preserves the order of children" do
125+
isomorphic do
126+
ChildModel.class_eval do
127+
server_method :do_some_calc do
128+
child_attribute
129+
end
130+
end
131+
TestModel.class_eval do
132+
server_method :do_some_calc do
133+
child_models.collect(&:child_attribute).join(', ')
134+
end
135+
end
136+
end
137+
expect_promise do
138+
parent = TestModel.new
139+
4.times do |i|
140+
parent.child_models << ChildModel.new(child_attribute: i.to_s)
141+
end
142+
ReactiveRecord.load do
143+
parent.do_some_calc.tap { parent.child_models[3].do_some_calc }
144+
end
145+
end.to eq('0, 1, 2, 3')
146+
end
123147

124148
it "will re-render the count after an item is added or removed from a model" do
125149
m1 = FactoryBot.create(:test_model)

0 commit comments

Comments
 (0)