cubism 0.2.1 → 0.2.2

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +6 -11
  3. data/Gemfile.lock +278 -126
  4. data/app/helpers/cubism_helper.rb +3 -1
  5. data/cubism.gemspec +3 -4
  6. data/lib/cubism/broadcaster.rb +7 -3
  7. data/lib/cubism/cubicle_store.rb +9 -2
  8. data/lib/cubism/preprocessor.rb +4 -1
  9. data/lib/cubism/version.rb +1 -1
  10. data/package.json +1 -1
  11. metadata +7 -95
  12. data/test/block_container_test.rb +0 -105
  13. data/test/block_source_test.rb +0 -102
  14. data/test/broadcaster_test.rb +0 -66
  15. data/test/channels/cubism/presence_channel_test.rb +0 -72
  16. data/test/cubicle_store_test.rb +0 -34
  17. data/test/cubism_test.rb +0 -7
  18. data/test/dummy/app/channels/application_cable/channel.rb +0 -4
  19. data/test/dummy/app/channels/application_cable/connection.rb +0 -4
  20. data/test/dummy/app/controllers/application_controller.rb +0 -2
  21. data/test/dummy/app/helpers/application_helper.rb +0 -2
  22. data/test/dummy/app/jobs/application_job.rb +0 -7
  23. data/test/dummy/app/mailers/application_mailer.rb +0 -4
  24. data/test/dummy/app/models/application_record.rb +0 -3
  25. data/test/dummy/app/models/post.rb +0 -3
  26. data/test/dummy/app/models/user.rb +0 -3
  27. data/test/dummy/config/application.rb +0 -22
  28. data/test/dummy/config/boot.rb +0 -5
  29. data/test/dummy/config/environment.rb +0 -5
  30. data/test/dummy/config/environments/development.rb +0 -76
  31. data/test/dummy/config/environments/production.rb +0 -120
  32. data/test/dummy/config/environments/test.rb +0 -59
  33. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
  34. data/test/dummy/config/initializers/assets.rb +0 -12
  35. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -8
  36. data/test/dummy/config/initializers/content_security_policy.rb +0 -28
  37. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -6
  39. data/test/dummy/config/initializers/inflections.rb +0 -16
  40. data/test/dummy/config/initializers/mime_types.rb +0 -4
  41. data/test/dummy/config/initializers/permissions_policy.rb +0 -11
  42. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  43. data/test/dummy/config/puma.rb +0 -43
  44. data/test/dummy/config/routes.rb +0 -3
  45. data/test/dummy/db/migrate/20220102072929_create_posts.rb +0 -10
  46. data/test/dummy/db/migrate/20220102073003_create_users.rb +0 -9
  47. data/test/dummy/db/schema.rb +0 -26
  48. data/test/dummy/test/models/post_test.rb +0 -7
  49. data/test/dummy/test/models/user_test.rb +0 -7
  50. data/test/helpers/cubism_helper_test.rb +0 -39
  51. data/test/integration/navigation_test.rb +0 -7
  52. data/test/models/concerns/presence_test.rb +0 -25
  53. data/test/models/concerns/user_test.rb +0 -9
  54. data/test/rendering/preprocessor_test.rb +0 -61
  55. data/test/test_helper.rb +0 -22
@@ -36,7 +36,10 @@ module Cubism
36
36
  def evaluate_view(erubi, view_context)
37
37
  view = Class.new(ActionView::Base) {
38
38
  include view_context._routes.url_helpers
39
- class_eval("define_method(:_template) { |local_assigns, output_buffer| #{erubi.src} }", erubi.filename.nil? ? "(erubi)" : erubi.filename, 0)
39
+
40
+ # Deliberately not __FILE__/__LINE__: the eval'd source is the user's
41
+ # template, so backtraces have to point there and not at this file.
42
+ class_eval("define_method(:_template) { |local_assigns, output_buffer| #{erubi.src} }", erubi.filename.nil? ? "(erubi)" : erubi.filename, 0) # standard:disable Style/EvalWithLocation
40
43
  }.empty
