diff options
Diffstat (limited to 'actionview/test/actionpack/controller')
4 files changed, 187 insertions, 188 deletions
diff --git a/actionview/test/actionpack/controller/capture_test.rb b/actionview/test/actionpack/controller/capture_test.rb index 933456ce9d..f0ae609845 100644 --- a/actionview/test/actionpack/controller/capture_test.rb +++ b/actionview/test/actionpack/controller/capture_test.rb @@ -1,30 +1,30 @@ -require 'abstract_unit' -require 'active_support/logger' +require "abstract_unit" +require "active_support/logger" class CaptureController < ActionController::Base - self.view_paths = [ File.dirname(__FILE__) + '/../../fixtures/actionpack' ] + self.view_paths = [ File.dirname(__FILE__) + "/../../fixtures/actionpack" ] def self.controller_name; "test"; end def self.controller_path; "test"; end def content_for @title = nil - render :layout => "talk_from_action" + render layout: "talk_from_action" end def content_for_with_parameter @title = nil - render :layout => "talk_from_action" + render layout: "talk_from_action" end def content_for_concatenated @title = nil - render :layout => "talk_from_action" + render layout: "talk_from_action" end def non_erb_block_content_for @title = nil - render :layout => "talk_from_action" + render layout: "talk_from_action" end def proper_block_detection diff --git a/actionview/test/actionpack/controller/layout_test.rb b/actionview/test/actionpack/controller/layout_test.rb index 64bc4c41d6..00147d31f3 100644 --- a/actionview/test/actionpack/controller/layout_test.rb +++ b/actionview/test/actionpack/controller/layout_test.rb @@ -1,15 +1,16 @@ -require 'abstract_unit' -require 'active_support/core_ext/array/extract_options' +require "abstract_unit" +require "active_support/core_ext/array/extract_options" +require "active_support/core_ext/regexp" # The view_paths array must be set on Base and not LayoutTest so that LayoutTest's inherited # method has access to the view_paths array when looking for a layout to automatically assign. old_load_paths = ActionController::Base.view_paths -ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../../fixtures/actionpack/layout_tests/' ] +ActionController::Base.view_paths = [ File.dirname(__FILE__) + "/../../fixtures/actionpack/layout_tests/" ] class LayoutTest < ActionController::Base - def self.controller_path; 'views' end - def self._implied_layout_name; to_s.underscore.gsub(/_controller$/, '') ; end + def self.controller_path; "views" end + def self._implied_layout_name; to_s.underscore.gsub(/_controller$/, "") ; end self.view_paths = ActionController::Base.view_paths.dup end @@ -54,13 +55,13 @@ class LayoutAutoDiscoveryTest < ActionController::TestCase def test_application_layout_is_default_when_no_controller_match @controller = ProductController.new get :hello - assert_equal 'layout_test.erb hello.erb', @response.body + assert_equal "layout_test.erb hello.erb", @response.body end def test_controller_name_layout_name_match @controller = ItemController.new get :hello - assert_equal 'item.erb hello.erb', @response.body + assert_equal "item.erb hello.erb", @response.body end def test_third_party_template_library_auto_discovers_layout @@ -68,20 +69,20 @@ class LayoutAutoDiscoveryTest < ActionController::TestCase @controller = ThirdPartyTemplateLibraryController.new get :hello assert_response :success - assert_equal 'layouts/third_party_template_library.mab', @response.body + assert_equal "layouts/third_party_template_library.mab", @response.body end end def test_namespaced_controllers_auto_detect_layouts1 @controller = ControllerNameSpace::NestedController.new get :hello - assert_equal 'controller_name_space/nested.erb hello.erb', @response.body + assert_equal "controller_name_space/nested.erb hello.erb", @response.body end def test_namespaced_controllers_auto_detect_layouts2 @controller = MultipleExtensions.new get :hello - assert_equal 'multiple_extensions.html.erb hello.erb', @response.body.strip + assert_equal "multiple_extensions.html.erb hello.erb", @response.body.strip end end @@ -91,16 +92,16 @@ end class StreamingLayoutController < LayoutTest def render(*args) options = args.extract_options! - super(*args, options.merge(:stream => true)) + super(*args, options.merge(stream: true)) end end class AbsolutePathLayoutController < LayoutTest - layout File.expand_path(File.expand_path(__FILE__) + '/../../../fixtures/actionpack/layout_tests/layouts/layout_test') + layout File.expand_path(File.expand_path(__FILE__) + "/../../../fixtures/actionpack/layout_tests/layouts/layout_test") end class HasOwnLayoutController < LayoutTest - layout 'item' + layout "item" end class HasNilLayoutSymbol < LayoutTest @@ -117,28 +118,28 @@ end class PrependsViewPathController < LayoutTest def hello - prepend_view_path File.dirname(__FILE__) + '/../../fixtures/actionpack/layout_tests/alt/' - render :layout => 'alt' + prepend_view_path File.dirname(__FILE__) + "/../../fixtures/actionpack/layout_tests/alt/" + render layout: "alt" end end class OnlyLayoutController < LayoutTest - layout 'item', :only => "hello" + layout "item", only: "hello" end class ExceptLayoutController < LayoutTest - layout 'item', :except => "goodbye" + layout "item", except: "goodbye" end class SetsLayoutInRenderController < LayoutTest def hello - render :layout => 'third_party_template_library' + render layout: "third_party_template_library" end end class RendersNoLayoutController < LayoutTest def hello - render :layout => false + render layout: false end end @@ -149,75 +150,75 @@ class LayoutSetInResponseTest < ActionController::TestCase def test_layout_set_when_using_default_layout @controller = DefaultLayoutController.new get :hello - assert_includes @response.body, 'layout_test.erb' + assert_includes @response.body, "layout_test.erb" end def test_layout_set_when_using_streaming_layout @controller = StreamingLayoutController.new get :hello - assert_includes @response.body, 'layout_test.erb' + assert_includes @response.body, "layout_test.erb" end def test_layout_set_when_set_in_controller @controller = HasOwnLayoutController.new get :hello - assert_includes @response.body, 'item.erb' + assert_includes @response.body, "item.erb" end def test_layout_symbol_set_in_controller_returning_nil_falls_back_to_default @controller = HasNilLayoutSymbol.new get :hello - assert_includes @response.body, 'layout_test.erb' + assert_includes @response.body, "layout_test.erb" end def test_layout_proc_set_in_controller_returning_nil_falls_back_to_default @controller = HasNilLayoutProc.new get :hello - assert_includes @response.body, 'layout_test.erb' + assert_includes @response.body, "layout_test.erb" end def test_layout_only_exception_when_included @controller = OnlyLayoutController.new get :hello - assert_includes @response.body, 'item.erb' + assert_includes @response.body, "item.erb" end def test_layout_only_exception_when_excepted @controller = OnlyLayoutController.new get :goodbye - assert_not_includes @response.body, 'item.erb' + assert_not_includes @response.body, "item.erb" end def test_layout_except_exception_when_included @controller = ExceptLayoutController.new get :hello - assert_includes @response.body, 'item.erb' + assert_includes @response.body, "item.erb" end def test_layout_except_exception_when_excepted @controller = ExceptLayoutController.new get :goodbye - assert_not_includes @response.body, 'item.erb' + assert_not_includes @response.body, "item.erb" end def test_layout_set_when_using_render with_template_handler :mab, lambda { |template| template.source.inspect } do @controller = SetsLayoutInRenderController.new get :hello - assert_includes @response.body, 'layouts/third_party_template_library.mab' + assert_includes @response.body, "layouts/third_party_template_library.mab" end end def test_layout_is_not_set_when_none_rendered @controller = RendersNoLayoutController.new get :hello - assert_equal 'hello.erb', @response.body + assert_equal "hello.erb", @response.body end def test_layout_is_picked_from_the_controller_instances_view_path @controller = PrependsViewPathController.new get :hello - assert_includes @response.body, 'alt.erb' + assert_includes @response.body, "alt.erb" end def test_absolute_pathed_layout @@ -240,7 +241,7 @@ end class LayoutStatusIsRendered < LayoutTest def hello - render :status => 401 + render status: 401 end end @@ -252,7 +253,7 @@ class LayoutStatusIsRenderedTest < ActionController::TestCase end end -unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ +unless /mswin|mingw/.match?(RbConfig::CONFIG["host_os"]) class LayoutSymlinkedTest < LayoutTest layout "symlinked/symlinked_layout" end @@ -262,7 +263,7 @@ unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ @controller = LayoutSymlinkedTest.new get :hello assert_response 200 - assert_includes @response.body, 'This is my layout' + assert_includes @response.body, "This is my layout" end end end diff --git a/actionview/test/actionpack/controller/render_test.rb b/actionview/test/actionpack/controller/render_test.rb index 7b69ffc628..453c2e75d6 100644 --- a/actionview/test/actionpack/controller/render_test.rb +++ b/actionview/test/actionpack/controller/render_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_model' +require "abstract_unit" +require "active_model" class ApplicationController < ActionController::Base self.view_paths = File.join(FIXTURE_LOAD_PATH, "actionpack") @@ -51,7 +51,7 @@ module Quiz # Controller class QuestionsController < ApplicationController def new - render :partial => Quiz::Question.new("Namespaced Partial") + render partial: Quiz::Question.new("Namespaced Partial") end end end @@ -64,7 +64,7 @@ module Fun def hello_world; end def nested_partial_with_form_builder - render :partial => ActionView::Helpers::FormBuilder.new(:post, nil, view_context, {}) + render partial: ActionView::Helpers::FormBuilder.new(:post, nil, view_context, {}) end end end @@ -90,7 +90,7 @@ class TestController < ApplicationController end def hello_world_file - render :file => File.expand_path("../../../fixtures/actionpack/hello", __FILE__), :formats => [:html] + render file: File.expand_path("../../../fixtures/actionpack/hello", __FILE__), formats: [:html] end # :ported: @@ -110,12 +110,12 @@ class TestController < ApplicationController # :ported: def render_template_in_top_directory - render :template => 'shared' + render template: "shared" end # :deprecated: def render_template_in_top_directory_with_slash - render '/shared' + render "/shared" end # :ported: @@ -126,11 +126,11 @@ class TestController < ApplicationController # :ported: def render_action_hello_world - render :action => "hello_world" + render action: "hello_world" end def render_action_upcased_hello_world - render :action => "Hello_world" + render action: "Hello_world" end def render_action_hello_world_as_string @@ -138,7 +138,7 @@ class TestController < ApplicationController end def render_action_hello_world_with_symbol - render :action => :hello_world + render action: :hello_world end # :ported: @@ -149,70 +149,70 @@ class TestController < ApplicationController # :ported: def render_text_hello_world_with_layout @variable_for_layout = ", I am here!" - render plain: "hello world", :layout => true + render plain: "hello world", layout: true end def hello_world_with_layout_false - render :layout => false + render layout: false end # :ported: def render_file_with_instance_variables - @secret = 'in the sauce' - path = File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_ivar') - render :file => path + @secret = "in the sauce" + path = File.join(File.dirname(__FILE__), "../../fixtures/test/render_file_with_ivar") + render file: path end # :ported: def render_file_not_using_full_path - @secret = 'in the sauce' - render :file => 'test/render_file_with_ivar' + @secret = "in the sauce" + render file: "test/render_file_with_ivar" end def render_file_not_using_full_path_with_dot_in_path - @secret = 'in the sauce' - render :file => 'test/dot.directory/render_file_with_ivar' + @secret = "in the sauce" + render file: "test/dot.directory/render_file_with_ivar" end def render_file_using_pathname - @secret = 'in the sauce' - render :file => Pathname.new(File.dirname(__FILE__)).join('..', '..', 'fixtures', 'test', 'dot.directory', 'render_file_with_ivar') + @secret = "in the sauce" + render file: Pathname.new(File.dirname(__FILE__)).join("..", "..", "fixtures", "test", "dot.directory", "render_file_with_ivar") end def render_file_from_template - @secret = 'in the sauce' - @path = File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_ivar')) + @secret = "in the sauce" + @path = File.expand_path(File.join(File.dirname(__FILE__), "../../fixtures/test/render_file_with_ivar")) end def render_file_with_locals - path = File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_locals') - render :file => path, :locals => {:secret => 'in the sauce'} + path = File.join(File.dirname(__FILE__), "../../fixtures/test/render_file_with_locals") + render file: path, locals: {secret: "in the sauce"} end def render_file_as_string_with_locals - path = File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_locals')) - render file: path, :locals => {:secret => 'in the sauce'} + path = File.expand_path(File.join(File.dirname(__FILE__), "../../fixtures/test/render_file_with_locals")) + render file: path, locals: {secret: "in the sauce"} end def accessing_request_in_template - render :inline => "Hello: <%= request.host %>" + render inline: "Hello: <%= request.host %>" end def accessing_logger_in_template - render :inline => "<%= logger.class %>" + render inline: "<%= logger.class %>" end def accessing_action_name_in_template - render :inline => "<%= action_name %>" + render inline: "<%= action_name %>" end def accessing_controller_name_in_template - render :inline => "<%= controller_name %>" + render inline: "<%= controller_name %>" end # :ported: def render_custom_code - render plain: "hello world", :status => 404 + render plain: "hello world", status: 404 end # :ported: @@ -240,7 +240,7 @@ class TestController < ApplicationController # setting content type def render_xml_hello @name = "David" - render :template => "test/hello" + render template: "test/hello" end def render_xml_hello_as_string_template @@ -249,7 +249,7 @@ class TestController < ApplicationController end def render_line_offset - render :inline => '<% raise %>', :locals => {:foo => 'bar'} + render inline: "<% raise %>", locals: {foo: "bar"} end def heading @@ -262,49 +262,49 @@ class TestController < ApplicationController # :ported: def blank_response - render plain: ' ' + render plain: " " end # :ported: def layout_test - render :action => "hello_world" + render action: "hello_world" end # :ported: def builder_layout_test @name = nil - render :action => "hello", :layout => "layouts/builder" + render action: "hello", layout: "layouts/builder" end # :move: test this in Action View def builder_partial_test - render :action => "hello_world_container" + render action: "hello_world_container" end # :ported: def partials_list - @test_unchanged = 'hello' + @test_unchanged = "hello" @customers = [ Customer.new("david"), Customer.new("mary") ] - render :action => "list" + render action: "list" end def partial_only - render :partial => true + render partial: true end def hello_in_a_string @customers = [ Customer.new("david"), Customer.new("mary") ] - render plain: "How's there? " + render_to_string(:template => "test/list") + render plain: "How's there? " + render_to_string(template: "test/list") end def accessing_params_in_template - render :inline => "Hello: <%= params[:name] %>" + render inline: "Hello: <%= params[:name] %>" end def accessing_local_assigns_in_inline_template name = params[:local_name] - render :inline => "<%= 'Goodbye, ' + local_name %>", - :locals => { :local_name => name } + render inline: "<%= 'Goodbye, ' + local_name %>", + locals: { local_name: name } end def render_implicit_html_template_from_xhr_request @@ -320,7 +320,7 @@ class TestController < ApplicationController end def render_to_string_test - @foo = render_to_string :inline => "this is a test" + @foo = render_to_string inline: "this is a test" end def default_render @@ -333,27 +333,27 @@ class TestController < ApplicationController end def render_action_hello_world_as_symbol - render :action => :hello_world + render action: :hello_world end def layout_test_with_different_layout - render :action => "hello_world", :layout => "standard" + render action: "hello_world", layout: "standard" end def layout_test_with_different_layout_and_string_action - render "hello_world", :layout => "standard" + render "hello_world", layout: "standard" end def layout_test_with_different_layout_and_symbol_action - render :hello_world, :layout => "standard" + render :hello_world, layout: "standard" end def rendering_without_layout - render :action => "hello_world", :layout => false + render action: "hello_world", layout: false end def layout_overriding_layout - render :action => "hello_world", :layout => "standard" + render action: "hello_world", layout: "standard" end def rendering_nothing_on_layout @@ -364,38 +364,38 @@ class TestController < ApplicationController @before = "i'm before the render" render_to_string plain: "foo" @after = "i'm after the render" - render :template => "test/hello_world" + render template: "test/hello_world" end def render_to_string_with_exception - render_to_string :file => "exception that will not be caught - this will certainly not work" + render_to_string file: "exception that will not be caught - this will certainly not work" end def render_to_string_with_caught_exception @before = "i'm before the render" begin - render_to_string :file => "exception that will be caught- hope my future instance vars still work!" + render_to_string file: "exception that will be caught- hope my future instance vars still work!" rescue end @after = "i'm after the render" - render :template => "test/hello_world" + render template: "test/hello_world" end def accessing_params_in_template_with_layout - render :layout => true, :inline => "Hello: <%= params[:name] %>" + render layout: true, inline: "Hello: <%= params[:name] %>" end # :ported: def render_with_explicit_template - render :template => "test/hello_world" + render template: "test/hello_world" end def render_with_explicit_unescaped_template - render :template => "test/h*llo_world" + render template: "test/h*llo_world" end def render_with_explicit_escaped_template - render :template => "test/hello,world" + render template: "test/hello,world" end def render_with_explicit_string_template @@ -404,7 +404,7 @@ class TestController < ApplicationController # :ported: def render_with_explicit_template_with_locals - render :template => "test/render_file_with_locals", :locals => { :secret => 'area51' } + render template: "test/render_file_with_locals", locals: { secret: "area51" } end # :ported: @@ -414,13 +414,13 @@ class TestController < ApplicationController end def double_redirect - redirect_to :action => "double_render" - redirect_to :action => "double_render" + redirect_to action: "double_render" + redirect_to action: "double_render" end def render_and_redirect render plain: "hello" - redirect_to :action => "double_render" + redirect_to action: "double_render" end def render_to_string_and_render @@ -429,22 +429,22 @@ class TestController < ApplicationController end def render_to_string_with_inline_and_render - render_to_string :inline => "<%= 'dlrow olleh'.reverse %>" - render :template => "test/hello_world" + render_to_string inline: "<%= 'dlrow olleh'.reverse %>" + render template: "test/hello_world" end def rendering_with_conflicting_local_vars @name = "David" - render :action => "potential_conflicts" + render action: "potential_conflicts" end def hello_world_from_rxml_using_action - render :action => "hello_world_from_rxml", :handlers => [:builder] + render action: "hello_world_from_rxml", handlers: [:builder] end # :deprecated: def hello_world_from_rxml_using_template - render :template => "test/hello_world_from_rxml", :handlers => [:builder] + render template: "test/hello_world_from_rxml", handlers: [:builder] end def action_talk_to_layout @@ -458,11 +458,11 @@ class TestController < ApplicationController end def render_with_assigns_option - render inline: '<%= @hello %>', assigns: { hello: "world" } + render inline: "<%= @hello %>", assigns: { hello: "world" } end def yield_content_for - render :action => "content_for", :layout => "yield" + render action: "content_for", layout: "yield" end def render_content_type_from_body @@ -471,117 +471,117 @@ class TestController < ApplicationController end def render_using_layout_around_block - render :action => "using_layout_around_block" + render action: "using_layout_around_block" end def render_using_layout_around_block_in_main_layout_and_within_content_for_layout - render :action => "using_layout_around_block", :layout => "layouts/block_with_layout" + render action: "using_layout_around_block", layout: "layouts/block_with_layout" end def partial_formats_html - render :partial => 'partial', :formats => [:html] + render partial: "partial", formats: [:html] end def partial - render :partial => 'partial' + render partial: "partial" end def partial_html_erb - render :partial => 'partial_html_erb' + render partial: "partial_html_erb" end def render_to_string_with_partial - @partial_only = render_to_string :partial => "partial_only" - @partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") } - render :template => "test/hello_world" + @partial_only = render_to_string partial: "partial_only" + @partial_with_locals = render_to_string partial: "customer", locals: { customer: Customer.new("david") } + render template: "test/hello_world" end def render_to_string_with_template_and_html_partial - @text = render_to_string :template => "test/with_partial", :formats => [:text] - @html = render_to_string :template => "test/with_partial", :formats => [:html] - render :template => "test/with_html_partial" + @text = render_to_string template: "test/with_partial", formats: [:text] + @html = render_to_string template: "test/with_partial", formats: [:html] + render template: "test/with_html_partial" end def render_to_string_and_render_with_different_formats - @html = render_to_string :template => "test/with_partial", :formats => [:html] - render :template => "test/with_partial", :formats => [:text] + @html = render_to_string template: "test/with_partial", formats: [:html] + render template: "test/with_partial", formats: [:text] end def render_template_within_a_template_with_other_format - render :template => "test/with_xml_template", - :formats => [:html], - :layout => "with_html_partial" + render template: "test/with_xml_template", + formats: [:html], + layout: "with_html_partial" end def partial_with_counter - render :partial => "counter", :locals => { :counter_counter => 5 } + render partial: "counter", locals: { counter_counter: 5 } end def partial_with_locals - render :partial => "customer", :locals => { :customer => Customer.new("david") } + render partial: "customer", locals: { customer: Customer.new("david") } end def partial_with_form_builder - render :partial => ActionView::Helpers::FormBuilder.new(:post, nil, view_context, {}) + render partial: ActionView::Helpers::FormBuilder.new(:post, nil, view_context, {}) end def partial_with_form_builder_subclass - render :partial => LabellingFormBuilder.new(:post, nil, view_context, {}) + render partial: LabellingFormBuilder.new(:post, nil, view_context, {}) end def partial_collection - render :partial => "customer", :collection => [ Customer.new("david"), Customer.new("mary") ] + render partial: "customer", collection: [ Customer.new("david"), Customer.new("mary") ] end def partial_collection_with_as - render :partial => "customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer + render partial: "customer_with_var", collection: [ Customer.new("david"), Customer.new("mary") ], as: :customer end def partial_collection_with_iteration - render partial: "customer_iteration", collection: [ Customer.new("david"), Customer.new("mary"), Customer.new('christine') ] + render partial: "customer_iteration", collection: [ Customer.new("david"), Customer.new("mary"), Customer.new("christine") ] end def partial_collection_with_as_and_iteration - render partial: "customer_iteration_with_as", collection: [ Customer.new("david"), Customer.new("mary"), Customer.new('christine') ], as: :client + render partial: "customer_iteration_with_as", collection: [ Customer.new("david"), Customer.new("mary"), Customer.new("christine") ], as: :client end def partial_collection_with_counter - render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ] + render partial: "customer_counter", collection: [ Customer.new("david"), Customer.new("mary") ] end def partial_collection_with_as_and_counter - render :partial => "customer_counter_with_as", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :client + render partial: "customer_counter_with_as", collection: [ Customer.new("david"), Customer.new("mary") ], as: :client end def partial_collection_with_locals - render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } + render partial: "customer_greeting", collection: [ Customer.new("david"), Customer.new("mary") ], locals: { greeting: "Bonjour" } end def partial_collection_with_spacer - render :partial => "customer", :spacer_template => "partial_only", :collection => [ Customer.new("david"), Customer.new("mary") ] + render partial: "customer", spacer_template: "partial_only", collection: [ Customer.new("david"), Customer.new("mary") ] end def partial_collection_with_spacer_which_uses_render - render :partial => "customer", :spacer_template => "partial_with_partial", :collection => [ Customer.new("david"), Customer.new("mary") ] + render partial: "customer", spacer_template: "partial_with_partial", collection: [ Customer.new("david"), Customer.new("mary") ] end def partial_collection_shorthand_with_locals - render :partial => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } + render partial: [ Customer.new("david"), Customer.new("mary") ], locals: { greeting: "Bonjour" } end def partial_collection_shorthand_with_different_types_of_records - render :partial => [ + render partial: [ BadCustomer.new("mark"), GoodCustomer.new("craig"), BadCustomer.new("john"), GoodCustomer.new("zach"), GoodCustomer.new("brandon"), BadCustomer.new("dan") ], - :locals => { :greeting => "Bonjour" } + locals: { greeting: "Bonjour" } end def empty_partial_collection - render :partial => "customer", :collection => [] + render partial: "customer", collection: [] end def partial_collection_shorthand_with_different_types_of_records_with_counter @@ -589,15 +589,15 @@ class TestController < ApplicationController end def missing_partial - render :partial => 'thisFileIsntHere' + render partial: "thisFileIsntHere" end def partial_with_hash_object - render :partial => "hash_object", :object => {:first_name => "Sam"} + render partial: "hash_object", object: {first_name: "Sam"} end def partial_with_nested_object - render :partial => "quiz/questions/question", :object => Quiz::Question.new("first") + render partial: "quiz/questions/question", object: Quiz::Question.new("first") end def partial_with_nested_object_shorthand @@ -605,24 +605,24 @@ class TestController < ApplicationController end def partial_hash_collection - render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ] + render partial: "hash_object", collection: [ {first_name: "Pratik"}, {first_name: "Amy"} ] end def partial_hash_collection_with_locals - render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" } + render partial: "hash_greeting", collection: [ {first_name: "Pratik"}, {first_name: "Amy"} ], locals: { greeting: "Hola" } end def partial_with_implicit_local_assignment @customer = Customer.new("Marcel") - render :partial => "customer" + render partial: "customer" end def render_call_to_partial_with_layout - render :action => "calling_partial_with_layout" + render action: "calling_partial_with_layout" end def render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout - render :action => "calling_partial_with_layout", :layout => "layouts/partial_with_layout" + render action: "calling_partial_with_layout", layout: "layouts/partial_with_layout" end before_action only: :render_with_filters do @@ -631,7 +631,7 @@ class TestController < ApplicationController # Ensure that the before filter is executed *before* self.formats is set. def render_with_filters - render :action => :formatted_xml_erb + render action: :formatted_xml_erb end private @@ -642,7 +642,7 @@ class TestController < ApplicationController def determine_layout case action_name - when "hello_world", "layout_test", "rendering_without_layout", + when "hello_world", "layout_test", "rendering_without_layout", "rendering_nothing_on_layout", "render_text_hello_world", "render_text_hello_world_with_layout", "hello_world_with_layout_false", @@ -652,11 +652,11 @@ class TestController < ApplicationController "render_with_explicit_string_template", "update_page", "update_page_with_instance_variables" - "layouts/standard" - when "action_talk_to_layout", "layout_overriding_layout" - "layouts/talk_from_action" - when "render_implicit_html_template_from_xhr_request" - (request.xhr? ? 'layouts/xhr' : 'layouts/standard') + "layouts/standard" + when "action_talk_to_layout", "layout_overriding_layout" + "layouts/talk_from_action" + when "render_implicit_html_template_from_xhr_request" + (request.xhr? ? "layouts/xhr" : "layouts/standard") end end end @@ -771,7 +771,7 @@ class RenderTest < ActionController::TestCase # :ported: def test_do_with_render_action_and_layout_false get :hello_world_with_layout_false - assert_equal 'Hello world!', @response.body + assert_equal "Hello world!", @response.body end # :ported: @@ -826,27 +826,27 @@ class RenderTest < ActionController::TestCase get :render_custom_code assert_response 404 assert_response :missing - assert_equal 'hello world', @response.body + assert_equal "hello world", @response.body end # :ported: def test_render_text_with_nil get :render_text_with_nil assert_response 200 - assert_equal '', @response.body + assert_equal "", @response.body end # :ported: def test_render_text_with_false get :render_text_with_false - assert_equal 'false', @response.body + assert_equal "false", @response.body end # :ported: def test_render_nothing_with_appendix get :render_nothing_with_appendix assert_response 200 - assert_equal 'appended', @response.body + assert_equal "appended", @response.body end def test_render_text_with_resource @@ -941,7 +941,7 @@ class RenderTest < ActionController::TestCase def test_render_to_string_inline get :render_to_string_with_inline_and_render - assert_equal 'Hello world!', @response.body + assert_equal "Hello world!", @response.body end # :ported: @@ -974,24 +974,24 @@ class RenderTest < ActionController::TestCase def test_should_render_formatted_template get :formatted_html_erb - assert_equal 'formatted html erb', @response.body + assert_equal "formatted html erb", @response.body end def test_should_render_formatted_html_erb_template get :formatted_xml_erb - assert_equal '<test>passed formatted html erb</test>', @response.body + assert_equal "<test>passed formatted html erb</test>", @response.body end def test_should_render_formatted_html_erb_template_with_bad_accepts_header @request.env["HTTP_ACCEPT"] = "; a=dsf" get :formatted_xml_erb - assert_equal '<test>passed formatted html erb</test>', @response.body + assert_equal "<test>passed formatted html erb</test>", @response.body end def test_should_render_formatted_html_erb_template_with_faulty_accepts_header @request.accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*" get :formatted_xml_erb - assert_equal '<test>passed formatted html erb</test>', @response.body + assert_equal "<test>passed formatted html erb</test>", @response.body end def test_layout_test_with_different_layout @@ -1021,7 +1021,7 @@ class RenderTest < ActionController::TestCase def test_rendering_nothing_on_layout get :rendering_nothing_on_layout - assert_equal '', @response.body + assert_equal "", @response.body end def test_render_to_string_doesnt_break_assigns @@ -1103,7 +1103,7 @@ class RenderTest < ActionController::TestCase def test_render_text_with_assigns_option get :render_with_assigns_option - assert_equal 'world', response.body + assert_equal "world", response.body end # :ported: diff --git a/actionview/test/actionpack/controller/view_paths_test.rb b/actionview/test/actionpack/controller/view_paths_test.rb index e99659c802..9471c76921 100644 --- a/actionview/test/actionpack/controller/view_paths_test.rb +++ b/actionview/test/actionpack/controller/view_paths_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class ViewLoadPathsTest < ActionController::TestCase class TestController < ActionController::Base @@ -7,7 +7,7 @@ class ViewLoadPathsTest < ActionController::TestCase before_action :add_view_path, only: :hello_world_at_request_time def hello_world() end - def hello_world_at_request_time() render(:action => 'hello_world') end + def hello_world_at_request_time() render(action: "hello_world") end private def add_view_path @@ -17,15 +17,15 @@ class ViewLoadPathsTest < ActionController::TestCase module Test class SubController < ActionController::Base - layout 'test/sub' - def hello_world; render(:template => 'test/hello_world'); end + layout "test/sub" + def hello_world; render(template: "test/hello_world"); end end end def setup - @request = ActionController::TestRequest.create - @response = ActionDispatch::TestResponse.new @controller = TestController.new + @request = ActionController::TestRequest.create(@controller.class) + @response = ActionDispatch::TestResponse.new @paths = TestController.view_paths end @@ -47,7 +47,7 @@ class ViewLoadPathsTest < ActionController::TestCase end def test_controller_appends_view_path_correctly - @controller.append_view_path 'foo' + @controller.append_view_path "foo" assert_paths(FIXTURE_LOAD_PATH, "foo") @controller.append_view_path(%w(bar baz)) @@ -58,7 +58,7 @@ class ViewLoadPathsTest < ActionController::TestCase end def test_controller_prepends_view_path_correctly - @controller.prepend_view_path 'baz' + @controller.prepend_view_path "baz" assert_paths("baz", FIXTURE_LOAD_PATH) @controller.prepend_view_path(%w(foo bar)) @@ -72,7 +72,7 @@ class ViewLoadPathsTest < ActionController::TestCase @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) class_view_paths = TestController.view_paths - @controller.append_view_path 'foo' + @controller.append_view_path "foo" assert_paths FIXTURE_LOAD_PATH, "foo" @controller.append_view_path(%w(bar baz)) @@ -84,7 +84,7 @@ class ViewLoadPathsTest < ActionController::TestCase @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) class_view_paths = TestController.view_paths - @controller.prepend_view_path 'baz' + @controller.prepend_view_path "baz" assert_paths "baz", FIXTURE_LOAD_PATH @controller.prepend_view_path(%w(foo bar)) @@ -131,10 +131,8 @@ class ViewLoadPathsTest < ActionController::TestCase "Decorated body", template.identifier, template.handler, - { - :virtual_path => template.virtual_path, - :format => template.formats - } + virtual_path: template.virtual_path, + format: template.formats ) end end @@ -157,14 +155,14 @@ class ViewLoadPathsTest < ActionController::TestCase class C < ActionController::Base; end } - A.view_paths = ['a/path'] + A.view_paths = ["a/path"] assert_paths A, "a/path" assert_paths A, *B.view_paths assert_paths C, *original_load_paths C.view_paths = [] - assert_nothing_raised { C.append_view_path 'c/path' } + assert_nothing_raised { C.append_view_path "c/path" } assert_paths C, "c/path" end |