diff options
Diffstat (limited to 'actionpack/test/controller/new_base/render_file_test.rb')
-rw-r--r-- | actionpack/test/controller/new_base/render_file_test.rb | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/actionpack/test/controller/new_base/render_file_test.rb b/actionpack/test/controller/new_base/render_file_test.rb index 0c21bb0719..82325c5bb2 100644 --- a/actionpack/test/controller/new_base/render_file_test.rb +++ b/actionpack/test/controller/new_base/render_file_test.rb @@ -1,36 +1,38 @@ -require 'abstract_unit' +# frozen_string_literal: true + +require "abstract_unit" module RenderFile class BasicController < ActionController::Base - self.view_paths = File.dirname(__FILE__) + self.view_paths = __dir__ def index - render :file => File.join(File.dirname(__FILE__), *%w[.. .. fixtures test hello_world]) + render file: File.expand_path("../../fixtures/test/hello_world", __dir__) end def with_instance_variables - @secret = 'in the sauce' - render :file => File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_ivar') + @secret = "in the sauce" + render file: File.expand_path("../../fixtures/test/render_file_with_ivar", __dir__) end def relative_path - @secret = 'in the sauce' - render :file => '../../fixtures/test/render_file_with_ivar' + @secret = "in the sauce" + render file: "../../fixtures/test/render_file_with_ivar" end def relative_path_with_dot - @secret = 'in the sauce' - render :file => '../../fixtures/test/dot.directory/render_file_with_ivar' + @secret = "in the sauce" + render file: "../../fixtures/test/dot.directory/render_file_with_ivar" end def pathname - @secret = 'in the sauce' - render :file => Pathname.new(File.dirname(__FILE__)).join(*%w[.. .. fixtures test dot.directory render_file_with_ivar]) + @secret = "in the sauce" + render file: Pathname.new(__dir__).join(*%w[.. .. fixtures test dot.directory render_file_with_ivar]) end def with_locals - path = File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_locals') - render :file => path, :locals => {:secret => 'in the sauce'} + path = File.expand_path("../../fixtures/test/render_file_with_locals", __dir__) + render file: path, locals: { secret: "in the sauce" } end end @@ -38,32 +40,44 @@ module RenderFile testing RenderFile::BasicController test "rendering simple template" do - get :index + assert_deprecated do + get :index + end assert_response "Hello world!" end test "rendering template with ivar" do - get :with_instance_variables + assert_deprecated do + get :with_instance_variables + end assert_response "The secret is in the sauce\n" end test "rendering a relative path" do - get :relative_path + assert_deprecated do + get :relative_path + end assert_response "The secret is in the sauce\n" end test "rendering a relative path with dot" do - get :relative_path_with_dot + assert_deprecated do + get :relative_path_with_dot + end assert_response "The secret is in the sauce\n" end test "rendering a Pathname" do - get :pathname + assert_deprecated do + get :pathname + end assert_response "The secret is in the sauce\n" end test "rendering file with locals" do - get :with_locals + assert_deprecated do + get :with_locals + end assert_response "The secret is in the sauce\n" end end |