-
Notifications
You must be signed in to change notification settings - Fork 20
/
request_without_subscribe_spec.rb
58 lines (46 loc) · 1.38 KB
/
request_without_subscribe_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true
require 'rails_helper'
describe 'Request logux server without subscribe' do
subject(:request_logux) do
post('/logux',
params: logux_params,
as: :json)
end
let(:password) { Logux.configuration.password }
let(:logux_params) do
{ version: 0,
password: password,
commands: [
['action',
{ type: 'logux/subscribe', channel: channel },
{ time: Time.now.to_i, id: '219_856_768 clientid 0', userId: 1 }]
] }
end
context 'when verify_authorized=true' do
before { Logux.configuration.verify_authorized = true }
context 'when policy not exists' do
let(:channel) { 'notexists/123' }
it 'returns unknownChannel' do
request_logux
expect(response.stream).to have_chunk(
['unknownChannel', '219_856_768 clientid 0']
)
end
end
context 'when policy is exists' do
let(:channel) { 'policy_without_channel/123' }
it 'returns processed' do
request_logux
expect(response).to be_processed('219_856_768 clientid 0')
end
end
end
context 'when verify_authorized=false' do
let(:channel) { 'notexists/123' }
before { Logux.configuration.verify_authorized = false }
it 'returns processed' do
request_logux
expect(response).to be_processed('219_856_768 clientid 0')
end
end
end