File tree Expand file tree Collapse file tree 5 files changed +16
-2
lines changed
Expand file tree Collapse file tree 5 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,12 @@ module ReactiveRecord
22 class Broadcast
33
44 def self . after_commit ( operation , model )
5+ # Calling public_columns_hash once insures all policies are loaded
6+ # before the first broadcast.
7+ @public_columns_hash ||= ActiveRecord ::Base . public_columns_hash
58 Hyperstack ::InternalPolicy . regulate_broadcast ( model ) do |data |
69 if !Hyperstack . on_server? && Hyperstack ::Connection . root_path
7- send_to_server ( operation , data ) rescue nil # server no longer running so ignore
10+ send_to_server ( operation , data ) rescue nil # fails if server no longer running so ignore
811 else
912 SendPacket . run ( data , operation : operation )
1013 end
Original file line number Diff line number Diff line change 3838 size_window ( :small , :portrait )
3939 end
4040
41+ it "will load all the policies before the first broadcast" do
42+ expect ( defined? SomeModelPolicy ) . to be_falsy
43+ User . create ( name : 'Fred' )
44+ expect ( defined? SomeModelPolicy ) . to be_truthy
45+ end
46+
47+
4148 it "prerenders a belongs to relationship" do
4249 # must be first otherwise check for ajax fails because of race condition
4350 # with previous test
Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ class ActiveRecord::Base
288288
289289 config . before ( :all ) do
290290 # reset this variable so if any specs are setting up models locally
291- # the correct has gets sent to the client.
291+ # the correct hash gets sent to the client.
292292 ActiveRecord ::Base . instance_variable_set ( '@public_columns_hash' , nil )
293293 class ActiveRecord ::Base
294294 class << self
Original file line number Diff line number Diff line change 1+ class SomeModel < ApplicationRecord
2+ end
Original file line number Diff line number Diff line change 1+ class SomeModelPolicy
2+ end
You can’t perform that action at this time.
0 commit comments