File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change
1
+ * Raise ` ArgumentError ` if ` :renderable ` object does not respond to ` #render_in `
2
+
3
+ * Sean Doyle*
4
+
1
5
* Add the ` nonce: true ` option for ` stylesheet_link_tag ` helper to support automatic nonce generation for Content Security Policy.
2
6
Works the same way as ` javascript_include_tag nonce: true ` does.
3
7
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ def partial_path(object, view)
79
79
path = if object . respond_to? ( :to_partial_path )
80
80
object . to_partial_path
81
81
else
82
- raise ArgumentError . new ( "'#{ object . inspect } ' is not an ActiveModel-compatible object. It must implement : to_partial_path." )
82
+ raise ArgumentError . new ( "'#{ object . inspect } ' is not an ActiveModel-compatible object. It must implement # to_partial_path." )
83
83
end
84
84
85
85
if view . prefix_partial_path_with_controller_namespace
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ def identifier
14
14
15
15
def render ( context , *args )
16
16
@renderable . render_in ( context )
17
+ rescue NoMethodError
18
+ raise ArgumentError , "'#{ @renderable . inspect } ' is not a renderable object. It must implement #render_in."
17
19
end
18
20
19
21
def format
Original file line number Diff line number Diff line change @@ -293,8 +293,23 @@ def test_render_partial_with_missing_filename
293
293
end
294
294
295
295
def test_render_partial_with_incompatible_object
296
- e = assert_raises ( ArgumentError ) { @view . render ( partial : nil ) }
297
- assert_equal "'#{ nil . inspect } ' is not an ActiveModel-compatible object. It must implement :to_partial_path." , e . message
296
+ assert_raises ArgumentError , match : "'#{ nil . inspect } ' is not an ActiveModel-compatible object. It must implement #to_partial_path." do
297
+ @view . render ( partial : nil )
298
+ end
299
+ end
300
+
301
+ def test_render_renderable_with_nil
302
+ assert_raises ArgumentError , match : "'#{ nil . inspect } ' is not a renderable object. It must implement #render_in." do
303
+ @view . render renderable : nil
304
+ end
305
+ end
306
+
307
+ def test_render_renderable_with_incompatible_object
308
+ object = Object . new
309
+
310
+ assert_raises ArgumentError , match : "'#{ object . inspect } ' is not a renderable object. It must implement #render_in." do
311
+ @view . render renderable : object
312
+ end
298
313
end
299
314
300
315
def test_render_partial_starting_with_a_capital
You can’t perform that action at this time.
0 commit comments