File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -96,9 +96,6 @@ class TestComponent2 < React::Component::Base
96
96
end
97
97
98
98
it "adding child to a new model on client after render" do
99
- # Hyperloop.configuration do |config|
100
- # #config.transport = :none
101
- # end
102
99
m = FactoryBot . create ( :test_model )
103
100
m . child_models << FactoryBot . create ( :child_model )
104
101
mount "TestComponent2" do
@@ -122,6 +119,30 @@ def self.add_child
122
119
page . should have_content ( "parent has 3 children" )
123
120
end
124
121
122
+ it "preserves the order of children" do
123
+ isomorphic do
124
+ ChildModel . class_eval do
125
+ server_method :do_some_calc do
126
+ child_attribute
127
+ end
128
+ end
129
+ TestModel . class_eval do
130
+ server_method :do_some_calc do
131
+ child_models . collect ( &:child_attribute ) . join ( ', ' )
132
+ end
133
+ end
134
+ end
135
+ expect_promise do
136
+ parent = TestModel . new
137
+ 4 . times do |i |
138
+ parent . child_models << ChildModel . new ( child_attribute : i . to_s )
139
+ end
140
+ ReactiveRecord . load do
141
+ parent . do_some_calc . tap { parent . child_models [ 3 ] . do_some_calc }
142
+ end
143
+ end . to eq ( '0, 1, 2, 3' )
144
+ end
145
+
125
146
it "will re-render the count after an item is added or removed from a model" do
126
147
m1 = FactoryBot . create ( :test_model )
127
148
mount "TestComponent2" do
Original file line number Diff line number Diff line change @@ -271,13 +271,13 @@ class ActiveRecord::Base
271
271
# DatabaseCleaner.start
272
272
# end
273
273
274
- config . after ( :each ) do |example |
275
- unless example . exception
276
- # Clear session data
277
- Capybara . reset_sessions!
278
- # Rollback transaction
279
- DatabaseCleaner . clean
280
- end
274
+ config . after ( :each ) do # |example|
275
+ # unless example.exception
276
+ # Clear session data
277
+ Capybara . reset_sessions!
278
+ # Rollback transaction
279
+ DatabaseCleaner . clean
280
+ # end
281
281
end
282
282
283
283
config . after ( :all , :js => true ) do
You can’t perform that action at this time.
0 commit comments