@@ -393,4 +393,65 @@ def index
393393 assert_equal 1 , cop . offenses . count
394394 assert_equal "render must be used with a string literal or an instance of a Class" , cop . offenses [ 0 ] . message
395395 end
396+
397+ def test_render_shorthand_static_locals_no_offsense
398+ investigate cop , <<-RUBY , "app/controllers/products_controller.rb"
399+ class ProductsController < ActionController::Base
400+ def index
401+ render "products/index", locals: { product: product }
402+ end
403+ end
404+ RUBY
405+
406+ assert_equal 0 , cop . offenses . count
407+ end
408+
409+ def test_render_partial_static_locals_no_offsense
410+ investigate cop , <<-RUBY , "app/controllers/products_controller.rb"
411+ class ProductsController < ActionController::Base
412+ def index
413+ render partial: "products/index", locals: { product: product }
414+ end
415+ end
416+ RUBY
417+
418+ assert_equal 0 , cop . offenses . count
419+ end
420+
421+ def test_render_literal_dynamic_options_offense
422+ investigate cop , <<-RUBY , "app/controllers/products_controller.rb"
423+ class ProductsController < ActionController::Base
424+ def index
425+ render "products/product", options
426+ end
427+ end
428+ RUBY
429+
430+ assert_equal 1 , cop . offenses . count
431+ end
432+
433+ def test_render_literal_dynamic_locals_offense
434+ investigate cop , <<-RUBY , "app/controllers/products_controller.rb"
435+ class ProductsController < ActionController::Base
436+ def index
437+ render "products/product", locals: locals
438+ end
439+ end
440+ RUBY
441+
442+ assert_equal 1 , cop . offenses . count
443+ end
444+
445+
446+ def test_render_literal_dynamic_local_key_offense
447+ investigate cop , <<-RUBY , "app/controllers/products_controller.rb"
448+ class ProductsController < ActionController::Base
449+ def index
450+ render "products/product", locals: { product_key => product }
451+ end
452+ end
453+ RUBY
454+
455+ assert_equal 1 , cop . offenses . count
456+ end
396457end
0 commit comments