File tree Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,21 @@ class InertiaShareTestController < ApplicationController
4
4
inertia_share do
5
5
{
6
6
position : 'center' ,
7
- number : 29 ,
7
+ number : number ,
8
8
}
9
9
end
10
10
11
11
def share
12
12
render inertia : 'ShareTestComponent'
13
13
end
14
+
15
+ def error
16
+ raise RuntimeError
17
+ end
18
+
19
+ private
20
+
21
+ def number
22
+ 29
23
+ end
14
24
end
Original file line number Diff line number Diff line change @@ -32,6 +32,15 @@ class Application < Rails::Application
32
32
33
33
# Required for Rails 5.0 and 5.1
34
34
config . secret_key_base = SecureRandom . hex
35
+
36
+ config . exceptions_app = -> ( env ) do
37
+ Class . new ( ActionController ::Base ) do
38
+ def show
39
+ render inertia : 'Error' , props : {
40
+ status : request . path_info [ 1 ..-1 ] . to_i
41
+ }
42
+ end
43
+ end . action ( :show ) . call ( env )
44
+ end
35
45
end
36
46
end
37
-
Original file line number Diff line number Diff line change 24
24
}
25
25
26
26
# Show full error reports and disable caching.
27
- config . consider_all_requests_local = true
27
+ config . consider_all_requests_local = false
28
28
config . action_controller . perform_caching = false
29
29
config . cache_store = :null_store
30
30
31
31
# Raise exceptions instead of rendering exception templates.
32
- config . action_dispatch . show_exceptions = false
32
+ config . action_dispatch . show_exceptions = true
33
33
34
34
# Disable request forgery protection in test environment.
35
35
config . action_controller . allow_forgery_protection = false
Original file line number Diff line number Diff line change 5
5
get 'view_data' => 'inertia_render_test#view_data'
6
6
get 'component' => 'inertia_render_test#component'
7
7
get 'share' => 'inertia_share_test#share'
8
+ get 'error' => 'inertia_share_test#error'
8
9
get 'share_with_inherited' => 'inertia_child_share_test#share_with_inherited'
9
10
get 'empty_test' => 'inertia_test#empty_test'
10
11
get 'redirect_test' => 'inertia_test#redirect_test'
Original file line number Diff line number Diff line change 63
63
64
64
it { is_expected . to eq props }
65
65
end
66
+
67
+ context 'using inertia share with exception handler' do
68
+ let ( :props ) { { status : 500 } }
69
+
70
+ before do
71
+ get error_path , headers : { 'X-Inertia' => true }
72
+ end
73
+
74
+ it { is_expected . to eq props }
75
+ end
66
76
end
You can’t perform that action at this time.
0 commit comments