diff options
Diffstat (limited to 'actionview/test/actionpack/abstract')
4 files changed, 63 insertions, 71 deletions
diff --git a/actionview/test/actionpack/abstract/abstract_controller_test.rb b/actionview/test/actionpack/abstract/abstract_controller_test.rb index 490932fef0..c92467c15f 100644 --- a/actionview/test/actionpack/abstract/abstract_controller_test.rb +++ b/actionview/test/actionpack/abstract/abstract_controller_test.rb @@ -1,9 +1,8 @@ -require 'abstract_unit' -require 'set' +require "abstract_unit" +require "set" module AbstractController module Testing - # Test basic dispatching. # ==== # * Call process @@ -38,7 +37,7 @@ module AbstractController def render(options = {}) if options.is_a?(String) - options = {:_template_name => options} + options = {_template_name: options} end super end @@ -65,11 +64,11 @@ module AbstractController end def rendering_to_body - self.response_body = render_to_body :template => "naked_render" + self.response_body = render_to_body template: "naked_render" end def rendering_to_string - self.response_body = render_to_string :template => "naked_render" + self.response_body = render_to_string template: "naked_render" end end @@ -114,13 +113,13 @@ module AbstractController # * self._prefix is used when defined class PrefixedViews < RenderingController private - def self.prefix - name.underscore - end + def self.prefix + name.underscore + end - def _prefixes - [self.class.prefix] - end + def _prefixes + [self.class.prefix] + end end class Me3 < PrefixedViews @@ -189,19 +188,19 @@ module AbstractController include ActionView::Layouts private - def self.layout(formats) - find_template(name.underscore, {:formats => formats}, :_prefixes => ["layouts"]) - rescue ActionView::MissingTemplate - begin - find_template("application", {:formats => formats}, :_prefixes => ["layouts"]) + def self.layout(formats) + find_template(name.underscore, {formats: formats}, _prefixes: ["layouts"]) rescue ActionView::MissingTemplate + begin + find_template("application", {formats: formats}, _prefixes: ["layouts"]) + rescue ActionView::MissingTemplate + end end - end - def render_to_body(options = {}) - options[:_layout] = options[:layout] || _default_layout({}) - super - end + def render_to_body(options = {}) + options[:_layout] = options[:layout] || _default_layout({}) + super + end end class Me4 < WithLayouts @@ -248,7 +247,6 @@ module AbstractController end class TestRespondToAction < ActiveSupport::TestCase - def assert_dispatch(klass, body = "success", action = :index) controller = klass.new controller.process(action) @@ -284,11 +282,9 @@ module AbstractController end class TestActionMethodsReloading < ActiveSupport::TestCase - test "action_methods should be reloaded after defining a new method" do assert_equal Set.new(["index"]), Me6.action_methods end end - end end diff --git a/actionview/test/actionpack/abstract/helper_test.rb b/actionview/test/actionpack/abstract/helper_test.rb index 7d346e917d..5a2f0839e5 100644 --- a/actionview/test/actionpack/abstract/helper_test.rb +++ b/actionview/test/actionpack/abstract/helper_test.rb @@ -1,17 +1,16 @@ -require 'abstract_unit' +require "abstract_unit" -ActionController::Base.helpers_path = File.expand_path('../../../fixtures/helpers', __FILE__) +ActionController::Base.helpers_path = File.expand_path("../../../fixtures/helpers", __FILE__) module AbstractController module Testing - class ControllerWithHelpers < AbstractController::Base include AbstractController::Helpers include AbstractController::Rendering include ActionView::Rendering def with_module - render :inline => "Module <%= included_method %>" + render inline: "Module <%= included_method %>" end end @@ -31,11 +30,11 @@ module AbstractController helper :abc def with_block - render :inline => "Hello <%= helpery_test %>" + render inline: "Hello <%= helpery_test %>" end def with_symbol - render :inline => "I respond to bare_a: <%= respond_to?(:bare_a) %>" + render inline: "I respond to bare_a: <%= respond_to?(:bare_a) %>" end end @@ -52,7 +51,7 @@ module AbstractController class AbstractInvalidHelpers < AbstractHelpers include ActionController::Helpers - path = File.expand_path('../../../fixtures/helpers_missing', __FILE__) + path = File.expand_path("../../../fixtures/helpers_missing", __FILE__) $:.unshift(path) self.helpers_path = path end diff --git a/actionview/test/actionpack/abstract/layouts_test.rb b/actionview/test/actionpack/abstract/layouts_test.rb index 78f6e78c61..4ece992597 100644 --- a/actionview/test/actionpack/abstract/layouts_test.rb +++ b/actionview/test/actionpack/abstract/layouts_test.rb @@ -1,8 +1,7 @@ -require 'abstract_unit' +require "abstract_unit" module AbstractControllerTests module Layouts - # Base controller for these tests class Base < AbstractController::Base include AbstractController::Rendering @@ -30,7 +29,7 @@ module AbstractControllerTests self.view_paths = [] def index - render :template => ActionView::Template::Text.new("Hello blank!") + render template: ActionView::Template::Text.new("Hello blank!") end end @@ -38,7 +37,7 @@ module AbstractControllerTests layout "hello_locals" def index - render :template => 'some/template', locals: { foo: "less than 3" } + render template: "some/template", locals: { foo: "less than 3" } end end @@ -46,7 +45,7 @@ module AbstractControllerTests layout "hello" def index - render :template => ActionView::Template::Text.new("Hello string!") + render template: ActionView::Template::Text.new("Hello string!") end def action_has_layout_false @@ -54,15 +53,15 @@ module AbstractControllerTests end def overwrite_default - render :template => ActionView::Template::Text.new("Hello string!"), :layout => :default + render template: ActionView::Template::Text.new("Hello string!"), layout: :default end def overwrite_false - render :template => ActionView::Template::Text.new("Hello string!"), :layout => false + render template: ActionView::Template::Text.new("Hello string!"), layout: false end def overwrite_string - render :template => ActionView::Template::Text.new("Hello string!"), :layout => "overwrite" + render template: ActionView::Template::Text.new("Hello string!"), layout: "overwrite" end def overwrite_skip @@ -92,7 +91,7 @@ module AbstractControllerTests layout proc { "overwrite" } def index - render :template => ActionView::Template::Text.new("Hello proc!") + render template: ActionView::Template::Text.new("Hello proc!") end end @@ -116,7 +115,7 @@ module AbstractControllerTests layout proc { "overwrite" } def index - render :template => ActionView::Template::Text.new("Hello zero arity proc!") + render template: ActionView::Template::Text.new("Hello zero arity proc!") end end @@ -129,7 +128,7 @@ module AbstractControllerTests } def index - render :template => ActionView::Template::Text.new("Hello again zero arity proc!") + render template: ActionView::Template::Text.new("Hello again zero arity proc!") end end @@ -137,7 +136,7 @@ module AbstractControllerTests layout :hello def index - render :template => ActionView::Template::Text.new("Hello symbol!") + render template: ActionView::Template::Text.new("Hello symbol!") end private def hello @@ -149,7 +148,7 @@ module AbstractControllerTests layout :nilz def index - render :template => ActionView::Template::Text.new("Hello nilz!") + render template: ActionView::Template::Text.new("Hello nilz!") end def nilz() end @@ -159,7 +158,7 @@ module AbstractControllerTests layout :objekt def index - render :template => ActionView::Template::Text.new("Hello nilz!") + render template: ActionView::Template::Text.new("Hello nilz!") end def objekt @@ -171,7 +170,7 @@ module AbstractControllerTests layout :no_method def index - render :template => ActionView::Template::Text.new("Hello boom!") + render template: ActionView::Template::Text.new("Hello boom!") end end @@ -179,7 +178,7 @@ module AbstractControllerTests layout "missing" def index - render :template => ActionView::Template::Text.new("Hello missing!") + render template: ActionView::Template::Text.new("Hello missing!") end end @@ -187,7 +186,7 @@ module AbstractControllerTests layout false def index - render :template => ActionView::Template::Text.new("Hello false!") + render template: ActionView::Template::Text.new("Hello false!") end end @@ -195,19 +194,19 @@ module AbstractControllerTests layout nil def index - render :template => ActionView::Template::Text.new("Hello nil!") + render template: ActionView::Template::Text.new("Hello nil!") end end class WithOnlyConditional < WithStringImpliedChild - layout "overwrite", :only => :show + layout "overwrite", only: :show def index - render :template => ActionView::Template::Text.new("Hello index!") + render template: ActionView::Template::Text.new("Hello index!") end def show - render :template => ActionView::Template::Text.new("Hello show!") + render template: ActionView::Template::Text.new("Hello show!") end end @@ -220,14 +219,14 @@ module AbstractControllerTests end class WithExceptConditional < WithStringImpliedChild - layout "overwrite", :except => :show + layout "overwrite", except: :show def index - render :template => ActionView::Template::Text.new("Hello index!") + render template: ActionView::Template::Text.new("Hello index!") end def show - render :template => ActionView::Template::Text.new("Hello show!") + render template: ActionView::Template::Text.new("Hello show!") end end @@ -294,7 +293,7 @@ module AbstractControllerTests 10.times do |x| controller = WithString.new controller.define_singleton_method :index do - render :template => ActionView::Template::Text.new("Hello string!"), :locals => { :"x#{x}" => :omg } + render template: ActionView::Template::Text.new("Hello string!"), locals: { :"x#{x}" => :omg } end controller.process(:index) end @@ -349,7 +348,7 @@ module AbstractControllerTests end test "when layout is specified as a proc, do not leak any methods into controller's action_methods" do - assert_equal Set.new(['index']), WithProc.action_methods + assert_equal Set.new(["index"]), WithProc.action_methods end test "when layout is specified as a proc, call it and use the layout returned" do @@ -422,16 +421,16 @@ module AbstractControllerTests test "when a grandchild has no layout specified, the child has an implied layout, and the " \ "parent has specified a layout, use the child controller layout" do - controller = WithChildOfImplied.new - controller.process(:index) - assert_equal "With Implied Hello string!", controller.response_body + controller = WithChildOfImplied.new + controller.process(:index) + assert_equal "With Implied Hello string!", controller.response_body end test "when a grandchild has nil layout specified, the child has an implied layout, and the " \ "parent has specified a layout, use the grand child controller layout" do - controller = WithGrandChildOfImplied.new - controller.process(:index) - assert_equal "With Grand Child Hello string!", controller.response_body + controller = WithGrandChildOfImplied.new + controller.process(:index) + assert_equal "With Grand Child Hello string!", controller.response_body end test "a child inherits layout from abstract controller" do @@ -543,7 +542,7 @@ module AbstractControllerTests test "layout for anonymous controller" do klass = Class.new(WithString) do def index - render plain: 'index', layout: true + render plain: "index", layout: true end end diff --git a/actionview/test/actionpack/abstract/render_test.rb b/actionview/test/actionpack/abstract/render_test.rb index e185b76adb..8b0c54fb77 100644 --- a/actionview/test/actionpack/abstract/render_test.rb +++ b/actionview/test/actionpack/abstract/render_test.rb @@ -1,8 +1,7 @@ -require 'abstract_unit' +require "abstract_unit" module AbstractController module Testing - class ControllerRenderer < AbstractController::Base include AbstractController::Rendering include ActionView::Rendering @@ -21,15 +20,15 @@ module AbstractController )] def template - render :template => "template" + render template: "template" end def file - render :file => "some/file" + render file: "some/file" end def inline - render :inline => "With <%= :Inline %>" + render inline: "With <%= :Inline %>" end def text @@ -54,7 +53,6 @@ module AbstractController end class TestRenderer < ActiveSupport::TestCase - def setup @controller = ControllerRenderer.new end |