-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
90 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.log | ||
*.sqlite3 | ||
*.sqlite3-shm | ||
*.sqlite3-wal | ||
tmp/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require_relative "config/application" | ||
|
||
Rails.application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module ApplicationCable | ||
class Channel < ActionCable::Channel::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module ApplicationCable | ||
class Connection < ActionCable::Connection::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Message < ActiveRecord::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
development: | ||
adapter: async | ||
|
||
test: | ||
adapter: inline | ||
|
||
production: | ||
adapter: redis | ||
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> | ||
channel_prefix: dummy_production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
default: &default | ||
adapter: sqlite3 | ||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | ||
timeout: 5000 | ||
|
||
test: | ||
adapter: sqlite3 | ||
database: db/combustion_test.sqlite | ||
<<: *default | ||
database: db/test.sqlite3 | ||
|
||
development: | ||
<<: *default | ||
database: db/development.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class TurboPower::BroadcastableTest < ActionCable::Channel::TestCase | ||
include ::Turbo::Broadcastable::TestHelper | ||
module TurboPower | ||
class BroadcastableTest < ActionCable::Channel::TestCase | ||
include ::Turbo::Broadcastable::TestHelper | ||
|
||
test "broadcast_dispatch_event" do | ||
message = Message.new(id: 1) | ||
test "broadcast_dispatch_event" do | ||
message = Message.new(id: 1) | ||
|
||
detail = { id: message.id, action: "save" } | ||
message.broadcast_dispatch_event(target: dom_id(message), name: "saved", detail: detail) | ||
detail = { id: message.id, action: "save" } | ||
message.broadcast_dispatch_event(target: dom_id(message), name: "saved", detail: detail) | ||
|
||
streams = capture_turbo_stream_broadcasts(message) | ||
streams = capture_turbo_stream_broadcasts(message) | ||
|
||
assert_equal 1, streams.length | ||
assert_equal "message_1", streams.first["target"] | ||
assert_equal "dispatch_event", streams.first["action"] | ||
assert_equal 1, streams.length | ||
assert_equal "message_1", streams.first["target"] | ||
assert_equal "dispatch_event", streams.first["action"] | ||
|
||
template_content = detail.to_json | ||
assert_equal template_content, streams.first.at_css("template").content | ||
end | ||
template_content = detail.to_json | ||
assert_equal template_content, streams.first.at_css("template").content | ||
end | ||
|
||
test "broadcast_dispatch_event_to" do | ||
message = Message.new(id: 1) | ||
test "broadcast_dispatch_event_to" do | ||
message = Message.new(id: 1) | ||
|
||
detail = { id: message.id, action: "save" } | ||
message.broadcast_dispatch_event_to("messages", target: dom_id(message), name: "saved", detail: detail) | ||
detail = { id: message.id, action: "save" } | ||
message.broadcast_dispatch_event_to("messages", target: dom_id(message), name: "saved", detail: detail) | ||
|
||
streams = capture_turbo_stream_broadcasts("messages") | ||
streams = capture_turbo_stream_broadcasts("messages") | ||
|
||
assert_equal 1, streams.length | ||
assert_equal "message_1", streams.first["target"] | ||
assert_equal "dispatch_event", streams.first["action"] | ||
assert_equal 1, streams.length | ||
assert_equal "message_1", streams.first["target"] | ||
assert_equal "dispatch_event", streams.first["action"] | ||
|
||
template_content = detail.to_json | ||
assert_equal template_content, streams.first.at_css("template").content | ||
template_content = detail.to_json | ||
assert_equal template_content, streams.first.at_css("template").content | ||
end | ||
end | ||
end |