41
44
  view._run(:_template, nil, {}, ActionView::OutputBuffer.new)
42
45
  end
@@ -1,3 +1,3 @@
1
1
  module Cubism
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minthesize/cubism",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Lightweight Resource-Based Presence Solution with CableReady.",
5
5
  "main": "./dist/cubism.umd.min.js",
6
6
  "module": "./dist/cubism.min.js",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cubism
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '6.0'
18
+ version: '7.2'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '6.0'
25
+ version: '7.2'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: kredis
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '0'
74
+ version: 1.35.1
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '0'
81
+ version: 1.35.1
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: nokogiri
84
84
  requirement: !ruby/object:Gem::Requirement
@@ -179,50 +179,6 @@ files:
179
179
  - package.json~
180
180
  - rollup.config.js
181
181
  - rollup.config.js~
182
- - test/block_container_test.rb
183
- - test/block_source_test.rb
184
- - test/broadcaster_test.rb
185
- - test/channels/cubism/presence_channel_test.rb
186
- - test/cubicle_store_test.rb
187
- - test/cubism_test.rb
188
- - test/dummy/app/channels/application_cable/channel.rb
189
- - test/dummy/app/channels/application_cable/connection.rb
190
- - test/dummy/app/controllers/application_controller.rb
191
- - test/dummy/app/helpers/application_helper.rb
192
- - test/dummy/app/jobs/application_job.rb
193
- - test/dummy/app/mailers/application_mailer.rb
194
- - test/dummy/app/models/application_record.rb
195
- - test/dummy/app/models/post.rb
196
- - test/dummy/app/models/user.rb
197
- - test/dummy/config/application.rb
198
- - test/dummy/config/boot.rb
199
- - test/dummy/config/environment.rb
200
- - test/dummy/config/environments/development.rb
201
- - test/dummy/config/environments/production.rb
202
- - test/dummy/config/environments/test.rb
203
- - test/dummy/config/initializers/application_controller_renderer.rb
204
- - test/dummy/config/initializers/assets.rb
205
- - test/dummy/config/initializers/backtrace_silencers.rb
206
- - test/dummy/config/initializers/content_security_policy.rb
207
- - test/dummy/config/initializers/cookies_serializer.rb
208
- - test/dummy/config/initializers/filter_parameter_logging.rb
209
- - test/dummy/config/initializers/inflections.rb
210
- - test/dummy/config/initializers/mime_types.rb
211
- - test/dummy/config/initializers/permissions_policy.rb
212
- - test/dummy/config/initializers/wrap_parameters.rb
213
- - test/dummy/config/puma.rb
214
- - test/dummy/config/routes.rb
215
- - test/dummy/db/migrate/20220102072929_create_posts.rb
216
- - test/dummy/db/migrate/20220102073003_create_users.rb
217
- - test/dummy/db/schema.rb
218
- - test/dummy/test/models/post_test.rb
219
- - test/dummy/test/models/user_test.rb
220
- - test/helpers/cubism_helper_test.rb
221
- - test/integration/navigation_test.rb
222
- - test/models/concerns/presence_test.rb
223
- - test/models/concerns/user_test.rb
224
- - test/rendering/preprocessor_test.rb
225
- - test/test_helper.rb
226
182
  - yarn.lock
227
183
  homepage: https://github.com/julianrubisch/cubism
228
184
  licenses:
@@ -237,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
193
  requirements:
238
194
  - - ">="
239
195
  - !ruby/object:Gem::Version
240
- version: '0'
196
+ version: '3.2'
241
197
  required_rubygems_version: !ruby/object:Gem::Requirement
242
198
  requirements:
243
199
  - - ">="
@@ -247,48 +203,4 @@ requirements: []
247
203
  rubygems_version: 3.6.7
248
204
  specification_version: 4
249
205
  summary: Lightweight Resource-Based Presence Solution with CableReady
250
- test_files:
251
- - test/block_container_test.rb
252
- - test/block_source_test.rb
253
- - test/broadcaster_test.rb
254
- - test/channels/cubism/presence_channel_test.rb
255
- - test/cubicle_store_test.rb
256
- - test/cubism_test.rb
257
- - test/dummy/app/channels/application_cable/channel.rb
258
- - test/dummy/app/channels/application_cable/connection.rb
259
- - test/dummy/app/controllers/application_controller.rb
260
- - test/dummy/app/helpers/application_helper.rb
261
- - test/dummy/app/jobs/application_job.rb
262
- - test/dummy/app/mailers/application_mailer.rb
263
- - test/dummy/app/models/application_record.rb
264
- - test/dummy/app/models/post.rb
265
- - test/dummy/app/models/user.rb
266
- - test/dummy/config/application.rb
267
- - test/dummy/config/boot.rb
268
- - test/dummy/config/environment.rb
269
- - test/dummy/config/environments/development.rb
270
- - test/dummy/config/environments/production.rb
271
- - test/dummy/config/environments/test.rb
272
- - test/dummy/config/initializers/application_controller_renderer.rb
273
- - test/dummy/config/initializers/assets.rb
274
- - test/dummy/config/initializers/backtrace_silencers.rb
275
- - test/dummy/config/initializers/content_security_policy.rb
276
- - test/dummy/config/initializers/cookies_serializer.rb
277
- - test/dummy/config/initializers/filter_parameter_logging.rb
278
- - test/dummy/config/initializers/inflections.rb
279
- - test/dummy/config/initializers/mime_types.rb
280
- - test/dummy/config/initializers/permissions_policy.rb
281
- - test/dummy/config/initializers/wrap_parameters.rb
282
- - test/dummy/config/puma.rb
283
- - test/dummy/config/routes.rb
284
- - test/dummy/db/migrate/20220102072929_create_posts.rb
285
- - test/dummy/db/migrate/20220102073003_create_users.rb
286
- - test/dummy/db/schema.rb
287
- - test/dummy/test/models/post_test.rb
288
- - test/dummy/test/models/user_test.rb
289
- - test/helpers/cubism_helper_test.rb
290
- - test/integration/navigation_test.rb
291
- - test/models/concerns/presence_test.rb
292
- - test/models/concerns/user_test.rb
293
- - test/rendering/preprocessor_test.rb
294
- - test/test_helper.rb
206
+ test_files: []
@@ -1,105 +0,0 @@
1
- require "test_helper"
2
-
3
- class BlockContainerTest < ActiveSupport::TestCase
4
- FIXTURES_DIR = File.expand_path("./fixtures", __dir__)
5
-
6
- setup do
7
- @cwd = Dir.pwd
8
- @tmp_dir = Dir.mktmpdir
9
-
10
- FileUtils.cp_r FIXTURES_DIR, @tmp_dir
11
- Dir.chdir @tmp_dir
12
-
13
- @post = posts(:one)
14
- @user = users(:one)
15
- end
16
-
17
- teardown do
18
- Dir.chdir @cwd
19
- FileUtils.rm_r @tmp_dir
20
- end
21
-
22
- test "block container digest changes when file contents change" do
23
- template = "fixtures/_cubicle_partial"
24
-
25
- digest1 = Cubism::BlockContainer.new(
26
- block_location: "#{template_tmp_path(template)}.html.erb:1",
27
- resource_gid: @post.to_gid.to_s,
28
- user_gid: @user.to_gid.to_s
29
- ).digest
30
-
31
- change_template(template)
32
-
33
- digest2 = Cubism::BlockContainer.new(
34
- block_location: "#{template_tmp_path(template)}.html.erb:1",
35
- resource_gid: @post.to_gid.to_s,
36
- user_gid: @user.to_gid.to_s
37
- ).digest
38
-
39
- refute_equal digest1, digest2
40
- end
41
-
42
- test "block container digest changes when user changes" do
43
- template = "fixtures/_cubicle_partial"
44
-
45
- digest1 = Cubism::BlockContainer.new(
46
- block_location: "#{template_tmp_path(template)}.html.erb:1",
47
- resource_gid: @post.to_gid.to_s,
48
- user_gid: @user.to_gid.to_s
49
- ).digest
50
-
51
- digest2 = Cubism::BlockContainer.new(
52
- block_location: "#{template_tmp_path(template)}.html.erb:1",
53
- resource_gid: @post.to_gid.to_s,
54
- user_gid: users(:two).to_gid.to_s
55
- ).digest
56
-
57
- refute_equal digest1, digest2
58
- end
59
-
60
- test "block container digest changes when resource changes" do
61
- template = "fixtures/_cubicle_partial"
62
-
63
- digest1 = Cubism::BlockContainer.new(
64
- block_location: "#{template_tmp_path(template)}.html.erb:1",
65
- resource_gid: @post.to_gid.to_s,
66
- user_gid: @user.to_gid.to_s
67
- ).digest
68
-
69
- digest2 = Cubism::BlockContainer.new(
70
- block_location: "#{template_tmp_path(template)}.html.erb:1",
71
- resource_gid: posts(:two).to_gid.to_s,
72
- user_gid: @user.to_gid.to_s
73
- ).digest
74
-
75
- refute_equal digest1, digest2
76
- end
77
-
78
- test "block container digest changes when block_location changes" do
79
- template = "fixtures/_cubicle_partial"
80
-
81
- digest1 = Cubism::BlockContainer.new(
82
- block_location: "#{template_tmp_path(template)}.html.erb:1",
83
- resource_gid: @post.to_gid.to_s,
84
- user_gid: @user.to_gid.to_s
85
- ).digest
86
-
87
- digest2 = Cubism::BlockContainer.new(
88
- block_location: "#{template_tmp_path(template)}.html.erb:2",
89
- resource_gid: @post.to_gid.to_s,
90
- user_gid: @user.to_gid.to_s
91
- ).digest
92
-
93
- refute_equal digest1, digest2
94
- end
95
-
96
- private
97
-
98
- def template_tmp_path(template)
99
- Pathname.new(@tmp_dir).join(template).to_path
100
- end
101
-
102
- def change_template(template)
103
- File.write("#{template}.html.erb", "\nTHIS WAS CHANGED!")
104
- end
105
- end
@@ -1,102 +0,0 @@
1
- require "test_helper"
2
-
3
- class BlockSourceTest < ActionView::TestCase
4
- FIXTURES_DIR = File.expand_path("./fixtures", __dir__)
5
-
6
- setup do
7
- @cwd = Dir.pwd
8
- @tmp_dir = Dir.mktmpdir
9
-
10
- FileUtils.cp_r FIXTURES_DIR, @tmp_dir
11
- Dir.chdir @tmp_dir
12
-
13
- @post = posts(:one)
14
- @user = users(:one)
15
- end
16
-
17
- teardown do
18
- Dir.chdir @cwd
19
- FileUtils.rm_r @tmp_dir
20
- end
21
-
22
- test "block source digest changes when file contents change" do
23
- template = "fixtures/_cubicle_partial"
24
-
25
- digest1 = Cubism::BlockSource.new(
26
- location: "#{template_tmp_path(template)}.html.erb:1",
27
- view_context: self
28
- ).digest
29
-
30
- change_template(template)
31
-
32
- digest2 = Cubism::BlockSource.new(
33
- location: "#{template_tmp_path(template)}.html.erb:1",
34
- view_context: self
35
- ).digest
36
-
37
- refute_equal digest1, digest2
38
- end
39
-
40
- test "block source digest changes when block_location changes" do
41
- template = "fixtures/_cubicle_partial"
42
-
43
- digest1 = Cubism::BlockSource.new(
44
- location: "#{template_tmp_path(template)}.html.erb:1",
45
- view_context: self
46
- ).digest
47
-
48
- digest2 = Cubism::BlockSource.new(
49
- location: "#{template_tmp_path(template)}.html.erb:2",
50
- view_context: self
51
- ).digest
52
-
53
- refute_equal digest1, digest2
54
- end
55
-
56
- test "can be created in the store by source location" do
57
- template = "fixtures/_cubicle_partial"
58
-
59
- assert_equal 0, Cubism.source_store.size
60
-
61
- Cubism::BlockSource.any_instance.expects(:parse!).once
62
-
63
- Cubism::BlockSource.find_or_create(
64
- location: "#{template_tmp_path(template)}.html.erb:1",
65
- view_context: self
66
- )
67
-
68
- assert_equal 1, Cubism.source_store.size
69
- end
70
-
71
- test "existing block source is returned and not parsed" do
72
- template = "fixtures/_cubicle_partial"
73
-
74
- instance = Cubism::BlockSource.new(
75
- location: "#{template_tmp_path(template)}.html.erb:1",
76
- view_context: self
77
- )
78
-
79
- Cubism.source_store[instance.digest] = instance
80
-
81
- assert_equal 1, Cubism.source_store.size
82
-
83
- Cubism::BlockSource.any_instance.expects(:parse!).never
84
-
85
- Cubism::BlockSource.find_or_create(
86
- location: "#{template_tmp_path(template)}.html.erb:1",
87
- view_context: self
88
- )
89
-
90
- assert_equal 1, Cubism.source_store.size
91
- end
92
-
93
- private
94
-
95
- def template_tmp_path(template)
96
- Pathname.new(@tmp_dir).join(template).to_path
97
- end
98
-
99
- def change_template(template)
100
- File.write("#{template}.html.erb", "\nTHIS WAS CHANGED!")
101
- end
102
- end
@@ -1,66 +0,0 @@
1
- require "test_helper"
2
-
3
- class BroadcasterTest < ActionView::TestCase
4
- include CableReady::StreamIdentifier
5
-
6
- setup do
7
- @post = posts(:one)
8
- @post.stubs(:cubicle_element_ids).returns(%w[foo bar])
9
- @post.stubs(:present_users_for_element_id_and_scope).with("foo", "").returns([users(:one)])
10
- @post.stubs(:present_users_for_element_id_and_scope).with("bar", "").returns([users(:two)])
11
-
12
- @post_2 = posts(:two)
13
- @post_2.stubs(:cubicle_element_ids).returns(%w[baz])
14
- @post_2.stubs(:present_users_for_element_id_and_scope).with("baz", :edit).returns([users(:one)])
15
- @post_2.stubs(:present_users_for_element_id_and_scope).with("baz", :show).returns([])
16
-
17
- block_source_foo = Cubism::BlockSource.new(location: "test:1", variable_name: "users", source: "<div><%= users.map(&:username).to_sentence %></div>", view_context: self)
18
- block_source_bar = Cubism::BlockSource.new(location: "test:1", variable_name: "present_users", source: "<div><%= present_users.map(&:username).to_sentence %></div>", view_context: self)
19
-
20
- Cubism.stubs(:block_store).returns({
21
- "foo" => Cubism::BlockContainer.new(block_location: "test:1", block_source: block_source_foo, user_gid: users(:one).to_gid.to_s, resource_gid: posts(:one).to_gid.to_s),
22
- "bar" => Cubism::BlockContainer.new(block_location: "test:1", block_source: block_source_bar, user_gid: users(:two).to_gid.to_s, resource_gid: posts(:one).to_gid.to_s),
23
- "baz" => Cubism::BlockContainer.new(block_location: "test:1", block_source: block_source_foo, user_gid: users(:one).to_gid.to_s, resource_gid: posts(:two).to_gid.to_s, scope: :edit)
24
- })
25
- end
26
-
27
- test "it broadcasts to all registered element ids with default scopes" do
28
- with_mocked_cable_ready({"foo" => {"" => users(:one)}, "bar" => {"" => users(:two)}}, @post) do |cable_ready_mock|
29
- @broadcaster = Cubism::Broadcaster.new(resource: @post)
30
-
31
- @broadcaster.expects(:cable_ready).returns(cable_ready_mock).times(3)
32
-
33
- @broadcaster.broadcast
34
- end
35
- end
36
-
37
- test "it broadcasts to all registered element ids and respects scopes" do
38
- with_mocked_cable_ready({"baz" => {"edit" => users(:one)}}, @post_2) do |cable_ready_mock|
39
- @broadcaster = Cubism::Broadcaster.new(resource: @post_2)
40
-
41
- @broadcaster.expects(:cable_ready).returns(cable_ready_mock).twice
42
-
43
- @broadcaster.broadcast
44
- end
45
- end
46
- end
47
-
48
- def with_mocked_cable_ready(elements_with_users_and_scopes, resource)
49
- cable_ready_mock = mock
50
- cable_ready_mock.expects(:broadcast).once
51
-
52
- elements_with_users_and_scopes.each do |element_id, scoped_users|
53
- cable_ready_channel = mock
54
- scoped_users.each do |scope, user|
55
- cable_ready_channel
56
- .expects(:inner_html)
57
- .with({
58
- selector: "cubicle-element#cubicle-#{element_id}[identifier='#{signed_stream_identifier(resource.to_global_id.to_s)}']",
59
- html: "<div>#{user.username}</div>"
60
- })
61
- end
62
- cable_ready_mock.expects(:[]).with(element_id).returns(cable_ready_channel)
63
- end
64
-
65
- yield cable_ready_mock
66
- end
@@ -1,72 +0,0 @@
1
- require "test_helper"
2
-
3
- class Cubism::PresenceChannelTest < ActionCable::Channel::TestCase
4
- include CableReady::StreamIdentifier
5
-
6
- setup do
7
- @post = posts(:one)
8
- @user = users(:one)
9
-
10
- Post.any_instance.stubs(:cubicle_element_ids).returns([])
11
- Post.any_instance.stubs(:excluded_user_id_for_element_id).returns({})
12
- Post.any_instance.stubs(:present_users).returns({})
13
-
14
- Cubism.stubs(:block_store).returns({
15
- "foo" => Cubism::BlockContainer.new(block_location: "test:1", user_gid: @user.to_gid.to_s, resource_gid: @post.to_gid.to_s, scope: ""),
16
- "bar" => Cubism::BlockContainer.new(block_location: "test:1", user_gid: @user.to_gid.to_s, resource_gid: @post.to_gid.to_s, scope: "edit")
17
- })
18
- end
19
-
20
- test "rejects a subscription for invalid identifiers" do
21
- subscribe identifier: "foo", element_id: "cubicle-bar"
22
-
23
- assert subscription.rejected?
24
- end
25
-
26
- test "confirms a subscription for valid identifiers" do
27
- subscribe identifier: signed_stream_identifier(@post.to_gid.to_s), element_id: "cubicle-bar"
28
-
29
- assert subscription.confirmed?
30
-
31
- assert_has_stream "bar"
32
- assert_equal 1, @post.cubicle_element_ids.size
33
- end
34
-
35
- test "adds user_id to the excluded users hash if the exclude_current_user param is passed" do
36
- subscribe identifier: signed_stream_identifier(@post.to_gid.to_s), element_id: "cubicle-bar", exclude_current_user: true
37
-
38
- assert_equal({"bar" => @user.id}, @post.excluded_user_id_for_element_id)
39
- end
40
-
41
- test "adds a user to the present users list when appear is called" do
42
- subscribe identifier: signed_stream_identifier(@post.to_gid.to_s), element_id: "cubicle-foo"
43
- perform :appear
44
-
45
- assert_equal [@user.id], @post.present_users_for_scope("").to_a
46
- end
47
-
48
- test "adds a user to a scope in the present users list when appear is called with a scope parameter" do
49
- assert_equal [], @post.present_users_for_scope("edit").to_a
50
- assert_equal [], @post.present_users_for_scope("show").to_a
51
-
52
- subscribe identifier: signed_stream_identifier(@post.to_gid.to_s), element_id: "cubicle-bar", scope: "edit"
53
- perform :appear
54
-
55
- subscribe identifier: signed_stream_identifier(@post.to_gid.to_s), element_id: "bar", scope: "show"
56
-
57
- assert_equal [@user.id], @post.present_users_for_scope("edit").to_a
58
- assert_equal [], @post.present_users_for_scope("show").to_a
59
- end
60
-
61
- test "removes a user from the present users list when disappear is called" do
62
- subscribe identifier: signed_stream_identifier(@post.to_gid.to_s), element_id: "cubicle-foo"
63
-
64
- perform :appear
65
-
66
- assert_equal [@user.id], @post.present_users_for_scope("").to_a
67
-
68
- perform :disappear
69
-
70
- assert_equal [], @post.present_users_for_scope("").to_a
71
- end
72
- end
@@ -1,34 +0,0 @@
1
- require "test_helper"
2
-
3
- class CubicleStoreTest < ActiveSupport::TestCase
4
- setup do
5
- @store = Cubism::CubicleStore.new("cubism-test")
6
- end
7
-
8
- test "empty value just retrieves the key" do
9
- @store["foo"] = "bar"
10
-
11
- value = @store.fetch("foo")
12
-
13
- refute_nil @store["foo"]
14
- assert_equal "bar", value
15
- end
16
-
17
- test "fetch assigns value to empty key" do
18
- assert_nil @store["foo"]
19
-
20
- value = @store.fetch("foo", "bar")
21
-
22
- refute_nil @store["foo"]
23
- assert_equal "bar", value
24
- end
25
-
26
- test "fetch retrieves value for existing key, and does not overwrite it" do
27
- @store["foo"] = "baz"
28
-
29
- value = @store.fetch("foo", "bar")
30
-
31
- refute_nil @store["foo"]
32
- assert_equal "baz", value
33
- end
34
- end
data/test/cubism_test.rb DELETED
@@ -1,7 +0,0 @@
1
- require "test_helper"
2
-
3
- class CubismTest < ActiveSupport::TestCase
4
- test "it has a version number" do
5
- assert Cubism::VERSION
6
- end
7
- end
@@ -1,4 +0,0 @@
1
- module ApplicationCable
2
- class Channel < ActionCable::Channel::Base
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module ApplicationCable
2
- class Connection < ActionCable::Connection::Base
3
- end
4
- end
@@ -1,2 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,7 +0,0 @@
1
- class ApplicationJob < ActiveJob::Base
2
- # Automatically retry jobs that encountered a deadlock
3
- # retry_on ActiveRecord::Deadlocked
4
-
5
- # Most jobs are safe to ignore if the underlying records are no longer available
6
- # discard_on ActiveJob::DeserializationError
7
- end
@@ -1,4 +0,0 @@
1
- class ApplicationMailer < ActionMailer::Base
2
- default from: "from@example.com"
3
- layout "mailer"
4
- end
@@ -1,3 +0,0 @@
1
- class ApplicationRecord < ActiveRecord::Base
2
- self.abstract_class = true
3
- end
@@ -1,3 +0,0 @@
1
- class Post < ApplicationRecord
2
- include Cubism::Presence
3
- end
@@ -1,3 +0,0 @@
1
- class User < ApplicationRecord
2
- include Cubism::User
3
- end
@@ -1,22 +0,0 @@
1
- require_relative "boot"
2
-
3
- require "rails/all"
4
-
5
- # Require the gems listed in Gemfile, including any gems
6
- # you've limited to :test, :development, or :production.
7
- Bundler.require(*Rails.groups)
8
- require "cubism"
9
-
10
- module Dummy
11
- class Application < Rails::Application
12
- config.load_defaults Rails::VERSION::STRING.to_f
13
-
14
- # Configuration for the application, engines, and railties goes here.
15
- #
16
- # These settings can be overridden in specific environments using the files
17
- # in config/environments, which are processed later.
18
- #
19
- # config.time_zone = "Central Time (US & Canada)"
20
- # config.eager_load_paths << Rails.root.join("extras")
21
- end
22
- end
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
3
-
4
- require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
5
- $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
@@ -1,5 +0,0 @@
1
- # Load the Rails application.
2
- require_relative "application"
3
-
4
- # Initialize the Rails application.
5
- Rails.application.initialize!