mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31: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
|
RSpec.describe ImportsChannel, type: :channel do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:import) { create(:import) }
|
|
||||||
|
|
||||||
before { stub_connection current_user: user }
|
before do
|
||||||
|
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#broadcast' do
|
it 'subscribes to a stream for the current user' do
|
||||||
it 'broadcasts a message to the stream' do
|
subscribe
|
||||||
subscribe(import_id: import.id)
|
|
||||||
|
|
||||||
expect do
|
expect(subscription).to be_confirmed
|
||||||
ImportsChannel.broadcast_to(import, message: 'Test message')
|
expect(subscription).to have_stream_for(user)
|
||||||
end.to have_broadcasted_to(import).with(message: 'Test message')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,18 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe NotificationsChannel, type: :channel do
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,18 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe PointsChannel, type: :channel do
|
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
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue