Skip to content

Commit

Permalink
closes #105
Browse files Browse the repository at this point in the history
  • Loading branch information
catmando committed Jan 16, 2019
1 parent a37bcc5 commit f587414
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def collect_other_params_as(name)

alias other_params collect_other_params_as
alias others collect_other_params_as
alias other collect_other_params_as
alias opts collect_other_params_as

def fires(name, opts = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def self.gather_records(records_to_process, force, record_being_saved)
end if record.new? || record.changed? || (record == record_being_saved && force)
record_index += 1
end
[models, associations, backing_records]
[models.sort_by { |model| model[:id] }, associations, backing_records]
end

def save_or_validate(save, validate, force, &block)
Expand Down
24 changes: 24 additions & 0 deletions ruby/hyper-model/spec/batch2/relationships_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,30 @@ def self.add_child
evaluate_ruby("TestComponent2.add_child")
page.should have_content("parent has 3 children")
end

it "preserves the order of children" do
isomorphic do
ChildModel.class_eval do
server_method :do_some_calc do
child_attribute
end
end
TestModel.class_eval do
server_method :do_some_calc do
child_models.collect(&:child_attribute).join(', ')
end
end
end
expect_promise do
parent = TestModel.new
4.times do |i|
parent.child_models << ChildModel.new(child_attribute: i.to_s)
end
ReactiveRecord.load do
parent.do_some_calc.tap { parent.child_models[3].do_some_calc }
end
end.to eq('0, 1, 2, 3')
end

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

0 comments on commit f587414

Please sign in to comment.