Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,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
27 changes: 24 additions & 3 deletions ruby/hyper-model/spec/batch2/relationships_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ class TestComponent2 < React::Component::Base
end

it "adding child to a new model on client after render" do
# Hyperloop.configuration do |config|
# #config.transport = :none
# end
m = FactoryBot.create(:test_model)
m.child_models << FactoryBot.create(:child_model)
mount "TestComponent2" do
Expand All @@ -122,6 +119,30 @@ def self.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)
mount "TestComponent2" do
Expand Down
14 changes: 7 additions & 7 deletions ruby/hyper-model/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ class ActiveRecord::Base
# DatabaseCleaner.start
# end

config.after(:each) do |example|
unless example.exception
# Clear session data
Capybara.reset_sessions!
# Rollback transaction
DatabaseCleaner.clean
end
config.after(:each) do # |example|
# unless example.exception
# Clear session data
Capybara.reset_sessions!
# Rollback transaction
DatabaseCleaner.clean
# end
end

config.after(:all, :js => true) do
Expand Down