mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Add very basic tests for the websockets channels
This commit is contained in:
parent
ea9ce874be
commit
92c9702b23
3 changed files with 34 additions and 25 deletions
|
|
@ -4,32 +4,15 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe ImportsChannel, type: :channel do
|
||||
let(:user) { create(:user) }
|
||||
let(:import) { create(:import) }
|
||||
|
||||
before { stub_connection current_user: user }
|
||||
|
||||
describe '#subscribe' do
|
||||
it 'confirms the subscription and subscribes to a stream' do
|
||||
subscribe(import_id: import.id)
|
||||
|
||||
expect(subscription).to be_confirmed
|
||||
expect(subscription).to have_stream_for(import)
|
||||
end
|
||||
|
||||
it 'rejects the subscription without import_id' do
|
||||
subscribe
|
||||
|
||||
expect(subscription).to be_rejected
|
||||
end
|
||||
before do
|
||||
stub_connection(current_user: user)
|
||||
end
|
||||
|
||||
describe '#broadcast' do
|
||||
it 'broadcasts a message to the stream' do
|
||||
subscribe(import_id: import.id)
|
||||
it 'subscribes to a stream for the current user' do
|
||||
subscribe
|
||||
|
||||
expect do
|
||||
ImportsChannel.broadcast_to(import, message: 'Test message')
|
||||
end.to have_broadcasted_to(import).with(message: 'Test message')
|
||||
end
|
||||
expect(subscription).to be_confirmed
|
||||
expect(subscription).to have_stream_for(user)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe NotificationsChannel, type: :channel do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
stub_connection(current_user: user)
|
||||
end
|
||||
|
||||
it 'subscribes to a stream for the current user' do
|
||||
subscribe
|
||||
|
||||
expect(subscription).to be_confirmed
|
||||
expect(subscription).to have_stream_for(user)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PointsChannel, type: :channel do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
stub_connection(current_user: user)
|
||||
end
|
||||
|
||||
it 'subscribes to a stream for the current user' do
|
||||
subscribe
|
||||
|
||||
expect(subscription).to be_confirmed
|
||||
expect(subscription).to have_stream_for(user)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue