File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,11 @@ def merge_props(shared_props, props)
91
91
92
92
def computed_props
93
93
merged_props = merge_props ( shared_data , props )
94
+ # Always keep errors in the props
95
+ if merged_props . key? ( :errors ) && !merged_props [ :errors ] . is_a? ( BaseProp )
96
+ errors = merged_props [ :errors ]
97
+ merged_props [ :errors ] = InertiaRails . always { errors }
98
+ end
94
99
deep_transform_props ( merged_props ) . tap do |transformed_props |
95
100
transformed_props [ :_inertia_meta ] = meta_tags if meta_tags . present?
96
101
end
Original file line number Diff line number Diff line change 45
45
expect ( response . body ) . to include ( CGI ::escape_html ( { errors : { uh : 'oh' } } . to_json ) )
46
46
expect ( session [ :inertia_errors ] ) . not_to be
47
47
end
48
+
49
+ context 'with partial update' do
50
+ let ( :headers ) do
51
+ {
52
+ 'X-Inertia' => true ,
53
+ 'X-Inertia-Version' => server_version ,
54
+ 'X-Inertia-Partial-Component' => 'EmptyTestComponent' ,
55
+ 'X-Inertia-Partial-Data' => 'foo' ,
56
+ }
57
+ end
58
+
59
+ it 'keeps errors when partial inertia request redirects' do
60
+ post redirect_with_inertia_errors_path , headers : headers
61
+ expect ( response . headers [ 'Location' ] ) . to eq ( empty_test_url )
62
+ expect ( session [ :inertia_errors ] ) . to include ( { uh : 'oh' } )
63
+
64
+ # Follow the redirect
65
+ get response . headers [ 'Location' ] , headers : headers
66
+ expect ( response . body ) . to include ( { errors : { uh : 'oh' } } . to_json )
67
+ expect ( session [ :inertia_errors ] ) . not_to be
68
+ end
69
+ end
48
70
end
49
71
end
You can’t perform that action at this time.
0 commit comments