Skip to content

Commit

Permalink
Test Action Cable action in Rails app
Browse files Browse the repository at this point in the history
Make sure we add a scenario that actually triggers an Action Cable
action so that we can test if it's instrumented.
  • Loading branch information
tombruijn committed Jul 10, 2024
1 parent 814e709 commit fa91415
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ruby/rails7-sidekiq/app/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: /integration
specs:
appsignal (3.9.1)
appsignal (3.10.0)
rack

GEM
Expand Down
8 changes: 8 additions & 0 deletions ruby/rails7-sidekiq/app/app/channels/chat_room_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ def echo(data)
data.delete("action")
transmit data
end

def add_connected_message
message = ChatMessage.new(
:body => "You're connected to the chat room!",
:created_at => Time.zone.now,
)
transmit message
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if (chatRoomId) {
consumer.subscriptions.create({ channel: "ChatRoomChannel", chat_room_id: chatRoomId }, {
connected() {
console.log(`Subscribed to ${chatRoomId}`)
// You would do this from the channel itself, but this triggers an action
// in the Channel so that we can test if instrument the action.
this.perform("add_connected_message")
},

disconnected() {
Expand Down

0 comments on commit fa91415

Please sign in to comment.