File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ def bad_single
3333 def bad_pair
3434 end
3535
36+ def no_json_template
37+ end
38+
39+ def no_html_template
40+ end
41+
3642 def render_does_not_exist
3743 render :does_not_exist
3844 end
Original file line number Diff line number Diff line change @@ -146,6 +146,37 @@ class RenderTest < ActionController::TestCase
146146 assert_equal "application/json" , @response . media_type
147147 end
148148
149+ test "rendering props with a non existant template still renders the layout" do
150+ get :no_json_template , format : :json
151+
152+ assert_response 200
153+ rendered = <<~HTML
154+ {"data":{}}
155+ HTML
156+
157+ assert_equal rendered , @response . body
158+ assert_equal "application/json" , @response . media_type
159+ end
160+
161+ test "rendering an action without a HTML template renders the fallback application/superglue" do
162+ get :no_html_template , format : :html
163+
164+ assert_response 200
165+ rendered = <<~HTML
166+ < html >
167+ < body >
168+ < script type ="text/javascript ">
169+ window . SUPERGLUE_INITIAL_PAGE_STATE = { "data" :{ } } ;
170+ </ script >
171+
172+ < div id ="app "> </ div > </ body >
173+ </ html >
174+ HTML
175+
176+ assert_equal rendered , @response . body
177+ assert_equal "text/html" , @response . media_type
178+ end
179+
149180 test "non existant template" do
150181 exception = assert_raise ( ActionView ::MissingTemplate , match : /extension JSX or TSX/ ) {
151182 get :render_does_not_exist
You can’t perform that action at this time.
0 commit comments