File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,16 @@ def wrap_render(render_method)
2525 protected
2626
2727 def set_values ( params )
28- @view_data = params [ :locals ] . except ( :page )
29- @props = params [ :locals ] [ :page ] [ :props ]
30- @component = params [ :locals ] [ :page ] [ :component ]
28+ if params [ :locals ] . present?
29+ @view_data = params [ :locals ] . except ( :page )
30+ @props = params [ :locals ] [ :page ] [ :props ]
31+ @component = params [ :locals ] [ :page ] [ :component ]
32+ else
33+ # Sequential Inertia request
34+ @view_data = { }
35+ @props = params [ :json ] [ :props ]
36+ @component = params [ :json ] [ :component ]
37+ end
3138 end
3239 end
3340
Original file line number Diff line number Diff line change @@ -34,6 +34,22 @@ def puts(thing)
3434 end
3535 end
3636
37+ context 'with props during sequential request' do
38+ before { get props_path , headers : { 'X-Inertia' : true } }
39+
40+ it 'has props' do
41+ expect_inertia . to have_exact_props ( { name : 'Brandon' , sport : 'hockey' } )
42+ end
43+
44+ it 'includes props' do
45+ expect_inertia . to include_props ( { sport : 'hockey' } )
46+ end
47+
48+ it 'can retrieve props' do
49+ expect ( inertia . props [ :name ] ) . to eq 'Brandon'
50+ end
51+ end
52+
3753 context 'with view data' do
3854 before { get view_data_path }
3955
You can’t perform that action at this time.
0 commit comments