Skip to content

Commit 1351858

Browse files
committed
closes #195
1 parent e79ac6a commit 1351858

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ def load_from_db(*args)
428428

429429
def destroy_associations
430430
@destroyed = false
431+
@being_destroyed = true
431432
model.reflect_on_all_associations.each do |association|
432433
if association.collection?
433434
@attributes[association.attribute].replace([]) if @attributes[association.attribute]

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ def set_change_status_and_notify_only(attr, changed)
115115
end
116116

117117
def change_status_and_notify_helper(attr, changed)
118+
return if @being_destroyed
118119
empty_before = changed_attributes.empty?
119-
# TODO: confirm this works:
120-
# || data_loading? added so that model.new can be wrapped in a ReactiveRecord.load_data
121120
if !changed || data_loading?
122121
changed_attributes.delete(attr)
123122
elsif !changed_attributes.include?(attr)

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def self.add_child
120120
evaluate_ruby("TestComponent2.add_child")
121121
page.should have_content("parent has 3 children")
122122
end
123-
123+
124124
it "preserves the order of children" do
125125
isomorphic do
126126
ChildModel.class_eval do
@@ -211,7 +211,7 @@ class TestComponent3 < HyperComponent
211211
ChildModel.create(child_attribute: :foo, test_model: TestModel.find(1))
212212
page.should have_content('child id = 2')
213213
ChildModel.find(1).destroy
214-
sleep 0.1 # necessary for poltergeist to work with pusher faker
214+
sleep 0.1 # necessary for chrome driver to work with pusher faker
215215
page.should_not have_content('child id = 1', wait: 2)
216216
end
217217

@@ -228,7 +228,7 @@ class TestComponent3 < HyperComponent
228228
evaluate_ruby do
229229
ChildModel.find(1).destroy
230230
end
231-
sleep 0.1 # necessary for poltergeist to work with pusher faker
231+
sleep 0.1 # necessary for chrome driver to work with pusher faker
232232
page.should_not have_content('child id = 1', wait: 2)
233233
end
234234

@@ -242,10 +242,14 @@ class TestComponent3 < HyperComponent
242242
FactoryBot.create(:child_model, test_model: m)
243243

244244
mount "TestComponent3" do
245+
class InnerComponent < HyperComponent
246+
param :child
247+
render { LI { "child id = #{@Child.id} #{@Child.test_model.test_attribute}"} }
248+
end
245249
class TestComponent3 < HyperComponent
246250
render(OL) do
247251
TestModel.all[0].child_models.each do |child|
248-
LI { "child id = #{child.id} "}
252+
InnerComponent(child: child)
249253
end
250254
end
251255
end
@@ -257,8 +261,9 @@ class TestComponent3 < HyperComponent
257261
ChildModel.create(child_attribute: :foo, test_model: TestModel.find(1))
258262
page.should have_content('child id = 2')
259263
ChildModel.find(1).destroy
260-
sleep 0.1 # necessary for poltergeist to work with pusher faker
264+
sleep 0.1 # necessary for chrome driver to work with pusher faker
261265
page.should_not have_content('child id = 1', wait: 2)
266+
page.should have_content('child id = 2')
262267
end
263268

264269
it "will update when sent from the client" do
@@ -275,7 +280,7 @@ class TestComponent3 < HyperComponent
275280

276281
ChildModel.find(1).destroy
277282
end
278-
sleep 0.1 # necessary for poltergeist to work with pusher faker
283+
sleep 0.1 # necessary for chrome driver to work with pusher faker
279284
page.should_not have_content('child id = 1', wait: 2)
280285
end
281286

0 commit comments

Comments
 (0)