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
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require 'spec/spec_helper'
|
|
2
|
-
require 'user'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe "Reactive Record" do
|
|
7
|
-
|
|
8
|
-
after(:each) { React::API.clear_component_class_cache }
|
|
9
|
-
|
|
10
|
-
# uncomment if you are having trouble with tests failing. One non-async test must pass for things to work
|
|
11
|
-
|
|
12
|
-
# describe "a passing dummy test" do
|
|
13
|
-
# it "passes" do
|
|
14
|
-
# expect(true).to be(true)
|
|
15
|
-
# end
|
|
16
|
-
# end
|
|
17
|
-
|
|
18
|
-
describe "reactive_record basic api" do
|
|
19
|
-
|
|
20
|
-
rendering("a simple component") do
|
|
21
|
-
div {"hello"}
|
|
22
|
-
end.should_immediately_generate do |component|
|
|
23
|
-
component.html == "hello"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
rendering("a find_by query") do
|
|
27
|
-
User.find_by_email("mitch@catprint.com").email
|
|
28
|
-
end.should_immediately_generate do
|
|
29
|
-
html == "mitch@catprint.com"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "should yield the same find_by result if called twice" do
|
|
33
|
-
ar1 = User.find_by_email("mitch@catprint.com")
|
|
34
|
-
ar2 = User.find_by_email("mitch@catprint.com")
|
|
35
|
-
expect(ar1.equal?(ar2)).to be(true)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require_tree './public' if RUBY_ENGINE == 'opal'
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
class Test
|
|
2
|
-
|
|
3
|
-
include React::Component
|
|
4
|
-
|
|
5
|
-
def render
|
|
6
|
-
user = User.find_by_email("mitch@catprint.com")
|
|
7
|
-
div do
|
|
8
|
-
"#{Time.now.to_s} #{user.first_name}".br
|
|
9
|
-
"zip: #{user.address.zip}".br
|
|
10
|
-
"todos: #{user.todo_items.collect { |todo| todo.title }.join(", ")}".br
|
|
11
|
-
"first todo in find_string(mitch) scope: #{user.todo_items.find_string("mitch").first.title}".br
|
|
12
|
-
"a comment was made by: #{user.todo_items.first.commenters.first.email}".br
|
|
13
|
-
"some expensive math: #{user.expensive_math(13)}".br
|
|
14
|
-
"and a server side method: #{user.detailed_name}".br.tap { user.first_name = "joe"; user.detailed_name! }
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello there check the console
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Dummy</title>
|
|
5
|
-
|
|
6
|
-
<%= stylesheet_link_tag "application", :media => "all" %>
|
|
7
|
-
<%= csrf_meta_tags %>
|
|
8
|
-
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
|
|
12
|
-
<%= yield %>
|
|
13
|
-
|
|
14
|
-
<%= javascript_include_tag "application" unless params[:no_js] %>
|
|
15
|
-
|
|
16
|
-
</body>
|
|
17
|
-
</html>
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
Dummy::Application.configure do
|
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
-
|
|
4
|
-
# Code is not reloaded between requests
|
|
5
|
-
config.cache_classes = true
|
|
6
|
-
|
|
7
|
-
# Full error reports are disabled and caching is turned on
|
|
8
|
-
config.consider_all_requests_local = false
|
|
9
|
-
config.action_controller.perform_caching = true
|
|
10
|
-
|
|
11
|
-
# Disable Rails's static asset server (Apache or nginx will already do this)
|
|
12
|
-
config.serve_static_assets = false
|
|
13
|
-
|
|
14
|
-
# Compress JavaScripts and CSS
|
|
15
|
-
config.assets.compress = true
|
|
16
|
-
|
|
17
|
-
# Don't fallback to assets pipeline if a precompiled asset is missed
|
|
18
|
-
config.assets.compile = false
|
|
19
|
-
|
|
20
|
-
# Generate digests for assets URLs
|
|
21
|
-
config.assets.digest = true
|
|
22
|
-
config.assets.debug = false #true
|
|
23
|
-
Opal::Processor.source_map_enabled = false
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# Defaults to nil and saved in location specified by config.assets.prefix
|
|
27
|
-
# config.assets.manifest = YOUR_PATH
|
|
28
|
-
|
|
29
|
-
# Specifies the header that your server uses for sending files
|
|
30
|
-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
|
31
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
|
32
|
-
|
|
33
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
|
34
|
-
# config.force_ssl = true
|
|
35
|
-
|
|
36
|
-
# See everything in the log (default is :info)
|
|
37
|
-
# config.log_level = :debug
|
|
38
|
-
|
|
39
|
-
# Prepend all log lines with the following tags
|
|
40
|
-
# config.log_tags = [ :subdomain, :uuid ]
|
|
41
|
-
|
|
42
|
-
# Use a different logger for distributed setups
|
|
43
|
-
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
|
44
|
-
|
|
45
|
-
# Use a different cache store in production
|
|
46
|
-
# config.cache_store = :mem_cache_store
|
|
47
|
-
|
|
48
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
|
49
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
|
50
|
-
|
|
51
|
-
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
|
52
|
-
# config.assets.precompile += %w( search.js )
|
|
53
|
-
|
|
54
|
-
# Disable delivery errors, bad email addresses will be ignored
|
|
55
|
-
# config.action_mailer.raise_delivery_errors = false
|
|
56
|
-
|
|
57
|
-
# Enable threaded mode
|
|
58
|
-
# config.threadsafe!
|
|
59
|
-
|
|
60
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
61
|
-
# the I18n.default_locale when a translation can not be found)
|
|
62
|
-
config.i18n.fallbacks = true
|
|
63
|
-
|
|
64
|
-
# Send deprecation notices to registered listeners
|
|
65
|
-
config.active_support.deprecation = :notify
|
|
66
|
-
|
|
67
|
-
# Log the query plan for queries taking more than this (works
|
|
68
|
-
# with SQLite, MySQL, and PostgreSQL)
|
|
69
|
-
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
|
70
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
Dummy::Application.configure do
|
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
-
|
|
4
|
-
# The test environment is used exclusively to run your application's
|
|
5
|
-
# test suite. You never need to work with it otherwise. Remember that
|
|
6
|
-
# your test database is "scratch space" for the test suite and is wiped
|
|
7
|
-
# and recreated between test runs. Don't rely on the data there!
|
|
8
|
-
config.cache_classes = true
|
|
9
|
-
|
|
10
|
-
# Configure static asset server for tests with Cache-Control for performance
|
|
11
|
-
config.serve_static_assets = true
|
|
12
|
-
config.static_cache_control = "public, max-age=3600"
|
|
13
|
-
|
|
14
|
-
# Log error messages when you accidentally call methods on nil
|
|
15
|
-
config.whiny_nils = true
|
|
16
|
-
|
|
17
|
-
# Show full error reports and disable caching
|
|
18
|
-
config.consider_all_requests_local = true
|
|
19
|
-
config.action_controller.perform_caching = false
|
|
20
|
-
|
|
21
|
-
# Raise exceptions instead of rendering exception templates
|
|
22
|
-
config.action_dispatch.show_exceptions = false
|
|
23
|
-
|
|
24
|
-
# Disable request forgery protection in test environment
|
|
25
|
-
config.action_controller.allow_forgery_protection = false
|
|
26
|
-
|
|
27
|
-
# Tell Action Mailer not to deliver emails to the real world.
|
|
28
|
-
# The :test delivery method accumulates sent emails in the
|
|
29
|
-
# ActionMailer::Base.deliveries array.
|
|
30
|
-
config.action_mailer.delivery_method = :test
|
|
31
|
-
|
|
32
|
-
# Raise exception on mass assignment protection for Active Record models
|
|
33
|
-
#config.active_record.mass_assignment_sanitizer = :strict
|
|
34
|
-
|
|
35
|
-
# Print deprecation notices to the stderr
|
|
36
|
-
config.active_support.deprecation = :stderr
|
|
37
|
-
|
|
38
|
-
config.assets.debug = false #true
|
|
39
|
-
Opal::Processor.source_map_enabled = false
|
|
40
|
-
|
|
41
|
-
end
|
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'synchromesh/integration/test_components'
|
|
3
|
-
|
|
4
|
-
SKIP_MESSAGE = 'Pusher credentials not specified. '\
|
|
5
|
-
'To run set env variable PUSHER=xxxx-yyy-zzz (app id - key - secret)'
|
|
6
|
-
|
|
7
|
-
def pusher_credentials
|
|
8
|
-
Hash[*[:app_id, :key, :secret].zip(ENV['PUSHER'].split('-')).flatten]
|
|
9
|
-
rescue
|
|
10
|
-
nil
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe "Transport Tests", js: true do
|
|
14
|
-
|
|
15
|
-
before(:each) do
|
|
16
|
-
5.times { |i| FactoryGirl.create(:test_model, test_attribute: "I am item #{i}") }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
before(:each) do
|
|
20
|
-
ApplicationController.acting_user = nil
|
|
21
|
-
# spec_helper resets the policy system after each test so we have to setup
|
|
22
|
-
# before each test
|
|
23
|
-
stub_const 'TestApplicationPolicy', Class.new
|
|
24
|
-
TestApplicationPolicy.class_eval do
|
|
25
|
-
regulate_class_connection { !self }
|
|
26
|
-
regulate_all_broadcasts { |policy| policy.send_all }
|
|
27
|
-
end
|
|
28
|
-
size_window(:small, :portrait)
|
|
29
|
-
on_client do
|
|
30
|
-
# patch HyperMesh.connect so it doesn't execute until we say so
|
|
31
|
-
# this is NOT used by the polling connection FYI
|
|
32
|
-
module HyperMesh
|
|
33
|
-
class << self
|
|
34
|
-
alias old_connect connect
|
|
35
|
-
def go_ahead_and_connect
|
|
36
|
-
old_connect(*@connect_args)
|
|
37
|
-
end
|
|
38
|
-
def connect(*args)
|
|
39
|
-
@connect_args = args
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
after(:each) do
|
|
47
|
-
Timecop.return
|
|
48
|
-
wait_for_ajax
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context "Pusher-Fake" do
|
|
52
|
-
before(:all) do
|
|
53
|
-
|
|
54
|
-
require 'pusher'
|
|
55
|
-
require 'pusher-fake'
|
|
56
|
-
Pusher.app_id = "MY_TEST_ID"
|
|
57
|
-
Pusher.key = "MY_TEST_KEY"
|
|
58
|
-
Pusher.secret = "MY_TEST_SECRET"
|
|
59
|
-
require "pusher-fake/support/base"
|
|
60
|
-
|
|
61
|
-
HyperMesh.configuration do |config|
|
|
62
|
-
config.transport = :pusher
|
|
63
|
-
config.channel_prefix = "synchromesh"
|
|
64
|
-
config.opts = {
|
|
65
|
-
app_id: Pusher.app_id,
|
|
66
|
-
key: Pusher.key,
|
|
67
|
-
secret: Pusher.secret,
|
|
68
|
-
auth: {headers: {'X-CSRF-Token': "123"}},
|
|
69
|
-
authEndpoint: "rr/synchromesh-pusher-auth"
|
|
70
|
-
}.merge(PusherFake.configuration.web_options)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "opens the connection" do
|
|
75
|
-
mount "TestComponent"
|
|
76
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
77
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
78
|
-
wait_for { HyperMesh::Connection.active }.to eq(['TestApplication'])
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "will not keep the temporary polled connection open" do
|
|
82
|
-
mount "TestComponent"
|
|
83
|
-
HyperMesh::Connection.active.should =~ ['TestApplication']
|
|
84
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
85
|
-
wait_for { HyperMesh::Connection.active }.to eq([])
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
it "sees the connection going offline" do
|
|
89
|
-
mount "TestComponent"
|
|
90
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
91
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
92
|
-
wait_for { HyperMesh::Connection.active }.to eq(['TestApplication'])
|
|
93
|
-
ApplicationController.acting_user = true
|
|
94
|
-
mount "TestComponent"
|
|
95
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
96
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.refresh_channels_every)
|
|
97
|
-
wait_for { HyperMesh::Connection.active }.to eq([])
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it "receives change notifications" do
|
|
101
|
-
# one tricky thing about synchromesh is that we want to capture all
|
|
102
|
-
# changes to the database that might be made while the client connections
|
|
103
|
-
# is still being initialized. To do this we establish a server side
|
|
104
|
-
# queue of all messages sent between the time the page begins rendering
|
|
105
|
-
# until the connection is established.
|
|
106
|
-
|
|
107
|
-
# mount our test component
|
|
108
|
-
mount "TestComponent"
|
|
109
|
-
# add a model
|
|
110
|
-
TestModel.new(test_attribute: "I'm new here!").save
|
|
111
|
-
# until we connect there should only be 5 items
|
|
112
|
-
page.should have_content("5 items")
|
|
113
|
-
# okay now we can go ahead and connect (this runs on the client)
|
|
114
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
115
|
-
# once we connect it should change to 6
|
|
116
|
-
page.should have_content("6 items")
|
|
117
|
-
# now that we are connected the UI should keep updating
|
|
118
|
-
TestModel.new(test_attribute: "I'm also new here!").save
|
|
119
|
-
page.should have_content("7 items")
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it "receives destroy notifications" do
|
|
123
|
-
mount "TestComponent"
|
|
124
|
-
TestModel.first.destroy
|
|
125
|
-
page.should have_content("5 items")
|
|
126
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
127
|
-
page.should have_content("4 items")
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
context "Simple Polling" do
|
|
132
|
-
|
|
133
|
-
before(:all) do
|
|
134
|
-
HyperMesh.configuration do |config|
|
|
135
|
-
config.transport = :simple_poller
|
|
136
|
-
# slow down the polling so wait_for_ajax works
|
|
137
|
-
config.opts = { seconds_between_poll: 2 }
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it "opens the connection" do
|
|
142
|
-
mount "TestComponent"
|
|
143
|
-
HyperMesh::Connection.active.should =~ ['TestApplication']
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "sees the connection going offline" do
|
|
147
|
-
mount "TestComponent"
|
|
148
|
-
wait_for_ajax
|
|
149
|
-
ApplicationController.acting_user = true
|
|
150
|
-
mount "TestComponent"
|
|
151
|
-
HyperMesh::Connection.active.should =~ ['TestApplication']
|
|
152
|
-
Timecop.travel(Time.now+HyperMesh.expire_polled_connection_in)
|
|
153
|
-
wait(10.seconds).for { HyperMesh::Connection.active }.to eq([])
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it "receives change notifications" do
|
|
157
|
-
mount "TestComponent"
|
|
158
|
-
TestModel.new(test_attribute: "I'm new here!").save
|
|
159
|
-
HyperMesh::Connection.active.should =~ ['TestApplication']
|
|
160
|
-
page.should have_content("6 items")
|
|
161
|
-
HyperMesh::Connection.active.should =~ ['TestApplication']
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
it "receives destroy notifications" do
|
|
165
|
-
mount "TestComponent"
|
|
166
|
-
TestModel.first.destroy
|
|
167
|
-
page.should have_content("4 items")
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
context "Real Pusher Account", skip: (pusher_credentials ? false : SKIP_MESSAGE) do
|
|
173
|
-
|
|
174
|
-
before(:each) do
|
|
175
|
-
require 'pusher'
|
|
176
|
-
Object.send(:remove_const, :PusherFake) if defined?(PusherFake)
|
|
177
|
-
|
|
178
|
-
HyperMesh.configuration do |config|
|
|
179
|
-
config.transport = :pusher
|
|
180
|
-
config.channel_prefix = "synchromesh"
|
|
181
|
-
config.opts = pusher_credentials
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
it "opens the connection" do
|
|
186
|
-
mount "TestComponent"
|
|
187
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
188
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
189
|
-
wait_for { HyperMesh::Connection.active }.to eq(['TestApplication'])
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
it "will not keep the temporary polled connection open" do
|
|
193
|
-
mount "TestComponent"
|
|
194
|
-
HyperMesh::Connection.active.should =~ ['TestApplication']
|
|
195
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
196
|
-
wait_for { HyperMesh::Connection.active }.to eq([])
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
it "sees the connection going offline" do
|
|
200
|
-
mount "TestComponent"
|
|
201
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
202
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
203
|
-
wait_for { HyperMesh::Connection.active }.to eq(['TestApplication'])
|
|
204
|
-
ApplicationController.acting_user = true
|
|
205
|
-
mount "TestComponent"
|
|
206
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
207
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.refresh_channels_every)
|
|
208
|
-
wait_for { HyperMesh::Connection.active }.to eq([])
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
it "receives change notifications" do
|
|
212
|
-
# one tricky thing about synchromesh is that we want to capture all
|
|
213
|
-
# changes to the database that might be made while the client connections
|
|
214
|
-
# is still being initialized. To do this we establish a server side
|
|
215
|
-
# queue of all messages sent between the time the page begins rendering
|
|
216
|
-
# until the connection is established.
|
|
217
|
-
|
|
218
|
-
# mount our test component
|
|
219
|
-
mount "TestComponent"
|
|
220
|
-
# add a model
|
|
221
|
-
TestModel.new(test_attribute: "I'm new here!").save
|
|
222
|
-
# until we connect there should only be 5 items
|
|
223
|
-
page.should have_content("5 items")
|
|
224
|
-
# okay now we can go ahead and connect (this runs on the client)
|
|
225
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
226
|
-
# once we connect it should change to 6
|
|
227
|
-
page.should have_content("6 items")
|
|
228
|
-
# now that we are connected the UI should keep updating
|
|
229
|
-
TestModel.new(test_attribute: "I'm also new here!").save
|
|
230
|
-
page.should have_content("7 items")
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
it "receives destroy notifications" do
|
|
234
|
-
mount "TestComponent"
|
|
235
|
-
TestModel.first.destroy
|
|
236
|
-
page.should have_content("5 items")
|
|
237
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
238
|
-
page.should have_content("4 items")
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
context "Action Cable" do
|
|
244
|
-
|
|
245
|
-
before(:each) do
|
|
246
|
-
HyperMesh.configuration do |config|
|
|
247
|
-
config.transport = :action_cable
|
|
248
|
-
config.channel_prefix = "synchromesh"
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
it "opens the connection" do
|
|
253
|
-
mount "TestComponent"
|
|
254
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
255
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
256
|
-
wait_for { HyperMesh::Connection.active }.to eq(['TestApplication'])
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
it "will not keep the temporary polled connection open" do
|
|
260
|
-
mount "TestComponent"
|
|
261
|
-
HyperMesh::Connection.active.should =~ ['TestApplication']
|
|
262
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
263
|
-
wait_for { HyperMesh::Connection.active }.to eq([])
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
it "sees the connection going offline" do
|
|
267
|
-
mount "TestComponent"
|
|
268
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
269
|
-
Timecop.travel(Time.now+HyperMesh::Connection.transport.expire_new_connection_in)
|
|
270
|
-
wait_for { HyperMesh::Connection.active }.to eq(['TestApplication'])
|
|
271
|
-
ApplicationController.acting_user = true
|
|
272
|
-
mount "TestComponent"
|
|
273
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
274
|
-
wait_for { HyperMesh::Connection.active }.to eq([])
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
it "receives change notifications" do
|
|
278
|
-
# one tricky thing about synchromesh is that we want to capture all
|
|
279
|
-
# changes to the database that might be made while the client connections
|
|
280
|
-
# is still being initialized. To do this we establish a server side
|
|
281
|
-
# queue of all messages sent between the time the page begins rendering
|
|
282
|
-
# until the connection is established.
|
|
283
|
-
|
|
284
|
-
# mount our test component
|
|
285
|
-
mount "TestComponent"
|
|
286
|
-
# add a model
|
|
287
|
-
TestModel.new(test_attribute: "I'm new here!").save
|
|
288
|
-
# until we connect there should only be 5 items
|
|
289
|
-
page.should have_content("5 items")
|
|
290
|
-
# okay now we can go ahead and connect (this runs on the client)
|
|
291
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
292
|
-
# once we connect it should change to 6
|
|
293
|
-
page.should have_content("6 items")
|
|
294
|
-
# now that we are connected the UI should keep updating
|
|
295
|
-
TestModel.new(test_attribute: "I'm also new here!").save
|
|
296
|
-
page.should have_content("7 items")
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
it "receives destroy notifications" do
|
|
300
|
-
mount "TestComponent"
|
|
301
|
-
TestModel.first.destroy
|
|
302
|
-
page.should have_content("5 items")
|
|
303
|
-
evaluate_ruby "HyperMesh.go_ahead_and_connect"
|
|
304
|
-
page.should have_content("4 items")
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
end
|
|
308
|
-
end
|