hyper-mesh 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +7 -2
- data/README.md +112 -87
- data/Rakefile +6 -1
- data/docs/action_cable_quickstart.md +20 -16
- data/docs/activerecord_api.md +23 -17
- data/docs/authorization-policies.md +45 -35
- data/docs/client_side_scoping.md +5 -5
- data/docs/configuration_details.md +6 -46
- data/docs/pusher_faker_quickstart.md +7 -68
- data/docs/pusher_quickstart.md +7 -68
- data/docs/simple_poller_quickstart.md +6 -67
- data/docs/todo-example.md +2 -2
- data/docs/word_game.md +3 -1
- data/docs/words-example.md +2 -3
- data/examples/action-cable/Gemfile +2 -1
- data/examples/action-cable/Gemfile.lock +73 -54
- data/examples/action-cable/config/initializers/{hyper_mesh.rb → hyperloop.rb} +1 -1
- data/examples/action-cable/config/routes.rb +1 -1
- data/hyper-mesh.gemspec +10 -4
- data/lib/active_record_base.rb +3 -3
- data/{examples/action-cable-production-mode/log/.keep → lib/acts_as_string.rb} +0 -0
- data/lib/hyper-mesh.rb +11 -19
- data/lib/hyper_mesh/version.rb +3 -0
- data/lib/hypermesh/version.rb +1 -1
- data/lib/reactive_record/active_record/class_methods.rb +10 -3
- data/lib/reactive_record/active_record/instance_methods.rb +8 -0
- data/lib/reactive_record/active_record/public_columns_hash.rb +8 -2
- data/lib/reactive_record/active_record/reactive_record/collection.rb +0 -1
- data/lib/reactive_record/active_record/reactive_record/dummy_value.rb +2 -1
- data/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb +55 -63
- data/lib/reactive_record/active_record/reactive_record/operations.rb +51 -0
- data/lib/reactive_record/active_record/reactive_record/reactive_set_relationship_helpers.rb +3 -3
- data/lib/reactive_record/active_record/reactive_record/while_loading.rb +93 -84
- data/lib/reactive_record/broadcast.rb +183 -0
- data/lib/reactive_record/permissions.rb +2 -2
- data/reactive_record_test_app/Gemfile +6 -2
- data/reactive_record_test_app/Gemfile.lock +120 -60
- data/reactive_record_test_app/app/assets/javascripts/application.rb +3 -5
- data/reactive_record_test_app/app/assets/javascripts/bigdecimal.rb +1 -0
- data/reactive_record_test_app/app/assets/javascripts/reactive_record_config.js +2 -2
- data/reactive_record_test_app/app/controllers/application_controller.rb +3 -3
- data/reactive_record_test_app/app/controllers/home_controller.rb +1 -1
- data/reactive_record_test_app/app/models/models.rb.erb +6 -0
- data/reactive_record_test_app/config/application.rb +2 -0
- data/reactive_record_test_app/config/environments/development.rb +1 -1
- data/reactive_record_test_app/config/routes.rb +1 -2
- data/reactive_record_test_app/db/seeds.rb +6 -0
- data/reactive_record_test_app/script/rails +0 -0
- data/reactive_record_test_app/spec-opal/active-record/rendering_spec.rb +11 -2
- data/reactive_record_test_app/spec-opal/active-record/save_spec.rb +3 -4
- data/reactive_record_test_app/spec-opal/spec_helper.js.rb +1 -1
- data/reactive_record_test_app/spec-opal/test_spec.rb +7 -0
- data/reactive_record_test_app/spec_dont_run/README.md +7 -0
- data/reactive_record_test_app/{spec-opal/active-record → spec_dont_run/active_record_broken}/permissions_spec.rb +0 -0
- data/reactive_record_test_app/{spec-opal/active-record → spec_dont_run/active_record_broken}/prerendering_spec.rb +1 -0
- data/spec/{synchromesh/aaa-unit_tests/connection_spec.rb → batch1/aaa-unit_tests/connection_movedspec.rb} +0 -0
- data/spec/{synchromesh → batch1}/aaa-unit_tests/dummy_value_spec.rb +2 -2
- data/spec/{synchromesh → batch1}/column_types/column_type_spec.rb +2 -2
- data/spec/{synchromesh → batch1}/crud_access_regulation/broadcast_controls_access_spec.rb +1 -1
- data/spec/{synchromesh → batch1}/crud_access_regulation/model_policies_spec.rb +6 -6
- data/spec/batch1/misc/access_like_hash_spec.rb +43 -0
- data/spec/batch1/misc/while_loading_spec.rb +196 -0
- data/spec/{synchromesh → batch1}/policies/regulate_all_broadcasts_spec.rb +12 -12
- data/spec/{synchromesh → batch1}/policies/regulate_broadcast_spec.rb +25 -25
- data/spec/{synchromesh/integration → batch2}/authorization_spec.rb +8 -7
- data/spec/{synchromesh/integration → batch2}/default_scope_spec.rb +2 -2
- data/spec/{synchromesh/integration → batch2}/has_many_through_spec.rb +2 -2
- data/spec/{synchromesh/integration → batch2}/relationships_spec.rb +3 -3
- data/spec/{reactive_record → batch3}/auto_load_itself_spec.rb +1 -1
- data/spec/{reactive_record → batch3}/edge_cases_spec.rb +1 -1
- data/spec/{reactive_record → batch3}/finder_method_spec.rb +1 -1
- data/spec/{reactive_record → batch3}/many_to_many_spec.rb +2 -2
- data/spec/{reactive_record → batch3}/pry_rescue_xspec.rb +0 -0
- data/{examples/action-cable-production-mode/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css → spec/batch3/readme.txt} +0 -0
- data/spec/{reactive_record → batch3}/revert_spec.rb +2 -2
- data/spec/{reactive_record → batch3}/save_while_loading_spec.rb +1 -1
- data/spec/{reactive_record → batch3}/update_associations_spec.rb +2 -2
- data/spec/{reactive_record → batch3}/update_scopes_spec.rb +2 -2
- data/spec/{synchromesh/integration → batch4}/saving_during_commit_spec.rb +2 -2
- data/spec/{synchromesh/integration → batch4}/scope_spec.rb +30 -2
- data/spec/{synchromesh/examples → batch4}/scoped_todos_spec.rb +3 -3
- data/spec/{synchromesh/integration → batch4}/synchromesh_spec.rb +2 -2
- data/spec/{synchromesh/examples → examples}/dictionary.rb +2 -2
- data/spec/{synchromesh/examples → examples}/dictionary_with_client_scopes.rb +2 -2
- data/spec/{synchromesh/examples → examples}/random_examples.rb +1 -1
- data/spec/{reactive_record/play.rb → play_ground.rb} +0 -0
- data/spec/{reactive_record/factory.rb → reactive_record_factory.rb} +0 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/test_app/Gemfile +8 -3
- data/spec/test_app/Gemfile.lock +114 -64
- data/spec/test_app/app/views/components.rb +1 -2
- data/spec/test_app/config/application.rb +2 -0
- data/spec/test_app/config/routes.rb +1 -1
- data/spec/{synchromesh/integration/test_components.rb → test_components.rb} +0 -0
- metadata +144 -137
- data/app/controllers/reactive_record/application_controller.rb +0 -4
- data/app/controllers/reactive_record/reactive_record_controller.rb +0 -49
- data/config/routes.rb +0 -7
- data/examples/action-cable-production-mode/public/assets/application-90043e04e9e784054fd08159fa7aafe5e23d3ffb31584b1bea1e47043c9cfb5a.js +0 -50
- data/examples/action-cable-production-mode/public/assets/application-90043e04e9e784054fd08159fa7aafe5e23d3ffb31584b1bea1e47043c9cfb5a.js.gz +0 -0
- data/examples/action-cable-production-mode/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz +0 -0
- data/examples/action-cable-production-mode/tmp/.keep +0 -0
- data/examples/action-cable/log/.keep +0 -0
- data/examples/action-cable/tmp/.keep +0 -0
- data/examples/pusher-fake/log/.keep +0 -0
- data/examples/pusher-fake/tmp/.keep +0 -0
- data/examples/pusher/log/.keep +0 -0
- data/examples/pusher/tmp/.keep +0 -0
- data/examples/simple-poller/log/.keep +0 -0
- data/examples/simple-poller/tmp/.keep +0 -0
- data/examples/word-game/log/.keep +0 -0
- data/examples/word-game/tmp/.keep +0 -0
- data/examples/words/log/.keep +0 -0
- data/examples/words/tmp/.keep +0 -0
- data/lib/reactive_record/version.rb +0 -3
- data/lib/sources/hyper-mesh/pusher.js +0 -98
- data/lib/synchromesh/action_cable.rb +0 -39
- data/lib/synchromesh/client_drivers.rb +0 -357
- data/lib/synchromesh/configuration.rb +0 -40
- data/lib/synchromesh/connection.rb +0 -170
- data/lib/synchromesh/policy.rb +0 -504
- data/lib/synchromesh/synchromesh.rb +0 -159
- data/lib/synchromesh/synchromesh_controller.rb +0 -162
- data/reactive_record_test_app/README.rdoc +0 -261
- data/reactive_record_test_app/app/assets/javascripts/components/another_component.rb +0 -24
- data/reactive_record_test_app/app/assets/javascripts/components/empty_component.rb +0 -6
- data/reactive_record_test_app/app/assets/javascripts/components/todo_item_component.js.rb +0 -16
- data/reactive_record_test_app/app/assets/javascripts/components/todos_component.js.rb +0 -42
- data/reactive_record_test_app/app/assets/javascripts/components/todos_main_component.rb +0 -49
- data/reactive_record_test_app/app/assets/javascripts/react_js_test_only.js +0 -21618
- data/reactive_record_test_app/app/assets/javascripts/spec/reactive_record_xspec.js.rb +0 -42
- data/reactive_record_test_app/app/controllers/test_controller.rb +0 -7
- data/reactive_record_test_app/app/mailers/.gitkeep +0 -0
- data/reactive_record_test_app/app/models/models.rb +0 -1
- data/reactive_record_test_app/app/policies/application_policy.rb +0 -5
- data/reactive_record_test_app/app/views/components.rb +0 -4
- data/reactive_record_test_app/app/views/components/test.rb +0 -18
- data/reactive_record_test_app/app/views/home/index.html.erb +0 -1
- data/reactive_record_test_app/app/views/layouts/application.html.erb +0 -17
- data/reactive_record_test_app/config/environments/production.rb +0 -70
- data/reactive_record_test_app/config/environments/test.rb +0 -41
- data/spec/synchromesh/integration/transports_spec.rb +0 -308
- data/spec/synchromesh/policies/auto_connect_spec.rb +0 -60
- data/spec/synchromesh/policies/auto_loader_spec.rb +0 -34
- data/spec/synchromesh/policies/policy_methods_spec.rb +0 -85
- data/spec/synchromesh/policies/regulate_class_connection_spec.rb +0 -50
- data/spec/synchromesh/policies/regulate_instance_connection_spec.rb +0 -66
- data/spec/test_app/log/.keep +0 -0
|
@@ -32,8 +32,8 @@ describe "regulate_broadcast" do
|
|
|
32
32
|
end
|
|
33
33
|
attr_accessor :id, :attrA, :attrB, :attrC, :attrD, :attrE
|
|
34
34
|
end
|
|
35
|
-
allow(
|
|
36
|
-
allow_any_instance_of(
|
|
35
|
+
allow(Hyperloop::Connection).to receive(:active).and_return(['Application', 'TestModel1-1', 'TestModel1-7', 'TestModel2-8'])
|
|
36
|
+
allow_any_instance_of(Hyperloop::InternalPolicy).to receive(:id).and_return(:unique_broadcast_id)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "will broadcast the instance policies for a model" do
|
|
@@ -44,7 +44,7 @@ describe "regulate_broadcast" do
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
model = TestModel1.new(id: 1, attr1: 1, attr2: 2, attr3: 3, attr4: 4, attr5: 5)
|
|
47
|
-
expect { |b|
|
|
47
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
48
48
|
{
|
|
49
49
|
broadcast_id: :unique_broadcast_id,
|
|
50
50
|
channel: 'TestModel1-1',
|
|
@@ -64,7 +64,7 @@ describe "regulate_broadcast" do
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
model = TestModel1.new(id: 1, attr1: 1, attr2: 2, attr3: 3, attr4: 4, attr5: 5)
|
|
67
|
-
expect { |b|
|
|
67
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.
|
|
68
68
|
to raise_error("TestModel1 instance broadcast policy not sent to any channel")
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -77,7 +77,7 @@ describe "regulate_broadcast" do
|
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
model = TestModel1.new(id: 1, attr1: 1, attr2: 2, attr3: 3, attr4: 4, attr5: 5)
|
|
80
|
-
expect { |b|
|
|
80
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
81
81
|
{
|
|
82
82
|
broadcast_id: :unique_broadcast_id,
|
|
83
83
|
channel: 'TestModel1-1',
|
|
@@ -98,7 +98,7 @@ describe "regulate_broadcast" do
|
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
model = TestModel1.new(id: 1, attr1: 1, attr2: 2, attr3: 3, attr4: 4, attr5: 5)
|
|
101
|
-
expect { |b|
|
|
101
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
102
102
|
{
|
|
103
103
|
broadcast_id: :unique_broadcast_id,
|
|
104
104
|
channel: 'TestModel1-1',
|
|
@@ -127,7 +127,7 @@ describe "regulate_broadcast" do
|
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
model = TestModel1.new(id: 1, attr1: 1, attr2: 2, attr3: 3, attr4: 4, attr5: 5)
|
|
130
|
-
expect { |b|
|
|
130
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
131
131
|
{
|
|
132
132
|
broadcast_id: :unique_broadcast_id,
|
|
133
133
|
channel: 'TestModel1-1',
|
|
@@ -157,7 +157,7 @@ describe "regulate_broadcast" do
|
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
model = TestModel1.new(id: 1, attr1: 1, attr2: 2, attr3: 3, attr4: 4, attr5: 5)
|
|
160
|
-
expect { |b|
|
|
160
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
161
161
|
{
|
|
162
162
|
broadcast_id: :unique_broadcast_id,
|
|
163
163
|
channel: 'TestModel1-1',
|
|
@@ -190,7 +190,7 @@ describe "regulate_broadcast" do
|
|
|
190
190
|
end
|
|
191
191
|
end
|
|
192
192
|
model = TestModel1.new(id: 1, attr1: 1, attr2: 2, attr3: 3, attr4: 4, attr5: 5)
|
|
193
|
-
expect { |b|
|
|
193
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
194
194
|
{
|
|
195
195
|
broadcast_id: :unique_broadcast_id,
|
|
196
196
|
channel: 'TestModel1-1',
|
|
@@ -222,7 +222,7 @@ describe "regulate_broadcast" do
|
|
|
222
222
|
end
|
|
223
223
|
end
|
|
224
224
|
model = TestModel1.new(id: 1, attr1: 1, attr2: "YES", attr3: 3, attr4: 4, attr5: 5)
|
|
225
|
-
expect { |b|
|
|
225
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
226
226
|
{
|
|
227
227
|
broadcast_id: :unique_broadcast_id,
|
|
228
228
|
channel: 'TestModel1-1',
|
|
@@ -233,7 +233,7 @@ describe "regulate_broadcast" do
|
|
|
233
233
|
}
|
|
234
234
|
)
|
|
235
235
|
model = TestModel1.new(id: 1, attr1: 1, attr2: "NO", attr3: 3, attr4: 4, attr5: 5)
|
|
236
|
-
expect { |b|
|
|
236
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.not_to yield_control
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
it "will adds the obj method to the policy which points back to the model being broadcast" do
|
|
@@ -248,7 +248,7 @@ describe "regulate_broadcast" do
|
|
|
248
248
|
end
|
|
249
249
|
end
|
|
250
250
|
model = TestModel1.new(id: 1, attr1: 1, attr2: "YES", attr3: 3, attr4: 4, attr5: 5)
|
|
251
|
-
expect { |b|
|
|
251
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
252
252
|
{
|
|
253
253
|
broadcast_id: :unique_broadcast_id,
|
|
254
254
|
channel: 'TestModel1-1',
|
|
@@ -259,7 +259,7 @@ describe "regulate_broadcast" do
|
|
|
259
259
|
}
|
|
260
260
|
)
|
|
261
261
|
model = TestModel1.new(id: 1, attr1: 1, attr2: "NO", attr3: 3, attr4: 4, attr5: 5)
|
|
262
|
-
expect { |b|
|
|
262
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.not_to yield_control
|
|
263
263
|
end
|
|
264
264
|
it "will not broadcast an empty record" do
|
|
265
265
|
stub_const "TestModel1Policy", Class.new
|
|
@@ -273,7 +273,7 @@ describe "regulate_broadcast" do
|
|
|
273
273
|
end
|
|
274
274
|
end
|
|
275
275
|
model = TestModel1.new(id: 1, attr1: 1, attr2: "YES", attr3: 3, attr4: 4, attr5: 5)
|
|
276
|
-
expect { |b|
|
|
276
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
277
277
|
{
|
|
278
278
|
broadcast_id: :unique_broadcast_id,
|
|
279
279
|
channel: 'TestModel1-1',
|
|
@@ -284,7 +284,7 @@ describe "regulate_broadcast" do
|
|
|
284
284
|
}
|
|
285
285
|
)
|
|
286
286
|
model = TestModel1.new(id: 1, attr1: 1, attr2: "NO", attr3: 3, attr4: 4, attr5: 5)
|
|
287
|
-
expect { |b|
|
|
287
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.not_to yield_control
|
|
288
288
|
end
|
|
289
289
|
it "will apply the same policy to several models" do
|
|
290
290
|
stub_const "ApplicationPolicy", Class.new
|
|
@@ -295,7 +295,7 @@ describe "regulate_broadcast" do
|
|
|
295
295
|
end
|
|
296
296
|
model1 = TestModel1.new(id: 7, attr1: 1)
|
|
297
297
|
model2 = TestModel2.new(id: 8, attrA: 1)
|
|
298
|
-
expect { |b|
|
|
298
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model1, &b) }.to yield_successive_args(
|
|
299
299
|
{
|
|
300
300
|
broadcast_id: :unique_broadcast_id,
|
|
301
301
|
channel: 'TestModel1-7',
|
|
@@ -305,7 +305,7 @@ describe "regulate_broadcast" do
|
|
|
305
305
|
previous_changes: {id: 7}
|
|
306
306
|
}
|
|
307
307
|
)
|
|
308
|
-
expect { |b|
|
|
308
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model2, &b) }.to yield_successive_args(
|
|
309
309
|
{
|
|
310
310
|
broadcast_id: :unique_broadcast_id,
|
|
311
311
|
channel: 'TestModel2-8',
|
|
@@ -318,23 +318,23 @@ describe "regulate_broadcast" do
|
|
|
318
318
|
|
|
319
319
|
end
|
|
320
320
|
|
|
321
|
-
it "exposes the policy methods on the
|
|
321
|
+
it "exposes the policy methods on the hyperloop_internal_policy_object" do
|
|
322
322
|
stub_const "TestModel1Policy", Class.new
|
|
323
323
|
stub_const "Application", Class.new
|
|
324
324
|
TestModel1Policy.class_eval do
|
|
325
325
|
regulate_broadcast do | policy |
|
|
326
|
-
case policy.
|
|
326
|
+
case policy.hyperloop_internal_policy_object.obj.attr1
|
|
327
327
|
when "send_all"
|
|
328
|
-
policy.
|
|
328
|
+
policy.hyperloop_internal_policy_object.send_all.to(self)
|
|
329
329
|
when "send_all_but"
|
|
330
|
-
policy.
|
|
330
|
+
policy.hyperloop_internal_policy_object.send_all_but(:attr2).to(self)
|
|
331
331
|
when "send_only"
|
|
332
|
-
policy.
|
|
332
|
+
policy.hyperloop_internal_policy_object.send_only(:attr2).to(self)
|
|
333
333
|
end
|
|
334
334
|
end
|
|
335
335
|
end
|
|
336
336
|
model = TestModel1.new(id: 1, attr1: "send_all", attr2: "YES", attr3: 3, attr4: 4, attr5: 5)
|
|
337
|
-
expect { |b|
|
|
337
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
338
338
|
{
|
|
339
339
|
broadcast_id: :unique_broadcast_id,
|
|
340
340
|
channel: 'TestModel1-1',
|
|
@@ -345,7 +345,7 @@ describe "regulate_broadcast" do
|
|
|
345
345
|
}
|
|
346
346
|
)
|
|
347
347
|
model = TestModel1.new(id: 1, attr1: "send_all_but", attr2: "YES", attr3: 3, attr4: 4, attr5: 5)
|
|
348
|
-
expect { |b|
|
|
348
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
349
349
|
{
|
|
350
350
|
broadcast_id: :unique_broadcast_id,
|
|
351
351
|
channel: 'TestModel1-1',
|
|
@@ -356,7 +356,7 @@ describe "regulate_broadcast" do
|
|
|
356
356
|
}
|
|
357
357
|
)
|
|
358
358
|
model = TestModel1.new(id: 1, attr1: "send_only", attr2: "YES", attr3: 3, attr4: 4, attr5: 5)
|
|
359
|
-
expect { |b|
|
|
359
|
+
expect { |b| Hyperloop::InternalPolicy.regulate_broadcast(model, &b) }.to yield_successive_args(
|
|
360
360
|
{
|
|
361
361
|
broadcast_id: :unique_broadcast_id,
|
|
362
362
|
channel: 'TestModel1-1',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require '
|
|
2
|
+
require 'test_components'
|
|
3
3
|
|
|
4
4
|
describe "authorization integration", js: true do
|
|
5
5
|
|
|
6
6
|
before(:all) do
|
|
7
|
-
#
|
|
7
|
+
# Hyperloop.configuration do |config|
|
|
8
8
|
# config.transport = :simple_poller
|
|
9
9
|
# # slow down the polling so wait_for_ajax works
|
|
10
10
|
# config.opts = { seconds_between_poll: 2 }
|
|
@@ -17,7 +17,7 @@ describe "authorization integration", js: true do
|
|
|
17
17
|
Pusher.secret = "MY_TEST_SECRET"
|
|
18
18
|
require "pusher-fake/support/base"
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Hyperloop.configuration do |config|
|
|
21
21
|
config.transport = :pusher
|
|
22
22
|
config.channel_prefix = "synchromesh"
|
|
23
23
|
config.opts = {app_id: Pusher.app_id, key: Pusher.key, secret: Pusher.secret}.merge(PusherFake.configuration.web_options)
|
|
@@ -46,6 +46,7 @@ describe "authorization integration", js: true do
|
|
|
46
46
|
before(:each) do
|
|
47
47
|
# spec_helper resets the policy system after each test so we have to setup
|
|
48
48
|
# before each test
|
|
49
|
+
User
|
|
49
50
|
stub_const "User", Class.new
|
|
50
51
|
User.class_eval do
|
|
51
52
|
include ActiveModel::Model
|
|
@@ -68,7 +69,7 @@ describe "authorization integration", js: true do
|
|
|
68
69
|
wait_for_ajax
|
|
69
70
|
model1.attributes_on_client(page).should eq({id: 1})
|
|
70
71
|
ApplicationController.acting_user = User.new(name: "fred")
|
|
71
|
-
page.evaluate_ruby('
|
|
72
|
+
page.evaluate_ruby('Hyperloop.connect("TestApplication")')
|
|
72
73
|
wait_for_ajax
|
|
73
74
|
model1.update_attribute(:test_attribute, 'george')
|
|
74
75
|
wait_for_ajax
|
|
@@ -78,7 +79,7 @@ describe "authorization integration", js: true do
|
|
|
78
79
|
updated_at: model1.updated_at.localtime.strftime('%Y-%m-%dT%H:%M:%S%z')
|
|
79
80
|
})
|
|
80
81
|
ApplicationController.acting_user = User.new(name: "george")
|
|
81
|
-
page.evaluate_ruby("
|
|
82
|
+
page.evaluate_ruby("Hyperloop.connect(['TestModel', #{model1.id}])")
|
|
82
83
|
wait_for_ajax
|
|
83
84
|
model1.update_attribute(:completed, true)
|
|
84
85
|
wait_for_ajax
|
|
@@ -92,7 +93,7 @@ describe "authorization integration", js: true do
|
|
|
92
93
|
it "will fail on illegal class connections" do
|
|
93
94
|
mount "TestComponent2"
|
|
94
95
|
model1 = FactoryGirl.create(:test_model, test_attribute: "hello")
|
|
95
|
-
page.evaluate_ruby('
|
|
96
|
+
page.evaluate_ruby('Hyperloop.connect("TestApplication")')
|
|
96
97
|
model1.update_attribute(:test_attribute, 'george')
|
|
97
98
|
wait_for_ajax
|
|
98
99
|
model1.attributes_on_client(page).should eq({id: 1})
|
|
@@ -102,7 +103,7 @@ describe "authorization integration", js: true do
|
|
|
102
103
|
mount "TestComponent2"
|
|
103
104
|
model1 = FactoryGirl.create(:test_model, test_attribute: "george")
|
|
104
105
|
ApplicationController.acting_user = User.new(name: "fred")
|
|
105
|
-
page.evaluate_ruby("
|
|
106
|
+
page.evaluate_ruby("Hyperloop.connect(['TestModel', #{model1.id}])")
|
|
106
107
|
model1.update_attribute(:completed, true)
|
|
107
108
|
wait_for_ajax
|
|
108
109
|
model1.attributes_on_client(page).should eq({id: 1})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require '
|
|
2
|
+
require 'test_components'
|
|
3
3
|
|
|
4
4
|
describe "default_scope" do
|
|
5
5
|
|
|
@@ -13,7 +13,7 @@ describe "default_scope" do
|
|
|
13
13
|
Pusher.secret = "MY_TEST_SECRET"
|
|
14
14
|
require "pusher-fake/support/base"
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Hyperloop.configuration do |config|
|
|
17
17
|
config.transport = :pusher
|
|
18
18
|
config.channel_prefix = "synchromesh"
|
|
19
19
|
config.opts = {app_id: Pusher.app_id, key: Pusher.key, secret: Pusher.secret}.merge(PusherFake.configuration.web_options)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require '
|
|
2
|
+
require 'test_components'
|
|
3
3
|
require 'rspec-steps'
|
|
4
4
|
|
|
5
5
|
RSpec::Steps.steps "has_many through relationships", js: true do
|
|
@@ -12,7 +12,7 @@ RSpec::Steps.steps "has_many through relationships", js: true do
|
|
|
12
12
|
Pusher.secret = "MY_TEST_SECRET"
|
|
13
13
|
require "pusher-fake/support/base"
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Hyperloop.configuration do |config|
|
|
16
16
|
config.transport = :pusher
|
|
17
17
|
config.channel_prefix = "synchromesh"
|
|
18
18
|
config.opts = {app_id: Pusher.app_id, key: Pusher.key, secret: Pusher.secret}.merge(PusherFake.configuration.web_options)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require '
|
|
2
|
+
require 'test_components'
|
|
3
3
|
|
|
4
4
|
describe "synchronizing relationships", js: true do
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ describe "synchronizing relationships", js: true do
|
|
|
11
11
|
Pusher.secret = "MY_TEST_SECRET"
|
|
12
12
|
require "pusher-fake/support/base"
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Hyperloop.configuration do |config|
|
|
15
15
|
config.transport = :pusher
|
|
16
16
|
config.channel_prefix = "synchromesh"
|
|
17
17
|
config.opts = {app_id: Pusher.app_id, key: Pusher.key, secret: Pusher.secret}.merge(PusherFake.configuration.web_options)
|
|
@@ -96,7 +96,7 @@ describe "synchronizing relationships", js: true do
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
it "adding child to a new model on client after render" do
|
|
99
|
-
#
|
|
99
|
+
# Hyperloop.configuration do |config|
|
|
100
100
|
# #config.transport = :none
|
|
101
101
|
# end
|
|
102
102
|
m = FactoryGirl.create(:test_model)
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require '
|
|
2
|
+
require 'test_components'
|
|
3
3
|
require 'rspec-steps'
|
|
4
4
|
|
|
5
5
|
describe "saving during commit", js: true do
|
|
@@ -12,7 +12,7 @@ describe "saving during commit", js: true do
|
|
|
12
12
|
Pusher.secret = "MY_TEST_SECRET"
|
|
13
13
|
require "pusher-fake/support/base"
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Hyperloop.configuration do |config|
|
|
16
16
|
config.transport = :pusher
|
|
17
17
|
config.channel_prefix = "synchromesh"
|
|
18
18
|
config.opts = {app_id: Pusher.app_id, key: Pusher.key, secret: Pusher.secret}.merge(PusherFake.configuration.web_options)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require '
|
|
2
|
+
require 'test_components'
|
|
3
3
|
|
|
4
4
|
describe "synchronized scopes", js: true do
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ describe "synchronized scopes", js: true do
|
|
|
11
11
|
Pusher.secret = "MY_TEST_SECRET"
|
|
12
12
|
require "pusher-fake/support/base"
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Hyperloop.configuration do |config|
|
|
15
15
|
config.transport = :pusher
|
|
16
16
|
config.channel_prefix = "synchromesh"
|
|
17
17
|
config.opts = {app_id: Pusher.app_id, key: Pusher.key, secret: Pusher.secret}.merge(PusherFake.configuration.web_options)
|
|
@@ -185,6 +185,34 @@ describe "synchronized scopes", js: true do
|
|
|
185
185
|
page.should have_content('scope1.scope2.count = 1')
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
+
it 'collections passed from server will not interfere with client associations' do
|
|
189
|
+
user = FactoryGirl.create(:user)
|
|
190
|
+
5.times do
|
|
191
|
+
FactoryGirl.create(:todo, title: 'active', created_by_id: user.id)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
isomorphic do
|
|
195
|
+
Todo.class_eval do
|
|
196
|
+
scope :active, -> { where('title LIKE ?', 'active') }
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
todos = user.authored_todos.active
|
|
201
|
+
|
|
202
|
+
mount 'TestComponent2', todos: todos do
|
|
203
|
+
class TestComponent2 < React::Component::Base
|
|
204
|
+
param :todos, type: [Todo]
|
|
205
|
+
render(:div) do
|
|
206
|
+
P { "params.todos = #{params.todos.count}" }
|
|
207
|
+
P { "params.user.authored_todos.active = #{User.find(1).authored_todos.active.count}" }
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
page.should have_content('params.todos = 5')
|
|
213
|
+
page.should have_content('params.user.authored_todos.active = 5')
|
|
214
|
+
end
|
|
215
|
+
|
|
188
216
|
context 'basic joins' do
|
|
189
217
|
|
|
190
218
|
it 'will not update a joined scope without a joins option' do
|