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)
25
25
protected
26
26
27
27
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
31
38
end
32
39
end
33
40
Original file line number Diff line number Diff line change @@ -34,6 +34,22 @@ def puts(thing)
34
34
end
35
35
end
36
36
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
+
37
53
context 'with view data' do
38
54
before { get view_data_path }
39
55
You can’t perform that action at this time.
0 commit comments