Skip to content

Commit b6d1747

Browse files
committed
closes #98
1 parent 095727c commit b6d1747

File tree

3 files changed

+11
-46
lines changed

3 files changed

+11
-46
lines changed

ruby/hyper-operation/lib/hyper-operation/transport/policy.rb

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def initialize(regulated_klass)
2121
EXPOSED_METHODS = [
2222
:regulate_class_connection, :always_allow_connection, :regulate_instance_connections,
2323
:regulate_all_broadcasts, :regulate_broadcast,
24-
:dispatch_to, :regulate_dispatches_from, :always_dispatch_from,
24+
:regulate_dispatches_from, :always_dispatch_from,
2525
:allow_change, :allow_create, :allow_read, :allow_update, :allow_destroy
2626
]
2727

@@ -58,21 +58,6 @@ def always_dispatch_from(*args, &regulation)
5858
regulate_dispatches_from(*args) { true }
5959
end
6060

61-
def dispatch_to(*args, &regulation)
62-
actual_klass = if regulated_klass.is_a?(Class)
63-
regulated_klass
64-
else
65-
begin
66-
regulated_klass.constantize
67-
rescue NameError
68-
nil
69-
end
70-
end
71-
raise 'you can only dispatch_to Operation classes' unless actual_klass.respond_to? :dispatch_to
72-
actual_klass.dispatch_to(actual_klass)
73-
actual_klass.dispatch_to(*args, &regulation)
74-
end
75-
7661
CHANGE_POLICIES = [:create, :update, :destroy]
7762

7863
def self.allow_policy(policy, method)

ruby/hyper-operation/spec/aaa_run_first/transports_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,22 @@ def connect(*args)
9999
mount "TestComponent"
100100
evaluate_ruby "Hyperstack.go_ahead_and_connect"
101101
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
102-
wait_for { Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
102+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
103103
end
104104

105105
it "will not keep the temporary polled connection open" do
106106
mount "TestComponent"
107107
Hyperstack::Connection.active.should =~ ['ScopeIt::TestApplication']
108108
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
109-
wait_for { Hyperstack::Connection.active }.to eq([])
109+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq([])
110110
sleep 1
111111
end
112112

113113
it "sees the connection going offline" do
114114
mount "TestComponent"
115115
evaluate_ruby "Hyperstack.go_ahead_and_connect"
116116
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
117-
wait_for { sleep 1; Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
117+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
118118
ApplicationController.acting_user = true
119119
mount "TestComponent"
120120
evaluate_ruby "Hyperstack.go_ahead_and_connect"
@@ -169,21 +169,21 @@ def connect(*args)
169169
mount "TestComponent"
170170
evaluate_ruby "Hyperstack.go_ahead_and_connect"
171171
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
172-
wait_for { Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
172+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
173173
end
174174

175175
it "will not keep the temporary polled connection open" do
176176
mount "TestComponent"
177177
Hyperstack::Connection.active.should =~ ['ScopeIt::TestApplication']
178178
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
179-
wait_for { Hyperstack::Connection.active }.to eq([])
179+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq([])
180180
end
181181

182182
it "sees the connection going offline" do
183183
mount "TestComponent"
184184
evaluate_ruby "Hyperstack.go_ahead_and_connect"
185185
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
186-
wait_for { Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
186+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
187187
ApplicationController.acting_user = true
188188
mount "TestComponent"
189189
evaluate_ruby "Hyperstack.go_ahead_and_connect"
@@ -240,27 +240,27 @@ def connect(*args)
240240
mount "TestComponent"
241241
evaluate_ruby "Hyperstack.go_ahead_and_connect"
242242
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
243-
wait_for { Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
243+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
244244
end
245245

246246
it "will not keep the temporary polled connection open" do
247247
mount "TestComponent"
248248
Hyperstack::Connection.active.should =~ ['ScopeIt::TestApplication']
249249
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
250-
wait_for { Hyperstack::Connection.active }.to eq([])
250+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq([])
251251
end
252252

253253
it "sees the connection going offline", skip: 'this keeps failing intermittently, but not due to functional issues' do
254254
mount "TestComponent"
255255
evaluate_ruby "Hyperstack.go_ahead_and_connect"
256256
Timecop.travel(Time.now+Hyperstack::Connection.transport.expire_new_connection_in)
257-
wait_for { Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
257+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq(['ScopeIt::TestApplication'])
258258
ApplicationController.acting_user = true
259259
sleep 1 # needed so Pusher can catch up since its not controlled by timecop
260260
mount "TestComponent"
261261
evaluate_ruby "Hyperstack.go_ahead_and_connect"
262262
Timecop.travel(Time.now+Hyperstack::Connection.transport.refresh_channels_every)
263-
wait_for { Hyperstack::Connection.active }.to eq([])
263+
wait_for { sleep 0.25; Hyperstack::Connection.active }.to eq([])
264264
end
265265

266266
it "receives change notifications" do

ruby/hyper-operation/spec/hyper-operation/server_op_spec.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -249,26 +249,6 @@ class Operation < Hyperstack::ServerOp
249249
expect(page).to have_content("The server says 'goodby'!")
250250
end
251251

252-
it 'can regulate dispatches with the regulate_dispatch applied to a policy' do
253-
isomorphic do
254-
class Operation < Hyperstack::ServerOp
255-
param :message
256-
param :broadcast, default: false
257-
end
258-
end
259-
stub_const "ApplicationPolicy", Class.new
260-
stub_const "OperationPolicy", Class.new
261-
ApplicationPolicy.always_allow_connection
262-
OperationPolicy.dispatch_to { ['Application'] if params.broadcast }
263-
mount 'Test'
264-
expect(page).to have_content('No messages yet')
265-
Operation.run(message: 'hello')
266-
wait_for_ajax
267-
expect(page).not_to have_content("The server says 'hello'!", wait: 0)
268-
Operation.run(message: 'goodby', broadcast: true)
269-
expect(page).to have_content("The server says 'goodby'!")
270-
end
271-
272252
it 'will regulate with the always_dispatch_from regulation' do
273253
isomorphic do
274254
class Operation < Hyperstack::ServerOp

0 commit comments

Comments
 (0)