diff options
Diffstat (limited to 'actionpack')
81 files changed, 557 insertions, 557 deletions
diff --git a/actionpack/lib/abstract_controller/caching/fragments.rb b/actionpack/lib/abstract_controller/caching/fragments.rb index 3257a731ed..c85b4adba1 100644 --- a/actionpack/lib/abstract_controller/caching/fragments.rb +++ b/actionpack/lib/abstract_controller/caching/fragments.rb @@ -51,7 +51,7 @@ module AbstractController # end # end def fragment_cache_key(value = nil, &key) - self.fragment_cache_keys += [key || ->{ value }] + self.fragment_cache_keys += [key || -> { value }] end end diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb index 873e88fcd5..73775e12c2 100644 --- a/actionpack/lib/abstract_controller/callbacks.rb +++ b/actionpack/lib/abstract_controller/callbacks.rb @@ -49,7 +49,7 @@ module AbstractController def _normalize_callback_option(options, from, to) # :nodoc: if from = options[from] _from = Array(from).map(&:to_s).to_set - from = proc {|c| _from.include? c.action_name } + from = proc { |c| _from.include? c.action_name } options[to] = Array(options[to]).unshift(from) end end diff --git a/actionpack/lib/action_controller/metal/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb index eee17082b7..a26ebd2b24 100644 --- a/actionpack/lib/action_controller/metal/conditional_get.rb +++ b/actionpack/lib/action_controller/metal/conditional_get.rb @@ -238,7 +238,7 @@ module ActionController ) options.delete(:private) - response.cache_control[:extras] = options.map {|k,v| "#{k}=#{v}"} + response.cache_control[:extras] = options.map { |k,v| "#{k}=#{v}" } response.date = Time.now unless response.date? end diff --git a/actionpack/lib/action_controller/metal/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb index 22aadb9dfa..a335bf109e 100644 --- a/actionpack/lib/action_controller/metal/http_authentication.rb +++ b/actionpack/lib/action_controller/metal/http_authentication.rb @@ -236,7 +236,7 @@ module ActionController def encode_credentials(http_method, credentials, password, password_is_ha1) credentials[:response] = expected_response(http_method, credentials[:uri], credentials, password, password_is_ha1) - "Digest " + credentials.sort_by {|x| x[0].to_s }.map {|v| "#{v[0]}='#{v[1]}'" }.join(", ") + "Digest " + credentials.sort_by { |x| x[0].to_s }.map { |v| "#{v[0]}='#{v[1]}'" }.join(", ") end def decode_credentials_header(request) diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb index 0d998632fc..f6aabcb102 100644 --- a/actionpack/lib/action_controller/metal/mime_responds.rb +++ b/actionpack/lib/action_controller/metal/mime_responds.rb @@ -280,8 +280,8 @@ module ActionController #:nodoc: def any(*args, &block) if block_given? - if args.any? && args.none?{ |a| a == @variant } - args.each{ |v| @variants[v] = block } + if args.any? && args.none? { |a| a == @variant } + args.each { |v| @variants[v] = block } else @variants[:any] = block end diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 7f5144bc49..5e7441b3ab 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -750,7 +750,7 @@ module ActionController ] def permitted_scalar?(value) - PERMITTED_SCALAR_TYPES.any? {|type| value.is_a?(type)} + PERMITTED_SCALAR_TYPES.any? { |type| value.is_a?(type) } end def permitted_scalar_filter(params, key) @@ -766,7 +766,7 @@ module ActionController end def array_of_permitted_scalars?(value) - if value.is_a?(Array) && value.all? {|element| permitted_scalar?(element)} + if value.is_a?(Array) && value.all? { |element| permitted_scalar?(element) } yield value end end diff --git a/actionpack/lib/action_controller/metal/testing.rb b/actionpack/lib/action_controller/metal/testing.rb index ac37b00010..9bb416178a 100644 --- a/actionpack/lib/action_controller/metal/testing.rb +++ b/actionpack/lib/action_controller/metal/testing.rb @@ -13,7 +13,7 @@ module ActionController module ClassMethods def before_filters - _process_action_callbacks.find_all{|x| x.kind == :before}.map(&:name) + _process_action_callbacks.find_all { |x| x.kind == :before }.map(&:name) end end end diff --git a/actionpack/lib/action_dispatch/http/parameters.rb b/actionpack/lib/action_dispatch/http/parameters.rb index 42e80b9bf5..31ef0af791 100644 --- a/actionpack/lib/action_dispatch/http/parameters.rb +++ b/actionpack/lib/action_dispatch/http/parameters.rb @@ -8,7 +8,7 @@ module ActionDispatch DEFAULT_PARSERS = { Mime[:json].symbol => -> (raw_post) { data = ActiveSupport::JSON.decode(raw_post) - data.is_a?(Hash) ? data : {_json: data} + data.is_a?(Hash) ? data : { _json: data } } } diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index e7cc6d5f31..e4ef9783f3 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -68,7 +68,7 @@ module ActionDispatch PASS_NOT_FOUND = Class.new { # :nodoc: def self.action(_); self; end - def self.call(_); [404, {"X-Cascade" => "pass"}, []]; end + def self.call(_); [404, { "X-Cascade" => "pass" }, []]; end def self.encoding_for_param(action, param); ::Encoding::UTF_8; end } diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index d3d79f8750..a289c34e8b 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -44,7 +44,7 @@ module ActionDispatch return [route.format(parameterized_parts), params] end - message = "No route matches #{Hash[constraints.sort_by{|k,v| k.to_s}].inspect}" + message = "No route matches #{Hash[constraints.sort_by { |k,v| k.to_s }].inspect}" message << " missing required keys: #{missing_keys.sort.inspect}" if missing_keys && !missing_keys.empty? raise ActionController::UrlGenerationError, message diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb index 727763c972..caa7a3ff51 100644 --- a/actionpack/lib/action_dispatch/journey/router.rb +++ b/actionpack/lib/action_dispatch/journey/router.rb @@ -48,7 +48,7 @@ module ActionDispatch return [status, headers, body] end - return [404, {"X-Cascade" => "pass"}, ["Not Found"]] + return [404, { "X-Cascade" => "pass" }, ["Not Found"]] end def recognize(rails_req) diff --git a/actionpack/lib/action_dispatch/journey/router/utils.rb b/actionpack/lib/action_dispatch/journey/router/utils.rb index e72db2e8f6..ce5d350763 100644 --- a/actionpack/lib/action_dispatch/journey/router/utils.rb +++ b/actionpack/lib/action_dispatch/journey/router/utils.rb @@ -28,7 +28,7 @@ module ActionDispatch US_ASCII = Encoding::US_ASCII UTF_8 = Encoding::UTF_8 EMPTY = "".force_encoding(US_ASCII).freeze - DEC2HEX = (0..255).to_a.map{ |i| ENCODE % i }.map{ |s| s.force_encoding(US_ASCII) } + DEC2HEX = (0..255).to_a.map { |i| ENCODE % i }.map { |s| s.force_encoding(US_ASCII) } ALPHA = "a-zA-Z".freeze DIGIT = "0-9".freeze @@ -60,7 +60,7 @@ module ActionDispatch protected def escape(component, pattern) - component.gsub(pattern){ |unsafe| percent_encode(unsafe) }.force_encoding(US_ASCII) + component.gsub(pattern) { |unsafe| percent_encode(unsafe) }.force_encoding(US_ASCII) end def percent_encode(unsafe) diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index bebf220488..ff83c4beca 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -355,7 +355,7 @@ module ActionDispatch end elsif options[:domain].is_a? Array # if host matches one of the supplied domains without a dot in front of it - options[:domain] = options[:domain].find {|domain| request.host.include? domain.sub(/^\./, "") } + options[:domain] = options[:domain].find { |domain| request.host.include? domain.sub(/^\./, "") } end end @@ -406,7 +406,7 @@ module ActionDispatch # Removes all cookies on the client machine by calling <tt>delete</tt> for each cookie def clear(options = {}) - @cookies.each_key{ |k| delete(k, options) } + @cookies.each_key { |k| delete(k, options) } end def write(headers) diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index d585e7042e..ee644f41c8 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -151,7 +151,7 @@ module ActionDispatch end def render(status, body, format) - [status, {"Content-Type" => "#{format}; charset=#{Response.default_charset}", "Content-Length" => body.bytesize.to_s}, [body]] + [status, { "Content-Type" => "#{format}; charset=#{Response.default_charset}", "Content-Length" => body.bytesize.to_s }, [body]] end def log_error(request, wrapper) diff --git a/actionpack/lib/action_dispatch/middleware/debug_locks.rb b/actionpack/lib/action_dispatch/middleware/debug_locks.rb index 91c2fbac01..74b952528e 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_locks.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_locks.rb @@ -86,11 +86,11 @@ module ActionDispatch end blockers = threads.values.select { |binfo| blocked_by?(info, binfo, threads.values) } - msg << " blocked by: #{blockers.map {|i| i[:index] }.join(', ')}\n" if blockers.any? + msg << " blocked by: #{blockers.map { |i| i[:index] }.join(', ')}\n" if blockers.any? end blockees = threads.values.select { |binfo| blocked_by?(binfo, info, threads.values) } - msg << " blocking: #{blockees.map {|i| i[:index] }.join(', ')}\n" if blockees.any? + msg << " blocking: #{blockees.map { |i| i[:index] }.join(', ')}\n" if blockees.any? msg << "\n#{info[:backtrace].join("\n")}\n" if info[:backtrace] end.join("\n\n---\n\n\n") diff --git a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb index e3555ce638..46f0f675b9 100644 --- a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb @@ -37,8 +37,8 @@ module ActionDispatch end def render_format(status, content_type, body) - [status, {"Content-Type" => "#{content_type}; charset=#{ActionDispatch::Response.default_charset}", - "Content-Length" => body.bytesize.to_s}, [body]] + [status, { "Content-Type" => "#{content_type}; charset=#{ActionDispatch::Response.default_charset}", + "Content-Length" => body.bytesize.to_s }, [body]] end def render_html(status) diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb index 5aff130bc3..90f26a1c33 100644 --- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb @@ -54,7 +54,7 @@ module ActionDispatch end def pass_response(status) - [status, {"Content-Type" => "text/html; charset=#{Response.default_charset}", "Content-Length" => "0"}, []] + [status, { "Content-Type" => "text/html; charset=#{Response.default_charset}", "Content-Length" => "0" }, []] end end end diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb index ea948076fa..48cc91bbfa 100644 --- a/actionpack/lib/action_dispatch/railtie.rb +++ b/actionpack/lib/action_dispatch/railtie.rb @@ -8,8 +8,8 @@ module ActionDispatch config.action_dispatch.show_exceptions = true config.action_dispatch.tld_length = 1 config.action_dispatch.ignore_accept_header = false - config.action_dispatch.rescue_templates = { } - config.action_dispatch.rescue_responses = { } + config.action_dispatch.rescue_templates = {} + config.action_dispatch.rescue_responses = {} config.action_dispatch.default_charset = nil config.action_dispatch.rack_cache = false config.action_dispatch.http_auth_salt = "http authentication" diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index abbf6b06b6..3f4f920a87 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -41,7 +41,7 @@ module ActionDispatch end def serve(req) - return [ 404, {"X-Cascade" => "pass"}, [] ] unless matches?(req) + return [ 404, { "X-Cascade" => "pass" }, [] ] unless matches?(req) @strategy.call @app, req end @@ -270,7 +270,7 @@ module ActionDispatch { requirements: { format: Regexp.compile(formatted) }, defaults: { format: formatted } } else - { requirements: { }, defaults: { } } + { requirements: {}, defaults: {} } end end diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb index abb51ce357..87bcceccc0 100644 --- a/actionpack/lib/action_dispatch/routing/redirection.rb +++ b/actionpack/lib/action_dispatch/routing/redirection.rb @@ -61,15 +61,15 @@ module ActionDispatch end def escape(params) - Hash[params.map{ |k,v| [k, Rack::Utils.escape(v)] }] + Hash[params.map { |k,v| [k, Rack::Utils.escape(v)] }] end def escape_fragment(params) - Hash[params.map{ |k,v| [k, Journey::Router::Utils.escape_fragment(v)] }] + Hash[params.map { |k,v| [k, Journey::Router::Utils.escape_fragment(v)] }] end def escape_path(params) - Hash[params.map{ |k,v| [k, Journey::Router::Utils.escape_path(v)] }] + Hash[params.map { |k,v| [k, Journey::Router::Utils.escape_path(v)] }] end end @@ -128,7 +128,7 @@ module ActionDispatch end def inspect - "redirect(#{status}, #{options.map{ |k,v| "#{k}: #{v}" }.join(', ')})" + "redirect(#{status}, #{options.map { |k,v| "#{k}: #{v}" }.join(', ')})" end end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index b9eda039a1..112a38b868 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -34,7 +34,7 @@ module ActionDispatch if @raise_on_name_error raise else - return [404, {"X-Cascade" => "pass"}, []] + return [404, { "X-Cascade" => "pass" }, []] end end @@ -208,7 +208,7 @@ module ActionDispatch params = parameterize_args(args) { |missing_key| missing_keys << missing_key } - constraints = Hash[@route.requirements.merge(params).sort_by{|k,v| k.to_s}] + constraints = Hash[@route.requirements.merge(params).sort_by { |k,v| k.to_s }] message = "No route matches #{constraints.inspect}" message << " missing required keys: #{missing_keys.sort.inspect}" diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index 2ea4a6c130..e53bc6af12 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -127,7 +127,7 @@ module ActionDispatch options[:controller] = "/#{controller}" end - generate_options = options.dup.delete_if{ |k, _| defaults.key?(k) } + generate_options = options.dup.delete_if { |k, _| defaults.key?(k) } assert_generates(path.is_a?(Hash) ? path[:path] : path, generate_options, defaults, extras, message) end diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 7bff21b5a2..c5b2493e06 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -123,7 +123,7 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase # simply return the controller#action as Rack::Body. class NullController < ::ActionController::Metal def self.dispatch(action, req, res) - [200, {"Content-Type" => "text/html"}, ["#{req.params[:controller]}##{action}"]] + [200, { "Content-Type" => "text/html" }, ["#{req.params[:controller]}##{action}"]] end end @@ -164,7 +164,7 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase ActiveSupport::Dependencies.autoload_paths << path yield ensure - ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path} + ActiveSupport::Dependencies.autoload_paths.reject! { |p| p == path } ActiveSupport::Dependencies.clear end end @@ -259,9 +259,9 @@ module ActionDispatch host = uri_or_host.host unless path path ||= uri_or_host.path - params = {"PATH_INFO" => path, + params = { "PATH_INFO" => path, "REQUEST_METHOD" => method, - "HTTP_HOST" => host} + "HTTP_HOST" => host } routes.call(params) end diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 55b4c1e6a6..b08f1f1707 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -165,7 +165,7 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase def test_string_constraint with_routing do |set| set.draw do - get "photos", to: "action_pack_assertions#nothing", constraints: {subdomain: "admin"} + get "photos", to: "action_pack_assertions#nothing", constraints: { subdomain: "admin" } end end end diff --git a/actionpack/test/controller/api/params_wrapper_test.rb b/actionpack/test/controller/api/params_wrapper_test.rb index cdf5acecae..a1da852040 100644 --- a/actionpack/test/controller/api/params_wrapper_test.rb +++ b/actionpack/test/controller/api/params_wrapper_test.rb @@ -20,7 +20,7 @@ class ParamsWrapperForApiTest < ActionController::TestCase @request.env["CONTENT_TYPE"] = "application/json" post :test, params: { "username" => "sikachu" } - expected = { "username" => "sikachu", "person" => { "username" => "sikachu" }} + expected = { "username" => "sikachu", "person" => { "username" => "sikachu" } } assert_equal expected, @controller.last_parameters end end diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 5f4857c553..18490c7d73 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -49,7 +49,7 @@ class FragmentCachingTest < ActionController::TestCase @controller = FragmentCachingTestController.new @controller.perform_caching = true @controller.cache_store = @store - @params = {controller: "posts", action: "index"} + @params = { controller: "posts", action: "index" } @controller.params = @params @controller.request = @request @controller.response = @response @@ -324,7 +324,7 @@ class CacheHelperOutputBufferTest < ActionController::TestCase cache_helper.stub :output_buffer, output_buffer do assert_called_with cache_helper, :output_buffer=, [output_buffer.class.new(output_buffer)] do assert_nothing_raised do - cache_helper.send :fragment_for, "Test fragment name", "Test fragment", &Proc.new{ nil } + cache_helper.send :fragment_for, "Test fragment name", "Test fragment", &Proc.new { nil } end end end @@ -345,7 +345,7 @@ class CacheHelperOutputBufferTest < ActionController::TestCase cache_helper.stub :output_buffer, output_buffer do assert_called_with cache_helper, :output_buffer=, [output_buffer.class.new(output_buffer)] do assert_nothing_raised do - cache_helper.send :fragment_for, "Test fragment name", "Test fragment", &Proc.new{ nil } + cache_helper.send :fragment_for, "Test fragment name", "Test fragment", &Proc.new { nil } end end end diff --git a/actionpack/test/controller/default_url_options_with_before_action_test.rb b/actionpack/test/controller/default_url_options_with_before_action_test.rb index 703f9f1fde..e3fe7a6495 100644 --- a/actionpack/test/controller/default_url_options_with_before_action_test.rb +++ b/actionpack/test/controller/default_url_options_with_before_action_test.rb @@ -13,7 +13,7 @@ class ControllerWithBeforeActionAndDefaultUrlOptions < ActionController::Base end def default_url_options - {locale: "de"} + { locale: "de" } end end diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 237711452a..e0987070a3 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -174,11 +174,11 @@ class FilterTest < ActionController::TestCase end class OnlyConditionProcController < ConditionalFilterController - before_action(only: :show) {|c| c.instance_variable_set(:"@ran_proc_action", true) } + before_action(only: :show) { |c| c.instance_variable_set(:"@ran_proc_action", true) } end class ExceptConditionProcController < ConditionalFilterController - before_action(except: :show_without_action) {|c| c.instance_variable_set(:"@ran_proc_action", true) } + before_action(except: :show_without_action) { |c| c.instance_variable_set(:"@ran_proc_action", true) } end class ConditionalClassFilter @@ -194,11 +194,11 @@ class FilterTest < ActionController::TestCase end class AnomolousYetValidConditionController < ConditionalFilterController - before_action(ConditionalClassFilter, :ensure_login, Proc.new {|c| c.instance_variable_set(:"@ran_proc_action1", true)}, except: :show_without_action) { |c| c.instance_variable_set(:"@ran_proc_action2", true)} + before_action(ConditionalClassFilter, :ensure_login, Proc.new { |c| c.instance_variable_set(:"@ran_proc_action1", true) }, except: :show_without_action) { |c| c.instance_variable_set(:"@ran_proc_action2", true) } end class OnlyConditionalOptionsFilter < ConditionalFilterController - before_action :ensure_login, only: :index, if: Proc.new {|c| c.instance_variable_set(:"@ran_conditional_index_proc", true) } + before_action :ensure_login, only: :index, if: Proc.new { |c| c.instance_variable_set(:"@ran_conditional_index_proc", true) } end class ConditionalOptionsFilter < ConditionalFilterController diff --git a/actionpack/test/controller/flash_hash_test.rb b/actionpack/test/controller/flash_hash_test.rb index 16651a3fd7..32f0db71f5 100644 --- a/actionpack/test/controller/flash_hash_test.rb +++ b/actionpack/test/controller/flash_hash_test.rb @@ -48,11 +48,11 @@ module ActionDispatch def test_to_hash @hash["foo"] = "bar" - assert_equal({"foo" => "bar"}, @hash.to_hash) + assert_equal({ "foo" => "bar" }, @hash.to_hash) @hash.to_hash["zomg"] = "aaron" assert !@hash.key?("zomg") - assert_equal({"foo" => "bar"}, @hash.to_hash) + assert_equal({ "foo" => "bar" }, @hash.to_hash) end def test_to_session_value @@ -74,7 +74,7 @@ module ActionDispatch rails_3_2_cookie = "BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsGSSINZmFyZXdlbGwGOwBUVDoMQGNsb3NlZEY6DUBmbGFzaGVzewdJIg1ncmVldGluZwY7AFRJIgpIZWxsbwY7AFRJIg1mYXJld2VsbAY7AFRJIgxHb29kYnllBjsAVDoJQG5vdzA=" session = Marshal.load(Base64.decode64(rails_3_2_cookie)) hash = Flash::FlashHash.from_session_value(session["flash"]) - assert_equal({"greeting" => "Hello"}, hash.to_hash) + assert_equal({ "greeting" => "Hello" }, hash.to_hash) assert_equal(nil, hash.to_session_value) end @@ -83,7 +83,7 @@ module ActionDispatch session = ActionDispatch::Cookies::JsonSerializer.load(decrypted_data) hash = Flash::FlashHash.from_session_value(session["flash"]) - assert_equal({"greeting" => "Hello"}, hash.to_hash) + assert_equal({ "greeting" => "Hello" }, hash.to_hash) assert_equal(nil, hash.to_session_value) assert_equal "Hello", hash[:greeting] assert_equal "Hello", hash["greeting"] @@ -112,7 +112,7 @@ module ActionDispatch def test_replace @hash["hello"] = "world" @hash.replace("omg" => "aaron") - assert_equal({"omg" => "aaron"}, @hash.to_hash) + assert_equal({ "omg" => "aaron" }, @hash.to_hash) end def test_discard_no_args @@ -129,14 +129,14 @@ module ActionDispatch @hash.discard "hello" @hash.sweep - assert_equal({"omg" => "world"}, @hash.to_hash) + assert_equal({ "omg" => "world" }, @hash.to_hash) end def test_keep_sweep @hash["hello"] = "world" @hash.sweep - assert_equal({"hello" => "world"}, @hash.to_hash) + assert_equal({ "hello" => "world" }, @hash.to_hash) end def test_update_sweep @@ -144,7 +144,7 @@ module ActionDispatch @hash.update("hi" => "mom") @hash.sweep - assert_equal({"hello" => "world", "hi" => "mom"}, @hash.to_hash) + assert_equal({ "hello" => "world", "hi" => "mom" }, @hash.to_hash) end def test_update_delete_sweep @@ -153,7 +153,7 @@ module ActionDispatch @hash.update("hello" => "mom") @hash.sweep - assert_equal({"hello" => "mom"}, @hash.to_hash) + assert_equal({ "hello" => "mom" }, @hash.to_hash) end def test_delete_sweep @@ -162,7 +162,7 @@ module ActionDispatch @hash.delete "hi" @hash.sweep - assert_equal({"hello" => "world"}, @hash.to_hash) + assert_equal({ "hello" => "world" }, @hash.to_hash) end def test_clear_sweep @@ -178,7 +178,7 @@ module ActionDispatch @hash.replace("hi" => "mom") @hash.sweep - assert_equal({"hi" => "mom"}, @hash.to_hash) + assert_equal({ "hi" => "mom" }, @hash.to_hash) end def test_discard_then_add @@ -188,7 +188,7 @@ module ActionDispatch @hash["hello"] = "world" @hash.sweep - assert_equal({"omg" => "world", "hello" => "world"}, @hash.to_hash) + assert_equal({ "omg" => "world", "hello" => "world" }, @hash.to_hash) end def test_keep_all_sweep @@ -198,14 +198,14 @@ module ActionDispatch @hash.keep @hash.sweep - assert_equal({"omg" => "world", "hello" => "world"}, @hash.to_hash) + assert_equal({ "omg" => "world", "hello" => "world" }, @hash.to_hash) end def test_double_sweep @hash["hello"] = "world" @hash.sweep - assert_equal({"hello" => "world"}, @hash.to_hash) + assert_equal({ "hello" => "world" }, @hash.to_hash) @hash.sweep assert_equal({}, @hash.to_hash) diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index 4e046b2fc8..cabbe2d608 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -176,13 +176,13 @@ class FlashTest < ActionController::TestCase assert_equal(:foo_indeed, flash.discard(:foo)) # valid key passed assert_nil flash.discard(:unknown) # non existent key passed - assert_equal({"foo" => :foo_indeed, "bar" => :bar_indeed}, flash.discard().to_hash) # nothing passed - assert_equal({"foo" => :foo_indeed, "bar" => :bar_indeed}, flash.discard(nil).to_hash) # nothing passed + assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.discard().to_hash) # nothing passed + assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.discard(nil).to_hash) # nothing passed assert_equal(:foo_indeed, flash.keep(:foo)) # valid key passed assert_nil flash.keep(:unknown) # non existent key passed - assert_equal({"foo" => :foo_indeed, "bar" => :bar_indeed}, flash.keep().to_hash) # nothing passed - assert_equal({"foo" => :foo_indeed, "bar" => :bar_indeed}, flash.keep(nil).to_hash) # nothing passed + assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.keep().to_hash) # nothing passed + assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.keep(nil).to_hash) # nothing passed end def test_redirect_to_with_alert diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb index 5e9b801f8b..343b7b643d 100644 --- a/actionpack/test/controller/http_digest_authentication_test.rb +++ b/actionpack/test/controller/http_digest_authentication_test.rb @@ -7,7 +7,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase before_action :authenticate_with_request, only: :display USERS = { "lifo" => "world", "pretty" => "please", - "dhh" => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":"))} + "dhh" => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":")) } def index render plain: "Hello Secret" @@ -199,7 +199,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase test "validate_digest_response should fail with nil returning password_procedure" do @request.env["HTTP_AUTHORIZATION"] = encode_credentials(username: nil, password: nil) - assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@request, "SuperSecret"){nil} + assert !ActionController::HttpAuthentication::Digest.validate_digest_response(@request, "SuperSecret") { nil } end test "authentication request with request-uri ending in '/'" do diff --git a/actionpack/test/controller/http_token_authentication_test.rb b/actionpack/test/controller/http_token_authentication_test.rb index b7a4c550d7..3842136682 100644 --- a/actionpack/test/controller/http_token_authentication_test.rb +++ b/actionpack/test/controller/http_token_authentication_test.rb @@ -156,10 +156,10 @@ class HttpTokenAuthenticationTest < ActionController::TestCase test "token_and_options returns correct token with nounce option" do token = "rcHu+HzSFw89Ypyhn/896A=" - nonce_hash = {nonce: "123abc"} + nonce_hash = { nonce: "123abc" } actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token, nonce_hash)) expected_token = token - expected_nonce = {"nonce" => nonce_hash[:nonce]} + expected_nonce = { "nonce" => nonce_hash[:nonce] } assert_equal(expected_token, actual.first) assert_equal(expected_nonce, actual.last) end @@ -190,7 +190,7 @@ class HttpTokenAuthenticationTest < ActionController::TestCase private - def sample_request(token, options = {nonce: "def"}) + def sample_request(token, options = { nonce: "def" }) authorization = options.inject([%{Token token="#{token}"}]) do |arr, (k, v)| arr << "#{k}=\"#{v}\"" end.join(", ") diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 4abbccfbe5..9044eff801 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -4,7 +4,7 @@ require "rails/engine" class SessionTest < ActiveSupport::TestCase StubApp = lambda { |env| - [200, {"Content-Type" => "text/html", "Content-Length" => "13"}, ["Hello, World!"]] + [200, { "Content-Type" => "text/html", "Content-Length" => "13" }, ["Hello, World!"]] } def setup @@ -32,7 +32,7 @@ class SessionTest < ActiveSupport::TestCase end def test_request_via_redirect_uses_given_method - path = "/somepath"; args = {id: "1"}; headers = {"X-Test-Header" => "testvalue"} + path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" } assert_called_with @session, :process, [:put, path, params: args, headers: headers] do @session.stub :redirect?, false do assert_deprecated { @session.request_via_redirect(:put, path, params: args, headers: headers) } @@ -50,17 +50,17 @@ class SessionTest < ActiveSupport::TestCase end def test_request_via_redirect_follows_redirects - path = "/somepath"; args = {id: "1"}; headers = {"X-Test-Header" => "testvalue"} + path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" } value_series = [true, true, false] assert_called @session, :follow_redirect!, times: 2 do - @session.stub :redirect?, ->{ value_series.shift } do + @session.stub :redirect?, -> { value_series.shift } do assert_deprecated { @session.request_via_redirect(:get, path, params: args, headers: headers) } end end end def test_request_via_redirect_returns_status - path = "/somepath"; args = {id: "1"}; headers = {"X-Test-Header" => "testvalue"} + path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" } @session.stub :redirect?, false do @session.stub :status, 200 do assert_deprecated do @@ -466,7 +466,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest def test_get_xml_rss_atom %w[ application/xml application/rss+xml application/atom+xml ].each do |mime_string| with_test_route_set do - get "/get", headers: {"HTTP_ACCEPT" => mime_string} + get "/get", headers: { "HTTP_ACCEPT" => mime_string } assert_equal 200, status assert_equal "OK", status_message assert_response 200 @@ -503,7 +503,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest self.cookies["cookie_2"] = "oatmeal" get "/cookie_monster" assert_equal "cookie_1=; path=/\ncookie_3=chocolate; path=/", headers["Set-Cookie"] - assert_equal({"cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate"}, cookies.to_hash) + assert_equal({ "cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate" }, cookies.to_hash) end end @@ -513,14 +513,14 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest assert_response :success assert_equal "foo=bar; path=/", headers["Set-Cookie"] - assert_equal({"foo"=>"bar"}, cookies.to_hash) + assert_equal({ "foo"=>"bar" }, cookies.to_hash) get "/get_cookie" assert_response :success assert_equal "bar", body assert_equal nil, headers["Set-Cookie"] - assert_equal({"foo"=>"bar"}, cookies.to_hash) + assert_equal({ "foo"=>"bar" }, cookies.to_hash) end end @@ -532,14 +532,14 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest assert_response :success assert_equal "foo=bar; path=/", headers["Set-Cookie"] - assert_equal({"foo"=>"bar"}, cookies.to_hash) + assert_equal({ "foo"=>"bar" }, cookies.to_hash) get "/get_cookie" assert_response :success assert_equal "bar", body assert_equal nil, headers["Set-Cookie"] - assert_equal({"foo"=>"bar"}, cookies.to_hash) + assert_equal({ "foo"=>"bar" }, cookies.to_hash) end end @@ -778,9 +778,9 @@ class MetalIntegrationTest < ActionDispatch::IntegrationTest class Poller def self.call(env) if env["PATH_INFO"] =~ /^\/success/ - [200, {"Content-Type" => "text/plain", "Content-Length" => "12"}, ["Hello World!"]] + [200, { "Content-Type" => "text/plain", "Content-Length" => "12" }, ["Hello World!"]] else - [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []] + [404, { "Content-Type" => "text/plain", "Content-Length" => "0" }, []] end end end @@ -809,7 +809,7 @@ class MetalIntegrationTest < ActionDispatch::IntegrationTest end def test_pass_headers - get "/success", headers: {"Referer" => "http://www.example.com/foo", "Host" => "http://nohost.com"} + get "/success", headers: { "Referer" => "http://www.example.com/foo", "Host" => "http://nohost.com" } assert_equal "http://nohost.com", @request.env["HTTP_HOST"] assert_equal "http://www.example.com/foo", @request.env["HTTP_REFERER"] @@ -885,7 +885,7 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest get "bar", to: "application_integration_test/test#index", as: :bar mount MountedApp => "/mounted", :as => "mounted" - get "fooz" => proc { |env| [ 200, {"X-Cascade" => "pass"}, [ "omg" ] ] }, :anchor => false + get "fooz" => proc { |env| [ 200, { "X-Cascade" => "pass" }, [ "omg" ] ] }, :anchor => false get "fooz", to: "application_integration_test/test#index" end @@ -1158,7 +1158,7 @@ class IntegrationRequestsWithSessionSetup < ActionDispatch::IntegrationTest def test_cookies_set_in_setup_are_persisted_through_the_session get "/foo" - assert_equal({"user_name"=>"david"}, cookies.to_hash) + assert_equal({ "user_name"=>"david" }, cookies.to_hash) end end diff --git a/actionpack/test/controller/live_stream_test.rb b/actionpack/test/controller/live_stream_test.rb index 9ec37e7559..1361e95081 100644 --- a/actionpack/test/controller/live_stream_test.rb +++ b/actionpack/test/controller/live_stream_test.rb @@ -161,7 +161,7 @@ module ActionController response.stream.close latch.count_down - ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path} + ActiveSupport::Dependencies.autoload_paths.reject! { |p| p == path } end def thread_locals @@ -285,7 +285,7 @@ module ActionController def test_set_cookie get :set_cookie - assert_equal({"hello" => "world"}, @response.cookies) + assert_equal({ "hello" => "world" }, @response.cookies) assert_equal "hello world", @response.body end diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 231283acdf..45a120acb6 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -138,7 +138,7 @@ class ACLogSubscriberTest < ActionController::TestCase def test_process_action_without_parameters get :show wait - assert_nil logs.detect {|l| l =~ /Parameters/ } + assert_nil logs.detect { |l| l =~ /Parameters/ } end def test_process_action_with_parameters diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb index 2b6d319999..c5f8165d04 100644 --- a/actionpack/test/controller/mime/respond_to_test.rb +++ b/actionpack/test/controller/mime/respond_to_test.rb @@ -76,7 +76,7 @@ class RespondToController < ActionController::Base def missing_templates respond_to do |type| # This test requires a block that is empty - type.json { } + type.json {} type.xml end end @@ -221,7 +221,7 @@ class RespondToController < ActionController::Base def variant_any respond_to do |format| format.html do |variant| - variant.any(:tablet, :phablet){ render body: "any" } + variant.any(:tablet, :phablet) { render body: "any" } variant.phone { render body: "phone" } end end @@ -238,7 +238,7 @@ class RespondToController < ActionController::Base def variant_inline_any respond_to do |format| - format.html.any(:tablet, :phablet){ render body: "any" } + format.html.any(:tablet, :phablet) { render body: "any" } format.html.phone { render body: "phone" } end end @@ -259,7 +259,7 @@ class RespondToController < ActionController::Base def variant_any_with_none respond_to do |format| - format.html.any(:none, :phone){ render body: "none or phone" } + format.html.any(:none, :phone) { render body: "none or phone" } end end @@ -267,8 +267,8 @@ class RespondToController < ActionController::Base respond_to do |format| format.html { render body: "HTML" } format.any(:js, :xml) do |variant| - variant.phone{ render body: "phone" } - variant.any(:tablet, :phablet){ render body: "tablet" } + variant.phone { render body: "phone" } + variant.any(:tablet, :phablet) { render body: "tablet" } end end end @@ -674,7 +674,7 @@ class RespondToControllerTest < ActionController::TestCase get :variant_without_implicit_template_rendering, xhr: true, params: { v: :does_not_matter } assert_response :no_content - assert_equal 1, logger.logged(:info).select{ |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged" + assert_equal 1, logger.logged(:info).select { |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged" ensure ActionController::Base.logger = old_logger end @@ -686,7 +686,7 @@ class RespondToControllerTest < ActionController::TestCase get :variant_without_implicit_template_rendering, format: "json", params: { v: :does_not_matter } assert_response :no_content - assert_equal 1, logger.logged(:info).select{ |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged" + assert_equal 1, logger.logged(:info).select { |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged" ensure ActionController::Base.logger = old_logger end diff --git a/actionpack/test/controller/new_base/render_file_test.rb b/actionpack/test/controller/new_base/render_file_test.rb index 9618157657..6d651e0104 100644 --- a/actionpack/test/controller/new_base/render_file_test.rb +++ b/actionpack/test/controller/new_base/render_file_test.rb @@ -30,7 +30,7 @@ module RenderFile def with_locals path = File.join(File.dirname(__FILE__), "../../fixtures/test/render_file_with_locals") - render file: path, locals: {secret: "in the sauce"} + render file: path, locals: { secret: "in the sauce" } end end diff --git a/actionpack/test/controller/parameter_encoding_test.rb b/actionpack/test/controller/parameter_encoding_test.rb index 69a72c000b..7840b4f5c4 100644 --- a/actionpack/test/controller/parameter_encoding_test.rb +++ b/actionpack/test/controller/parameter_encoding_test.rb @@ -30,35 +30,35 @@ class ParameterEncodingTest < ActionController::TestCase tests ParameterEncodingController test "properly transcodes UTF8 parameters into declared encodings" do - post :test_foo, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"} + post :test_foo, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" } assert_response :success assert_equal "UTF-8", @response.body end test "properly transcodes ASCII_8BIT parameters into declared encodings" do - post :test_bar, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"} + post :test_bar, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" } assert_response :success assert_equal "ASCII-8BIT", @response.body end test "properly transcodes ISO_8859_1 parameters into declared encodings" do - post :test_baz, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"} + post :test_baz, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" } assert_response :success assert_equal "ISO-8859-1", @response.body end test "does not transcode parameters when not specified" do - post :test_no_change_to_baz, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"} + post :test_no_change_to_baz, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" } assert_response :success assert_equal "UTF-8", @response.body end test "respects different encoding declarations for a param per action" do - post :test_baz_to_ascii, params: {"foo" => "foo", "bar" => "bar", "baz" => "baz"} + post :test_baz_to_ascii, params: { "foo" => "foo", "bar" => "bar", "baz" => "baz" } assert_response :success assert_equal "ASCII-8BIT", @response.body diff --git a/actionpack/test/controller/parameters/accessors_test.rb b/actionpack/test/controller/parameters/accessors_test.rb index a63512e8bd..8a522b2df8 100644 --- a/actionpack/test/controller/parameters/accessors_test.rb +++ b/actionpack/test/controller/parameters/accessors_test.rb @@ -13,7 +13,7 @@ class ParametersAccessorsTest < ActiveSupport::TestCase first: "David", last: "Heinemeier Hansson" }, - addresses: [{city: "Chicago", state: "Illinois"}] + addresses: [{ city: "Chicago", state: "Illinois" }] } ) end diff --git a/actionpack/test/controller/parameters/dup_test.rb b/actionpack/test/controller/parameters/dup_test.rb index 152f608266..d88891ca30 100644 --- a/actionpack/test/controller/parameters/dup_test.rb +++ b/actionpack/test/controller/parameters/dup_test.rb @@ -12,7 +12,7 @@ class ParametersDupTest < ActiveSupport::TestCase first: "David", last: "Heinemeier Hansson" }, - addresses: [{city: "Chicago", state: "Illinois"}] + addresses: [{ city: "Chicago", state: "Illinois" }] } ) end diff --git a/actionpack/test/controller/parameters/mutators_test.rb b/actionpack/test/controller/parameters/mutators_test.rb index a2dc84f2f7..e060e5180f 100644 --- a/actionpack/test/controller/parameters/mutators_test.rb +++ b/actionpack/test/controller/parameters/mutators_test.rb @@ -11,7 +11,7 @@ class ParametersMutatorsTest < ActiveSupport::TestCase first: "David", last: "Heinemeier Hansson" }, - addresses: [{city: "Chicago", state: "Illinois"}] + addresses: [{ city: "Chicago", state: "Illinois" }] } ) end diff --git a/actionpack/test/controller/parameters/nested_parameters_permit_test.rb b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb index f0155477c4..5f86901e30 100644 --- a/actionpack/test/controller/parameters/nested_parameters_permit_test.rb +++ b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb @@ -73,7 +73,7 @@ class NestedParametersPermitTest < ActiveSupport::TestCase genres: ["Tragedy"] }) - permitted = params.permit book: {genres: []} + permitted = params.permit book: { genres: [] } assert_equal ["Tragedy"], permitted[:book][:genres] end @@ -85,7 +85,7 @@ class NestedParametersPermitTest < ActiveSupport::TestCase }, magazine: "Shakespeare Today") - permitted = params.permit({book: ["title", :author]}, "magazine") + permitted = params.permit({ book: ["title", :author] }, "magazine") assert_equal "Romeo and Juliet", permitted[:book][:title] assert_equal "William Shakespeare", permitted[:book][:author] assert_equal "Shakespeare Today", permitted[:magazine] diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb index b42288636e..164efd936c 100644 --- a/actionpack/test/controller/parameters/parameters_permit_test.rb +++ b/actionpack/test/controller/parameters/parameters_permit_test.rb @@ -15,7 +15,7 @@ class ParametersPermitTest < ActiveSupport::TestCase first: "David", last: "Heinemeier Hansson" }, - addresses: [{city: "Chicago", state: "Illinois"}] + addresses: [{ city: "Chicago", state: "Illinois" }] } ) @@ -39,13 +39,13 @@ class ParametersPermitTest < ActiveSupport::TestCase end test "iteration should not impact permit" do - hash = {"foo"=>{"bar"=>{"0"=>{"baz"=>"hello", "zot"=>"1"}}}} + hash = { "foo"=>{ "bar"=>{ "0"=>{ "baz"=>"hello", "zot"=>"1" } } } } params = ActionController::Parameters.new(hash) walk_permitted params sanitized = params[:foo].permit(bar: [:baz]) - assert_equal({"0"=>{"baz"=>"hello"}}, sanitized[:bar].to_unsafe_h) + assert_equal({ "0"=>{ "baz"=>"hello" } }, sanitized[:bar].to_unsafe_h) end test "if nothing is permitted, the hash becomes empty" do @@ -98,7 +98,7 @@ class ParametersPermitTest < ActiveSupport::TestCase end test "key: hashes are filtered out" do - [{}, {foo: 1}, {foo: "bar"}].each do |hash| + [{}, { foo: 1 }, { foo: "bar" }].each do |hash| params = ActionController::Parameters.new(id: hash) permitted = params.permit(:id) assert_filtered_out permitted, :id @@ -161,7 +161,7 @@ class ParametersPermitTest < ActiveSupport::TestCase end test "key to empty array: arrays of non-permitted scalar do not pass" do - [[Object.new], [[]], [[1]], [{}], [{id: "1"}]].each do |non_permitted_scalar| + [[Object.new], [[]], [[1]], [{}], [{ id: "1" }]].each do |non_permitted_scalar| params = ActionController::Parameters.new(id: non_permitted_scalar) permitted = params.permit(id: []) assert_filtered_out permitted, :id @@ -203,10 +203,10 @@ class ParametersPermitTest < ActiveSupport::TestCase # the cache does not get fooled, the hash is still wrapped as strong params, # and not permitted. test "mutated arrays are detected" do - params = ActionController::Parameters.new(users: [{id: 1}]) + params = ActionController::Parameters.new(users: [{ id: 1 }]) permitted = params.permit(users: [:id]) - permitted[:users] << {injected: 1} + permitted[:users] << { injected: 1 } assert_not permitted[:users].last.permitted? end @@ -315,8 +315,8 @@ class ParametersPermitTest < ActiveSupport::TestCase end test "to_unsafe_h returns unfiltered params even after accessing few keys" do - params = ActionController::Parameters.new("f"=>{"language_facet"=>["Tibetan"]}) - expected = {"f"=>{"language_facet"=>["Tibetan"]}} + params = ActionController::Parameters.new("f"=>{ "language_facet"=>["Tibetan"] }) + expected = { "f"=>{ "language_facet"=>["Tibetan"] } } assert params["f"].is_a? ActionController::Parameters assert_equal expected, params.to_unsafe_h diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb index 7800ff26d0..1549405fe7 100644 --- a/actionpack/test/controller/params_wrapper_test.rb +++ b/actionpack/test/controller/params_wrapper_test.rb @@ -150,7 +150,7 @@ class ParamsWrapperTest < ActionController::TestCase def test_no_double_wrap_if_key_exists with_default_wrapper_options do @request.env["CONTENT_TYPE"] = "application/json" - post :parse, params: { "user" => { "username" => "sikachu" }} + post :parse, params: { "user" => { "username" => "sikachu" } } assert_parameters("user" => { "username" => "sikachu" }) end end @@ -158,8 +158,8 @@ class ParamsWrapperTest < ActionController::TestCase def test_nested_params with_default_wrapper_options do @request.env["CONTENT_TYPE"] = "application/json" - post :parse, params: { "person" => { "username" => "sikachu" }} - assert_parameters("person" => { "username" => "sikachu" }, "user" => {"person" => { "username" => "sikachu" }}) + post :parse, params: { "person" => { "username" => "sikachu" } } + assert_parameters("person" => { "username" => "sikachu" }, "user" => { "person" => { "username" => "sikachu" } }) end end @@ -208,7 +208,7 @@ class ParamsWrapperTest < ActionController::TestCase @request.env["CONTENT_TYPE"] = "application/json" post :parse, params: {} assert_parameters( - "user" => { } + "user" => {} ) end end diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index 0539580e14..495e41ce76 100644 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -33,7 +33,7 @@ class RedirectController < ActionController::Base end def redirect_with_status_hash - redirect_to({action: "hello_world"}, status: 301) + redirect_to({ action: "hello_world" }, status: 301) end def redirect_with_protocol @@ -118,7 +118,7 @@ class RedirectController < ActionController::Base end def redirect_to_with_block_and_options - redirect_to proc { {action: "hello_world"} } + redirect_to proc { { action: "hello_world" } } end def redirect_with_header_break diff --git a/actionpack/test/controller/render_json_test.rb b/actionpack/test/controller/render_json_test.rb index 31b11588fd..213829bd9e 100644 --- a/actionpack/test/controller/render_json_test.rb +++ b/actionpack/test/controller/render_json_test.rb @@ -52,7 +52,7 @@ class RenderJsonTest < ActionController::TestCase end def render_json_with_render_to_string - render json: {hello: render_to_string(partial: "partial")} + render json: { hello: render_to_string(partial: "partial") } end def render_json_with_extra_options diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index ba556c1bff..bf83131189 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -805,7 +805,7 @@ class HttpCacheForeverTest < ActionController::TestCase tests HttpCacheForeverController def test_cache_with_public - get :cache_me_forever, params: {public: true} + get :cache_me_forever, params: { public: true } assert_response :ok assert_equal "max-age=#{100.years}, public", @response.headers["Cache-Control"] assert_not_nil @response.etag diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb index 03f112c34d..90d5ab3c67 100644 --- a/actionpack/test/controller/request_forgery_protection_test.rb +++ b/actionpack/test/controller/request_forgery_protection_test.rb @@ -398,7 +398,7 @@ module RequestForgeryProtectionTests end assert_cross_origin_not_blocked { get :same_origin_js, xhr: true } - assert_cross_origin_not_blocked { get :same_origin_js, xhr: true, format: "js"} + assert_cross_origin_not_blocked { get :same_origin_js, xhr: true, format: "js" } assert_cross_origin_not_blocked do @request.accept = "text/javascript" get :negotiate_same_origin, xhr: true @@ -443,7 +443,7 @@ module RequestForgeryProtectionTests assert_cross_origin_not_blocked { post :same_origin_js, params: { format: "js", custom_authenticity_token: @token } } assert_cross_origin_not_blocked do @request.accept = "text/javascript" - post :negotiate_same_origin, params: { custom_authenticity_token: @token} + post :negotiate_same_origin, params: { custom_authenticity_token: @token } end end @@ -613,7 +613,7 @@ class FreeCookieControllerTest < ActionController::TestCase def test_should_allow_all_methods_without_token SecureRandom.stub :base64, @token do [:post, :patch, :put, :delete].each do |method| - assert_nothing_raised { send(method, :index)} + assert_nothing_raised { send(method, :index) } end end end @@ -692,7 +692,7 @@ class PerFormTokensControllerTest < ActionController::TestCase # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_one" assert_nothing_raised do - post :post_one, params: {custom_authenticity_token: form_token} + post :post_one, params: { custom_authenticity_token: form_token } end assert_response :success end @@ -707,7 +707,7 @@ class PerFormTokensControllerTest < ActionController::TestCase # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_two" assert_raises(ActionController::InvalidAuthenticityToken) do - post :post_two, params: {custom_authenticity_token: form_token} + post :post_two, params: { custom_authenticity_token: form_token } end end @@ -721,7 +721,7 @@ class PerFormTokensControllerTest < ActionController::TestCase # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_one" assert_raises(ActionController::InvalidAuthenticityToken) do - patch :post_one, params: {custom_authenticity_token: form_token} + patch :post_one, params: { custom_authenticity_token: form_token } end end @@ -777,13 +777,13 @@ class PerFormTokensControllerTest < ActionController::TestCase # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_one" assert_nothing_raised do - post :post_one, params: {custom_authenticity_token: token} + post :post_one, params: { custom_authenticity_token: token } end assert_response :success end def test_ignores_params - get :index, params: {form_path: "/per_form_tokens/post_one?foo=bar"} + get :index, params: { form_path: "/per_form_tokens/post_one?foo=bar" } form_token = assert_presence_and_fetch_form_csrf_token @@ -792,33 +792,33 @@ class PerFormTokensControllerTest < ActionController::TestCase # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_one?foo=baz" assert_nothing_raised do - post :post_one, params: {custom_authenticity_token: form_token, baz: "foo"} + post :post_one, params: { custom_authenticity_token: form_token, baz: "foo" } end assert_response :success end def test_ignores_trailing_slash_during_generation - get :index, params: {form_path: "/per_form_tokens/post_one/"} + get :index, params: { form_path: "/per_form_tokens/post_one/" } form_token = assert_presence_and_fetch_form_csrf_token # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_one" assert_nothing_raised do - post :post_one, params: {custom_authenticity_token: form_token} + post :post_one, params: { custom_authenticity_token: form_token } end assert_response :success end def test_ignores_origin_during_generation - get :index, params: {form_path: "https://example.com/per_form_tokens/post_one/"} + get :index, params: { form_path: "https://example.com/per_form_tokens/post_one/" } form_token = assert_presence_and_fetch_form_csrf_token # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_one" assert_nothing_raised do - post :post_one, params: {custom_authenticity_token: form_token} + post :post_one, params: { custom_authenticity_token: form_token } end assert_response :success end @@ -831,19 +831,19 @@ class PerFormTokensControllerTest < ActionController::TestCase # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_one/" assert_nothing_raised do - post :post_one, params: {custom_authenticity_token: form_token} + post :post_one, params: { custom_authenticity_token: form_token } end assert_response :success end def test_method_is_case_insensitive - get :index, params: {form_method: "POST"} + get :index, params: { form_method: "POST" } form_token = assert_presence_and_fetch_form_csrf_token # This is required because PATH_INFO isn't reset between requests. @request.env["PATH_INFO"] = "/per_form_tokens/post_one/" assert_nothing_raised do - post :post_one, params: {custom_authenticity_token: form_token} + post :post_one, params: { custom_authenticity_token: form_token } end assert_response :success end diff --git a/actionpack/test/controller/required_params_test.rb b/actionpack/test/controller/required_params_test.rb index c9b0ac874d..315d1ff3e8 100644 --- a/actionpack/test/controller/required_params_test.rb +++ b/actionpack/test/controller/required_params_test.rb @@ -49,7 +49,7 @@ class ParametersRequireTest < ActiveSupport::TestCase end test "require array when all required params are present" do - safe_params = ActionController::Parameters.new(person: {first_name: "Gaurish", title: "Mjallo", city: "Barcelona"}) + safe_params = ActionController::Parameters.new(person: { first_name: "Gaurish", title: "Mjallo", city: "Barcelona" }) .require(:person) .require([:first_name, :title]) @@ -59,7 +59,7 @@ class ParametersRequireTest < ActiveSupport::TestCase test "require array when a required param is missing" do assert_raises(ActionController::ParameterMissing) do - ActionController::Parameters.new(person: {first_name: "Gaurish", title: nil}) + ActionController::Parameters.new(person: { first_name: "Gaurish", title: nil }) .require(:person) .require([:first_name, :title]) end diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 91d3072fdb..29471939d0 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -28,7 +28,7 @@ class ResourcesTest < ActionController::TestCase def test_override_paths_for_member_and_collection_methods collection_methods = { rss: :get, reorder: :post, csv: :post } member_methods = { rss: :get, atom: :get, upload: :post, fix: :post } - path_names = {new: "nuevo", rss: "canal", fix: "corrigir" } + path_names = { new: "nuevo", rss: "canal", fix: "corrigir" } with_restful_routing :messages, collection: collection_methods, @@ -77,7 +77,7 @@ class ResourcesTest < ActionController::TestCase end def test_multiple_resources_with_options - expected_options = {controller: "threads", action: "index"} + expected_options = { controller: "threads", action: "index" } with_restful_routing :messages, :comments, expected_options.slice(:controller) do assert_recognizes(expected_options, path: "comments") @@ -92,7 +92,7 @@ class ResourcesTest < ActionController::TestCase end def test_irregular_id_with_no_constraints_should_raise_error - expected_options = {controller: "messages", action: "show", id: "1.1.1"} + expected_options = { controller: "messages", action: "show", id: "1.1.1" } with_restful_routing :messages do assert_raise(Assertion) do @@ -102,24 +102,24 @@ class ResourcesTest < ActionController::TestCase end def test_irregular_id_with_constraints_should_pass - expected_options = {controller: "messages", action: "show", id: "1.1.1"} + expected_options = { controller: "messages", action: "show", id: "1.1.1" } - with_restful_routing(:messages, constraints: {id: /[0-9]\.[0-9]\.[0-9]/}) do + with_restful_routing(:messages, constraints: { id: /[0-9]\.[0-9]\.[0-9]/ }) do assert_recognizes(expected_options, path: "messages/1.1.1", method: :get) end end def test_with_path_prefix_constraints - expected_options = {controller: "messages", action: "show", thread_id: "1.1.1", id: "1"} - with_restful_routing :messages, path_prefix: "/thread/:thread_id", constraints: {thread_id: /[0-9]\.[0-9]\.[0-9]/} do + expected_options = { controller: "messages", action: "show", thread_id: "1.1.1", id: "1" } + with_restful_routing :messages, path_prefix: "/thread/:thread_id", constraints: { thread_id: /[0-9]\.[0-9]\.[0-9]/ } do assert_recognizes(expected_options, path: "thread/1.1.1/messages/1", method: :get) end end def test_irregular_id_constraints_should_get_passed_to_member_actions - expected_options = {controller: "messages", action: "custom", id: "1.1.1"} + expected_options = { controller: "messages", action: "custom", id: "1.1.1" } - with_restful_routing(:messages, member: {custom: :get}, constraints: {id: /[0-9]\.[0-9]\.[0-9]/}) do + with_restful_routing(:messages, member: { custom: :get }, constraints: { id: /[0-9]\.[0-9]\.[0-9]/ }) do assert_recognizes(expected_options, path: "messages/1.1.1/custom", method: :get) end end @@ -261,7 +261,7 @@ class ResourcesTest < ActionController::TestCase def test_with_member_action [:patch, :put, :post].each do |method| with_restful_routing :messages, member: { mark: method } do - mark_options = {action: "mark", id: "1"} + mark_options = { action: "mark", id: "1" } mark_path = "/messages/1/mark" assert_restful_routes_for :messages do |options| assert_recognizes(options.merge(mark_options), path: mark_path, method: method) @@ -275,24 +275,24 @@ class ResourcesTest < ActionController::TestCase end def test_with_member_action_and_requirement - expected_options = {controller: "messages", action: "mark", id: "1.1.1"} + expected_options = { controller: "messages", action: "mark", id: "1.1.1" } - with_restful_routing(:messages, constraints: {id: /[0-9]\.[0-9]\.[0-9]/}, member: { mark: :get }) do + with_restful_routing(:messages, constraints: { id: /[0-9]\.[0-9]\.[0-9]/ }, member: { mark: :get }) do assert_recognizes(expected_options, path: "messages/1.1.1/mark", method: :get) end end def test_member_when_override_paths_for_default_restful_actions_with [:patch, :put, :post].each do |method| - with_restful_routing :messages, member: { mark: method }, path_names: {new: "nuevo"} do - mark_options = {action: "mark", id: "1", controller: "messages"} + with_restful_routing :messages, member: { mark: method }, path_names: { new: "nuevo" } do + mark_options = { action: "mark", id: "1", controller: "messages" } mark_path = "/messages/1/mark" - assert_restful_routes_for :messages, path_names: {new: "nuevo"} do |options| + assert_restful_routes_for :messages, path_names: { new: "nuevo" } do |options| assert_recognizes(options.merge(mark_options), path: mark_path, method: method) end - assert_restful_named_routes_for :messages, path_names: {new: "nuevo"} do + assert_restful_named_routes_for :messages, path_names: { new: "nuevo" } do assert_named_route mark_path, :mark_message_path, mark_options end end @@ -312,7 +312,7 @@ class ResourcesTest < ActionController::TestCase end %w(mark unmark).each do |action| - action_options = {action: action, id: "1"} + action_options = { action: action, id: "1" } action_path = "/messages/1/#{action}" assert_restful_routes_for :messages do |options| assert_recognizes(options.merge(action_options), path: action_path, method: method) @@ -359,7 +359,7 @@ class ResourcesTest < ActionController::TestCase end end - preview_options = {action: "preview"} + preview_options = { action: "preview" } preview_path = "/messages/new/preview" assert_restful_routes_for :messages do |options| assert_recognizes(options.merge(preview_options), path: preview_path, method: :post) @@ -381,7 +381,7 @@ class ResourcesTest < ActionController::TestCase end end - preview_options = {action: "preview", thread_id: "1"} + preview_options = { action: "preview", thread_id: "1" } preview_path = "/threads/1/messages/new/preview" assert_restful_routes_for :messages, path_prefix: "threads/1/", name_prefix: "thread_", options: { thread_id: "1" } do |options| assert_recognizes(options.merge(preview_options), path: preview_path, method: :post) @@ -403,7 +403,7 @@ class ResourcesTest < ActionController::TestCase end end - preview_options = {action: "preview", thread_id: "1", format: "xml"} + preview_options = { action: "preview", thread_id: "1", format: "xml" } preview_path = "/threads/1/messages/new/preview.xml" assert_restful_routes_for :messages, path_prefix: "threads/1/", name_prefix: "thread_", options: { thread_id: "1" } do |options| assert_recognizes(options.merge(preview_options), path: preview_path, method: :post) @@ -561,7 +561,7 @@ class ResourcesTest < ActionController::TestCase end end - reset_options = {action: "reset"} + reset_options = { action: "reset" } reset_path = "/account/reset" assert_singleton_routes_for :account do |options| assert_recognizes(options.merge(reset_options), path: reset_path, method: method) @@ -585,7 +585,7 @@ class ResourcesTest < ActionController::TestCase end %w(reset disable).each do |action| - action_options = {action: action} + action_options = { action: action } action_path = "/account/#{action}" assert_singleton_routes_for :account do |options| assert_recognizes(options.merge(action_options), path: action_path, method: method) @@ -743,7 +743,7 @@ class ResourcesTest < ActionController::TestCase end end - assert_simply_restful_for :images, controller: "backoffice/images", name_prefix: "backoffice_product_", path_prefix: "backoffice/products/1/", options: {product_id: "1"} + assert_simply_restful_for :images, controller: "backoffice/images", name_prefix: "backoffice_product_", path_prefix: "backoffice/products/1/", options: { product_id: "1" } end end @@ -759,15 +759,15 @@ class ResourcesTest < ActionController::TestCase end end - assert_simply_restful_for :images, controller: "backoffice/admin/images", name_prefix: "backoffice_admin_product_", path_prefix: "backoffice/admin/products/1/", options: {product_id: "1"} + assert_simply_restful_for :images, controller: "backoffice/admin/images", name_prefix: "backoffice_admin_product_", path_prefix: "backoffice/admin/products/1/", options: { product_id: "1" } end end def test_with_path_segment with_restful_routing :messages do assert_simply_restful_for :messages - assert_recognizes({controller: "messages", action: "index"}, "/messages") - assert_recognizes({controller: "messages", action: "index"}, "/messages/") + assert_recognizes({ controller: "messages", action: "index" }, "/messages") + assert_recognizes({ controller: "messages", action: "index" }, "/messages/") end with_routing do |set| @@ -775,8 +775,8 @@ class ResourcesTest < ActionController::TestCase resources :messages, path: "reviews" end assert_simply_restful_for :messages, as: "reviews" - assert_recognizes({controller: "messages", action: "index"}, "/reviews") - assert_recognizes({controller: "messages", action: "index"}, "/reviews/") + assert_recognizes({ controller: "messages", action: "index" }, "/reviews") + assert_recognizes({ controller: "messages", action: "index" }, "/reviews/") end end @@ -791,13 +791,13 @@ class ResourcesTest < ActionController::TestCase end end - assert_simply_restful_for :product_reviews, controller: "messages", as: "reviews", name_prefix: "product_", path_prefix: "products/1/", options: {product_id: "1"} - assert_simply_restful_for :tutor_reviews,controller: "comments", as: "reviews", name_prefix: "tutor_", path_prefix: "tutors/1/", options: {tutor_id: "1"} + assert_simply_restful_for :product_reviews, controller: "messages", as: "reviews", name_prefix: "product_", path_prefix: "products/1/", options: { product_id: "1" } + assert_simply_restful_for :tutor_reviews,controller: "comments", as: "reviews", name_prefix: "tutor_", path_prefix: "tutors/1/", options: { tutor_id: "1" } end end def test_with_path_segment_path_prefix_constraints - expected_options = {controller: "messages", action: "show", thread_id: "1.1.1", id: "1"} + expected_options = { controller: "messages", action: "show", thread_id: "1.1.1", id: "1" } with_routing do |set| set.draw do scope "/thread/:thread_id", constraints: { thread_id: /[0-9]\.[0-9]\.[0-9]/ } do @@ -1125,7 +1125,7 @@ class ResourcesTest < ActionController::TestCase def with_singleton_resources(*args) with_routing do |set| - set.draw {resource(*args) } + set.draw { resource(*args) } yield end end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 9f0e3bff15..d1cc0f7d68 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -91,7 +91,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase end hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/faithfully-omg")) - assert_equal({"artist"=>"journey", "song"=>"faithfully"}, hash) + assert_equal({ "artist"=>"journey", "song"=>"faithfully" }, hash) end def test_id_with_dash @@ -103,7 +103,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase end hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/faithfully-omg")) - assert_equal({"id"=>"faithfully-omg"}, hash) + assert_equal({ "id"=>"faithfully-omg" }, hash) end def test_dash_with_custom_regexp @@ -115,7 +115,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase end hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/123-omg")) - assert_equal({"artist"=>"journey", "song"=>"123"}, hash) + assert_equal({ "artist"=>"journey", "song"=>"123" }, hash) assert_equal "Not Found", get(URI("http://example.org/journey/faithfully-omg")) end @@ -128,7 +128,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase end hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/omg-faithfully")) - assert_equal({"artist"=>"journey", "song"=>"faithfully"}, hash) + assert_equal({ "artist"=>"journey", "song"=>"faithfully" }, hash) end def test_pre_dash_with_custom_regexp @@ -140,7 +140,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase end hash = ActiveSupport::JSON.decode get(URI("http://example.org/journey/omg-123")) - assert_equal({"artist"=>"journey", "song"=>"123"}, hash) + assert_equal({ "artist"=>"journey", "song"=>"123" }, hash) assert_equal "Not Found", get(URI("http://example.org/journey/omg-faithfully")) end @@ -286,7 +286,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase } end assert_equal "foo", get(URI("http://example.org/posts/1/foo.js")) - assert_equal({id: "1", filters: "foo", format: "js"}, params) + assert_equal({ id: "1", filters: "foo", format: "js" }, params) end def test_specific_controller_action_failure @@ -301,11 +301,11 @@ class LegacyRouteSetTests < ActiveSupport::TestCase def test_default_setup rs.draw { ActiveSupport::Deprecation.silence { get "/:controller(/:action(/:id))" } } - assert_equal({controller: "content", action: "index"}, rs.recognize_path("/content")) - assert_equal({controller: "content", action: "list"}, rs.recognize_path("/content/list")) - assert_equal({controller: "content", action: "show", id: "10"}, rs.recognize_path("/content/show/10")) + assert_equal({ controller: "content", action: "index" }, rs.recognize_path("/content")) + assert_equal({ controller: "content", action: "list" }, rs.recognize_path("/content/list")) + assert_equal({ controller: "content", action: "show", id: "10" }, rs.recognize_path("/content/show/10")) - assert_equal({controller: "admin/user", action: "show", id: "10"}, rs.recognize_path("/admin/user/show/10")) + assert_equal({ controller: "admin/user", action: "show", id: "10" }, rs.recognize_path("/admin/user/show/10")) assert_equal "/admin/user/show/10", url_for(rs, controller: "admin/user", action: "show", id: 10) @@ -330,7 +330,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase get ":url", controller: "content", action: "translate" end - assert_equal({controller: "content", action: "translate", url: "example"}, rs.recognize_path("/example")) + assert_equal({ controller: "content", action: "translate", url: "example" }, rs.recognize_path("/example")) end def test_route_with_regexp_for_action @@ -351,9 +351,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase end end - assert_equal({controller: "admin/user", admintoken: "foo", action: "index"}, + assert_equal({ controller: "admin/user", admintoken: "foo", action: "index" }, rs.recognize_path("/admin/user/foo")) - assert_equal({controller: "content", action: "foo"}, + assert_equal({ controller: "content", action: "foo" }, rs.recognize_path("/content/foo")) assert_equal "/admin/user/foo", url_for(rs, controller: "admin/user", admintoken: "foo", action: "index") @@ -366,8 +366,8 @@ class LegacyRouteSetTests < ActiveSupport::TestCase get "/:controller(/:action(/:id))", controller: /admin\/(accounts|users)/ end end - assert_equal({controller: "admin/accounts", action: "index"}, rs.recognize_path("/admin/accounts")) - assert_equal({controller: "admin/users", action: "index"}, rs.recognize_path("/admin/users")) + assert_equal({ controller: "admin/accounts", action: "index" }, rs.recognize_path("/admin/accounts")) + assert_equal({ controller: "admin/users", action: "index" }, rs.recognize_path("/admin/users")) assert_raise(ActionController::RoutingError) { rs.recognize_path("/admin/products") } end @@ -377,22 +377,22 @@ class LegacyRouteSetTests < ActiveSupport::TestCase get ":controller/:action/:file", controller: /admin|user/, action: /upload|download/, - defaults: {file: nil}, - constraints: {file: %r{[^/]+(\.[^/]+)?}} + defaults: { file: nil }, + constraints: { file: %r{[^/]+(\.[^/]+)?} } end end # Without a file extension assert_equal "/user/download/file", url_for(rs, controller: "user", action: "download", file: "file") - assert_equal({controller: "user", action: "download", file: "file"}, + assert_equal({ controller: "user", action: "download", file: "file" }, rs.recognize_path("/user/download/file")) # Now, let's try a file with an extension, really a dot (.) assert_equal "/user/download/file.jpg", url_for(rs, controller: "user", action: "download", file: "file.jpg") - assert_equal({controller: "user", action: "download", file: "file.jpg"}, + assert_equal({ controller: "user", action: "download", file: "file.jpg" }, rs.recognize_path("/user/download/file.jpg")) end @@ -603,7 +603,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase end get URI("http://test.host/pages/boo") - assert_equal({controller: "content", action: "show_file", path: "pages/boo"}, + assert_equal({ controller: "content", action: "show_file", path: "pages/boo" }, controller.request.path_parameters) assert_equal "/pages/boo", @@ -638,9 +638,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase assert_equal "/page", url_for(rs, controller: "content", action: "show_page", id: "1") assert_equal "/page/10", url_for(rs, controller: "content", action: "show_page", id: 10) - assert_equal({controller: "content", action: "show_page", id: 1 }, rs.recognize_path("/page")) - assert_equal({controller: "content", action: "show_page", id: "1"}, rs.recognize_path("/page/1")) - assert_equal({controller: "content", action: "show_page", id: "10"}, rs.recognize_path("/page/10")) + assert_equal({ controller: "content", action: "show_page", id: 1 }, rs.recognize_path("/page")) + assert_equal({ controller: "content", action: "show_page", id: "1" }, rs.recognize_path("/page/1")) + assert_equal({ controller: "content", action: "show_page", id: "10" }, rs.recognize_path("/page/10")) end # For newer revision @@ -672,7 +672,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase def test_requirement_should_prevent_optional_id rs.draw do - get "post/:id" => "post#show", :constraints => {id: /\d+/}, :as => "post" + get "post/:id" => "post#show", :constraints => { id: /\d+/ }, :as => "post" end assert_equal "/post/10", url_for(rs, controller: "post", action: "show", id: 10) @@ -1111,8 +1111,8 @@ class RouteSetTest < ActiveSupport::TestCase assert_equal "/users/show/10", url_for(set, controller: "users", action: "show", id: 10) assert_equal "/users/index/10", url_for(set, controller: "users", id: 10) - assert_equal({controller: "users", action: "index", id: "10"}, set.recognize_path("/users/index/10")) - assert_equal({controller: "users", action: "index", id: "10"}, set.recognize_path("/users/index/10/")) + assert_equal({ controller: "users", action: "index", id: "10" }, set.recognize_path("/users/index/10")) + assert_equal({ controller: "users", action: "index", id: "10" }, set.recognize_path("/users/index/10/")) end def test_route_with_parameter_shell @@ -1124,12 +1124,12 @@ class RouteSetTest < ActiveSupport::TestCase end end - assert_equal({controller: "pages", action: "index"}, request_path_params("/pages")) - assert_equal({controller: "pages", action: "index"}, request_path_params("/pages/index")) - assert_equal({controller: "pages", action: "list"}, request_path_params("/pages/list")) + assert_equal({ controller: "pages", action: "index" }, request_path_params("/pages")) + assert_equal({ controller: "pages", action: "index" }, request_path_params("/pages/index")) + assert_equal({ controller: "pages", action: "list" }, request_path_params("/pages/list")) - assert_equal({controller: "pages", action: "show", id: "10"}, request_path_params("/pages/show/10")) - assert_equal({controller: "pages", action: "show", id: "10"}, request_path_params("/page/10")) + assert_equal({ controller: "pages", action: "show", id: "10" }, request_path_params("/pages/show/10")) + assert_equal({ controller: "pages", action: "show", id: "10" }, request_path_params("/page/10")) end def test_route_constraints_on_request_object_with_anchors_are_valid @@ -1189,8 +1189,8 @@ class RouteSetTest < ActiveSupport::TestCase get "page/:id" => "pages#show", :id => /[a-zA-Z0-9\+]+/ end - assert_equal({controller: "pages", action: "show", id: "10"}, request_path_params("/page/10")) - assert_equal({controller: "pages", action: "show", id: "hello+world"}, request_path_params("/page/hello+world")) + assert_equal({ controller: "pages", action: "show", id: "10" }, request_path_params("/page/10")) + assert_equal({ controller: "pages", action: "show", id: "hello+world" }, request_path_params("/page/hello+world")) end def test_recognize_with_http_methods @@ -1500,7 +1500,7 @@ class RouteSetTest < ActiveSupport::TestCase end get URI("http://test.host/posts.xml") - assert_equal({controller: "posts", action: "index", format: "xml"}, + assert_equal({ controller: "posts", action: "index", format: "xml" }, controller.request.path_parameters) assert_equal "/posts", controller.url_for( @@ -1591,12 +1591,12 @@ class RouteSetTest < ActiveSupport::TestCase def test_route_with_subdomain_and_constraints_must_receive_params name_param = nil set.draw do - get "page/:name" => "pages#show", :constraints => lambda {|request| + get "page/:name" => "pages#show", :constraints => lambda { |request| name_param = request.params[:name] return true } end - assert_equal({controller: "pages", action: "show", name: "mypage"}, + assert_equal({ controller: "pages", action: "show", name: "mypage" }, set.recognize_path("http://subdomain.example.org/page/mypage")) assert_equal(name_param, "mypage") end @@ -1604,19 +1604,19 @@ class RouteSetTest < ActiveSupport::TestCase def test_route_requirement_recognize_with_ignore_case set.draw do get "page/:name" => "pages#show", - :constraints => {name: /(david|jamis)/i} + :constraints => { name: /(david|jamis)/i } end - assert_equal({controller: "pages", action: "show", name: "jamis"}, set.recognize_path("/page/jamis")) + assert_equal({ controller: "pages", action: "show", name: "jamis" }, set.recognize_path("/page/jamis")) assert_raise ActionController::RoutingError do set.recognize_path("/page/davidjamis") end - assert_equal({controller: "pages", action: "show", name: "DAVID"}, set.recognize_path("/page/DAVID")) + assert_equal({ controller: "pages", action: "show", name: "DAVID" }, set.recognize_path("/page/DAVID")) end def test_route_requirement_generate_with_ignore_case set.draw do get "page/:name" => "pages#show", - :constraints => {name: /(david|jamis)/i} + :constraints => { name: /(david|jamis)/i } end url = url_for(set, controller: "pages", action: "show", name: "david") @@ -1631,15 +1631,15 @@ class RouteSetTest < ActiveSupport::TestCase def test_route_requirement_recognize_with_extended_syntax set.draw do get "page/:name" => "pages#show", - :constraints => {name: / # Desperately overcommented regexp + :constraints => { name: / # Desperately overcommented regexp ( #Either david #The Creator | #Or jamis #The Deployer - )/x} + )/x } end - assert_equal({controller: "pages", action: "show", name: "jamis"}, set.recognize_path("/page/jamis")) - assert_equal({controller: "pages", action: "show", name: "david"}, set.recognize_path("/page/david")) + assert_equal({ controller: "pages", action: "show", name: "jamis" }, set.recognize_path("/page/jamis")) + assert_equal({ controller: "pages", action: "show", name: "david" }, set.recognize_path("/page/david")) assert_raise ActionController::RoutingError do set.recognize_path("/page/david #The Creator") end @@ -1651,15 +1651,15 @@ class RouteSetTest < ActiveSupport::TestCase def test_route_requirement_with_xi_modifiers set.draw do get "page/:name" => "pages#show", - :constraints => {name: / # Desperately overcommented regexp + :constraints => { name: / # Desperately overcommented regexp ( #Either david #The Creator | #Or jamis #The Deployer - )/xi} + )/xi } end - assert_equal({controller: "pages", action: "show", name: "JAMIS"}, + assert_equal({ controller: "pages", action: "show", name: "JAMIS" }, set.recognize_path("/page/JAMIS")) assert_equal "/page/JAMIS", @@ -1671,8 +1671,8 @@ class RouteSetTest < ActiveSupport::TestCase get "unnamed", controller: :pages, action: :show, name: :as_symbol get "named" , controller: :pages, action: :show, name: :as_symbol, as: :named end - assert_equal({controller: "pages", action: "show", name: :as_symbol}, set.recognize_path("/unnamed")) - assert_equal({controller: "pages", action: "show", name: :as_symbol}, set.recognize_path("/named")) + assert_equal({ controller: "pages", action: "show", name: :as_symbol }, set.recognize_path("/unnamed")) + assert_equal({ controller: "pages", action: "show", name: :as_symbol }, set.recognize_path("/named")) end def test_regexp_chunk_should_add_question_mark_for_optionals @@ -1684,8 +1684,8 @@ class RouteSetTest < ActiveSupport::TestCase assert_equal "/", url_for(set, controller: "foo") assert_equal "/hello", url_for(set, controller: "bar") - assert_equal({controller: "foo", action: "index"}, set.recognize_path("/")) - assert_equal({controller: "bar", action: "index"}, set.recognize_path("/hello")) + assert_equal({ controller: "foo", action: "index" }, set.recognize_path("/")) + assert_equal({ controller: "bar", action: "index" }, set.recognize_path("/hello")) end def test_assign_route_options_with_anchor_chars @@ -1697,7 +1697,7 @@ class RouteSetTest < ActiveSupport::TestCase assert_equal "/cars/buy/1/2", url_for(set, controller: "cars", action: "buy", person: "1", car: "2") - assert_equal({controller: "cars", action: "buy", person: "1", car: "2"}, set.recognize_path("/cars/buy/1/2")) + assert_equal({ controller: "cars", action: "buy", person: "1", car: "2" }, set.recognize_path("/cars/buy/1/2")) end def test_segmentation_of_dot_path @@ -1709,7 +1709,7 @@ class RouteSetTest < ActiveSupport::TestCase assert_equal "/books/list.rss", url_for(set, controller: "books", action: "list") - assert_equal({controller: "books", action: "list"}, set.recognize_path("/books/list.rss")) + assert_equal({ controller: "books", action: "list" }, set.recognize_path("/books/list.rss")) end def test_segmentation_of_dynamic_dot_path @@ -1724,10 +1724,10 @@ class RouteSetTest < ActiveSupport::TestCase assert_equal "/books/list", url_for(set, controller: "books", action: "list") assert_equal "/books", url_for(set, controller: "books", action: "index") - assert_equal({controller: "books", action: "list", format: "rss"}, set.recognize_path("/books/list.rss")) - assert_equal({controller: "books", action: "list", format: "xml"}, set.recognize_path("/books/list.xml")) - assert_equal({controller: "books", action: "list"}, set.recognize_path("/books/list")) - assert_equal({controller: "books", action: "index"}, set.recognize_path("/books")) + assert_equal({ controller: "books", action: "list", format: "rss" }, set.recognize_path("/books/list.rss")) + assert_equal({ controller: "books", action: "list", format: "xml" }, set.recognize_path("/books/list.xml")) + assert_equal({ controller: "books", action: "list" }, set.recognize_path("/books/list")) + assert_equal({ controller: "books", action: "index" }, set.recognize_path("/books")) end def test_slashes_are_implied @@ -1737,14 +1737,14 @@ class RouteSetTest < ActiveSupport::TestCase assert_equal "/content/list", url_for(set, controller: "content", action: "list") assert_equal "/content/show/1", url_for(set, controller: "content", action: "show", id: "1") - assert_equal({controller: "content", action: "index"}, set.recognize_path("/content")) - assert_equal({controller: "content", action: "index"}, set.recognize_path("/content/index")) - assert_equal({controller: "content", action: "list"}, set.recognize_path("/content/list")) - assert_equal({controller: "content", action: "show", id: "1"}, set.recognize_path("/content/show/1")) + assert_equal({ controller: "content", action: "index" }, set.recognize_path("/content")) + assert_equal({ controller: "content", action: "index" }, set.recognize_path("/content/index")) + assert_equal({ controller: "content", action: "list" }, set.recognize_path("/content/list")) + assert_equal({ controller: "content", action: "show", id: "1" }, set.recognize_path("/content/show/1")) end def test_default_route_recognition - expected = {controller: "pages", action: "show", id: "10"} + expected = { controller: "pages", action: "show", id: "10" } assert_equal expected, default_route_set.recognize_path("/pages/show/10") assert_equal expected, default_route_set.recognize_path("/pages/show/10/") @@ -1860,19 +1860,19 @@ class RouteSetTest < ActiveSupport::TestCase controller.request.path_parameters } - assert_equal({controller: "blog", action: "index"}, recognize_path.("/blog")) - assert_equal({controller: "blog", action: "show", id: "123"}, recognize_path.("/blog/show/123")) - assert_equal({controller: "blog", action: "show_date", year: "2004", day: nil, month: nil }, recognize_path.("/blog/2004")) - assert_equal({controller: "blog", action: "show_date", year: "2004", month: "12", day: nil }, recognize_path.("/blog/2004/12")) - assert_equal({controller: "blog", action: "show_date", year: "2004", month: "12", day: "25"}, recognize_path.("/blog/2004/12/25")) - assert_equal({controller: "articles", action: "edit", id: "123"}, recognize_path.("/blog/articles/edit/123")) - assert_equal({controller: "articles", action: "show_stats"}, recognize_path.("/blog/articles/show_stats")) - assert_equal({controller: "blog", action: "unknown_request", anything: "blog/wibble"}, recognize_path.("/blog/wibble")) - assert_equal({controller: "blog", action: "unknown_request", anything: "junk"}, recognize_path.("/junk")) + assert_equal({ controller: "blog", action: "index" }, recognize_path.("/blog")) + assert_equal({ controller: "blog", action: "show", id: "123" }, recognize_path.("/blog/show/123")) + assert_equal({ controller: "blog", action: "show_date", year: "2004", day: nil, month: nil }, recognize_path.("/blog/2004")) + assert_equal({ controller: "blog", action: "show_date", year: "2004", month: "12", day: nil }, recognize_path.("/blog/2004/12")) + assert_equal({ controller: "blog", action: "show_date", year: "2004", month: "12", day: "25" }, recognize_path.("/blog/2004/12/25")) + assert_equal({ controller: "articles", action: "edit", id: "123" }, recognize_path.("/blog/articles/edit/123")) + assert_equal({ controller: "articles", action: "show_stats" }, recognize_path.("/blog/articles/show_stats")) + assert_equal({ controller: "blog", action: "unknown_request", anything: "blog/wibble" }, recognize_path.("/blog/wibble")) + assert_equal({ controller: "blog", action: "unknown_request", anything: "junk" }, recognize_path.("/junk")) get URI("http://example.org/blog/2006/07/28") - assert_equal({controller: "blog", action: "show_date", year: "2006", month: "07", day: "28"}, controller.request.path_parameters) + assert_equal({ controller: "blog", action: "show_date", year: "2006", month: "07", day: "28" }, controller.request.path_parameters) assert_equal("/blog/2006/07/25", controller.url_for(day: 25, only_path: true)) assert_equal("/blog/2005", controller.url_for(year: 2005, only_path: true)) assert_equal("/blog/show/123", controller.url_for(action: "show" , id: 123, only_path: true)) @@ -1966,76 +1966,76 @@ class RackMountIntegrationTests < ActiveSupport::TestCase end def test_recognize_path - assert_equal({controller: "admin/users", action: "index"}, @routes.recognize_path("/admin/users", method: :get)) - assert_equal({controller: "admin/users", action: "create"}, @routes.recognize_path("/admin/users", method: :post)) - assert_equal({controller: "admin/users", action: "new"}, @routes.recognize_path("/admin/users/new", method: :get)) - assert_equal({controller: "admin/users", action: "show", id: "1"}, @routes.recognize_path("/admin/users/1", method: :get)) - assert_equal({controller: "admin/users", action: "update", id: "1"}, @routes.recognize_path("/admin/users/1", method: :put)) - assert_equal({controller: "admin/users", action: "destroy", id: "1"}, @routes.recognize_path("/admin/users/1", method: :delete)) - assert_equal({controller: "admin/users", action: "edit", id: "1"}, @routes.recognize_path("/admin/users/1/edit", method: :get)) - - assert_equal({controller: "admin/posts", action: "index"}, @routes.recognize_path("/admin/posts", method: :get)) - assert_equal({controller: "admin/posts", action: "new"}, @routes.recognize_path("/admin/posts/new", method: :get)) - - assert_equal({controller: "api/users", action: "index"}, @routes.recognize_path("/api", method: :get)) - assert_equal({controller: "api/users", action: "index"}, @routes.recognize_path("/api/", method: :get)) - - assert_equal({controller: "posts", action: "show_date", year: "2009", month: nil, day: nil }, @routes.recognize_path("/blog/2009", method: :get)) - assert_equal({controller: "posts", action: "show_date", year: "2009", month: "01", day: nil }, @routes.recognize_path("/blog/2009/01", method: :get)) - assert_equal({controller: "posts", action: "show_date", year: "2009", month: "01", day: "01"}, @routes.recognize_path("/blog/2009/01/01", method: :get)) - - assert_equal({controller: "archive", action: "index", year: "2010"}, @routes.recognize_path("/archive/2010")) - assert_equal({controller: "archive", action: "index"}, @routes.recognize_path("/archive")) - - assert_equal({controller: "people", action: "index"}, @routes.recognize_path("/people", method: :get)) - assert_equal({controller: "people", action: "index", format: "xml"}, @routes.recognize_path("/people.xml", method: :get)) - assert_equal({controller: "people", action: "create"}, @routes.recognize_path("/people", method: :post)) - assert_equal({controller: "people", action: "new"}, @routes.recognize_path("/people/new", method: :get)) - assert_equal({controller: "people", action: "show", id: "1"}, @routes.recognize_path("/people/1", method: :get)) - assert_equal({controller: "people", action: "show", id: "1", format: "xml"}, @routes.recognize_path("/people/1.xml", method: :get)) - assert_equal({controller: "people", action: "update", id: "1"}, @routes.recognize_path("/people/1", method: :put)) - assert_equal({controller: "people", action: "destroy", id: "1"}, @routes.recognize_path("/people/1", method: :delete)) - assert_equal({controller: "people", action: "edit", id: "1"}, @routes.recognize_path("/people/1/edit", method: :get)) - assert_equal({controller: "people", action: "edit", id: "1", format: "xml"}, @routes.recognize_path("/people/1/edit.xml", method: :get)) - - assert_equal({controller: "symbols", action: "show", name: :as_symbol}, @routes.recognize_path("/symbols")) - assert_equal({controller: "foo", action: "id_default", id: "1"}, @routes.recognize_path("/id_default/1")) - assert_equal({controller: "foo", action: "id_default", id: "2"}, @routes.recognize_path("/id_default/2")) - assert_equal({controller: "foo", action: "id_default", id: 1 }, @routes.recognize_path("/id_default")) - assert_equal({controller: "foo", action: "get_or_post"}, @routes.recognize_path("/get_or_post", method: :get)) - assert_equal({controller: "foo", action: "get_or_post"}, @routes.recognize_path("/get_or_post", method: :post)) + assert_equal({ controller: "admin/users", action: "index" }, @routes.recognize_path("/admin/users", method: :get)) + assert_equal({ controller: "admin/users", action: "create" }, @routes.recognize_path("/admin/users", method: :post)) + assert_equal({ controller: "admin/users", action: "new" }, @routes.recognize_path("/admin/users/new", method: :get)) + assert_equal({ controller: "admin/users", action: "show", id: "1" }, @routes.recognize_path("/admin/users/1", method: :get)) + assert_equal({ controller: "admin/users", action: "update", id: "1" }, @routes.recognize_path("/admin/users/1", method: :put)) + assert_equal({ controller: "admin/users", action: "destroy", id: "1" }, @routes.recognize_path("/admin/users/1", method: :delete)) + assert_equal({ controller: "admin/users", action: "edit", id: "1" }, @routes.recognize_path("/admin/users/1/edit", method: :get)) + + assert_equal({ controller: "admin/posts", action: "index" }, @routes.recognize_path("/admin/posts", method: :get)) + assert_equal({ controller: "admin/posts", action: "new" }, @routes.recognize_path("/admin/posts/new", method: :get)) + + assert_equal({ controller: "api/users", action: "index" }, @routes.recognize_path("/api", method: :get)) + assert_equal({ controller: "api/users", action: "index" }, @routes.recognize_path("/api/", method: :get)) + + assert_equal({ controller: "posts", action: "show_date", year: "2009", month: nil, day: nil }, @routes.recognize_path("/blog/2009", method: :get)) + assert_equal({ controller: "posts", action: "show_date", year: "2009", month: "01", day: nil }, @routes.recognize_path("/blog/2009/01", method: :get)) + assert_equal({ controller: "posts", action: "show_date", year: "2009", month: "01", day: "01" }, @routes.recognize_path("/blog/2009/01/01", method: :get)) + + assert_equal({ controller: "archive", action: "index", year: "2010" }, @routes.recognize_path("/archive/2010")) + assert_equal({ controller: "archive", action: "index" }, @routes.recognize_path("/archive")) + + assert_equal({ controller: "people", action: "index" }, @routes.recognize_path("/people", method: :get)) + assert_equal({ controller: "people", action: "index", format: "xml" }, @routes.recognize_path("/people.xml", method: :get)) + assert_equal({ controller: "people", action: "create" }, @routes.recognize_path("/people", method: :post)) + assert_equal({ controller: "people", action: "new" }, @routes.recognize_path("/people/new", method: :get)) + assert_equal({ controller: "people", action: "show", id: "1" }, @routes.recognize_path("/people/1", method: :get)) + assert_equal({ controller: "people", action: "show", id: "1", format: "xml" }, @routes.recognize_path("/people/1.xml", method: :get)) + assert_equal({ controller: "people", action: "update", id: "1" }, @routes.recognize_path("/people/1", method: :put)) + assert_equal({ controller: "people", action: "destroy", id: "1" }, @routes.recognize_path("/people/1", method: :delete)) + assert_equal({ controller: "people", action: "edit", id: "1" }, @routes.recognize_path("/people/1/edit", method: :get)) + assert_equal({ controller: "people", action: "edit", id: "1", format: "xml" }, @routes.recognize_path("/people/1/edit.xml", method: :get)) + + assert_equal({ controller: "symbols", action: "show", name: :as_symbol }, @routes.recognize_path("/symbols")) + assert_equal({ controller: "foo", action: "id_default", id: "1" }, @routes.recognize_path("/id_default/1")) + assert_equal({ controller: "foo", action: "id_default", id: "2" }, @routes.recognize_path("/id_default/2")) + assert_equal({ controller: "foo", action: "id_default", id: 1 }, @routes.recognize_path("/id_default")) + assert_equal({ controller: "foo", action: "get_or_post" }, @routes.recognize_path("/get_or_post", method: :get)) + assert_equal({ controller: "foo", action: "get_or_post" }, @routes.recognize_path("/get_or_post", method: :post)) assert_raise(ActionController::RoutingError) { @routes.recognize_path("/get_or_post", method: :put) } assert_raise(ActionController::RoutingError) { @routes.recognize_path("/get_or_post", method: :delete) } - assert_equal({controller: "posts", action: "index", optional: "bar"}, @routes.recognize_path("/optional/bar")) + assert_equal({ controller: "posts", action: "index", optional: "bar" }, @routes.recognize_path("/optional/bar")) assert_raise(ActionController::RoutingError) { @routes.recognize_path("/optional") } - assert_equal({controller: "posts", action: "show", id: "1", ws: true}, @routes.recognize_path("/ws/posts/show/1", method: :get)) - assert_equal({controller: "posts", action: "list", ws: true}, @routes.recognize_path("/ws/posts/list", method: :get)) - assert_equal({controller: "posts", action: "index", ws: true}, @routes.recognize_path("/ws/posts", method: :get)) + assert_equal({ controller: "posts", action: "show", id: "1", ws: true }, @routes.recognize_path("/ws/posts/show/1", method: :get)) + assert_equal({ controller: "posts", action: "list", ws: true }, @routes.recognize_path("/ws/posts/list", method: :get)) + assert_equal({ controller: "posts", action: "index", ws: true }, @routes.recognize_path("/ws/posts", method: :get)) - assert_equal({controller: "account", action: "subscription"}, @routes.recognize_path("/account", method: :get)) - assert_equal({controller: "account", action: "subscription"}, @routes.recognize_path("/account/subscription", method: :get)) - assert_equal({controller: "account", action: "billing"}, @routes.recognize_path("/account/billing", method: :get)) + assert_equal({ controller: "account", action: "subscription" }, @routes.recognize_path("/account", method: :get)) + assert_equal({ controller: "account", action: "subscription" }, @routes.recognize_path("/account/subscription", method: :get)) + assert_equal({ controller: "account", action: "billing" }, @routes.recognize_path("/account/billing", method: :get)) - assert_equal({page_id: "1", controller: "notes", action: "index"}, @routes.recognize_path("/pages/1/notes", method: :get)) - assert_equal({page_id: "1", controller: "notes", action: "list"}, @routes.recognize_path("/pages/1/notes/list", method: :get)) - assert_equal({page_id: "1", controller: "notes", action: "show", id: "2"}, @routes.recognize_path("/pages/1/notes/show/2", method: :get)) + assert_equal({ page_id: "1", controller: "notes", action: "index" }, @routes.recognize_path("/pages/1/notes", method: :get)) + assert_equal({ page_id: "1", controller: "notes", action: "list" }, @routes.recognize_path("/pages/1/notes/list", method: :get)) + assert_equal({ page_id: "1", controller: "notes", action: "show", id: "2" }, @routes.recognize_path("/pages/1/notes/show/2", method: :get)) - assert_equal({controller: "posts", action: "ping"}, @routes.recognize_path("/posts/ping", method: :get)) - assert_equal({controller: "posts", action: "index"}, @routes.recognize_path("/posts", method: :get)) - assert_equal({controller: "posts", action: "index"}, @routes.recognize_path("/posts/index", method: :get)) - assert_equal({controller: "posts", action: "show"}, @routes.recognize_path("/posts/show", method: :get)) - assert_equal({controller: "posts", action: "show", id: "1"}, @routes.recognize_path("/posts/show/1", method: :get)) - assert_equal({controller: "posts", action: "create"}, @routes.recognize_path("/posts/create", method: :post)) + assert_equal({ controller: "posts", action: "ping" }, @routes.recognize_path("/posts/ping", method: :get)) + assert_equal({ controller: "posts", action: "index" }, @routes.recognize_path("/posts", method: :get)) + assert_equal({ controller: "posts", action: "index" }, @routes.recognize_path("/posts/index", method: :get)) + assert_equal({ controller: "posts", action: "show" }, @routes.recognize_path("/posts/show", method: :get)) + assert_equal({ controller: "posts", action: "show", id: "1" }, @routes.recognize_path("/posts/show/1", method: :get)) + assert_equal({ controller: "posts", action: "create" }, @routes.recognize_path("/posts/create", method: :post)) - assert_equal({controller: "geocode", action: "show", postalcode: "hx12-1az"}, @routes.recognize_path("/ignorecase/geocode/hx12-1az")) - assert_equal({controller: "geocode", action: "show", postalcode: "hx12-1AZ"}, @routes.recognize_path("/ignorecase/geocode/hx12-1AZ")) - assert_equal({controller: "geocode", action: "show", postalcode: "12345-1234"}, @routes.recognize_path("/extended/geocode/12345-1234")) - assert_equal({controller: "geocode", action: "show", postalcode: "12345"}, @routes.recognize_path("/extended/geocode/12345")) + assert_equal({ controller: "geocode", action: "show", postalcode: "hx12-1az" }, @routes.recognize_path("/ignorecase/geocode/hx12-1az")) + assert_equal({ controller: "geocode", action: "show", postalcode: "hx12-1AZ" }, @routes.recognize_path("/ignorecase/geocode/hx12-1AZ")) + assert_equal({ controller: "geocode", action: "show", postalcode: "12345-1234" }, @routes.recognize_path("/extended/geocode/12345-1234")) + assert_equal({ controller: "geocode", action: "show", postalcode: "12345" }, @routes.recognize_path("/extended/geocode/12345")) - assert_equal({controller: "news", action: "index" }, @routes.recognize_path("/", method: :get)) - assert_equal({controller: "news", action: "index", format: "rss"}, @routes.recognize_path("/news.rss", method: :get)) + assert_equal({ controller: "news", action: "index" }, @routes.recognize_path("/", method: :get)) + assert_equal({ controller: "news", action: "index", format: "rss" }, @routes.recognize_path("/news.rss", method: :get)) assert_raise(ActionController::RoutingError) { @routes.recognize_path("/none", method: :get) } end @@ -2059,25 +2059,25 @@ class RackMountIntegrationTests < ActiveSupport::TestCase end def test_extras - params = {controller: "people"} + params = { controller: "people" } assert_equal [], @routes.extra_keys(params) - assert_equal({controller: "people", action: "index"}, params) + assert_equal({ controller: "people", action: "index" }, params) - params = {controller: "people", foo: "bar"} + params = { controller: "people", foo: "bar" } assert_equal [:foo], @routes.extra_keys(params) - assert_equal({controller: "people", action: "index", foo: "bar"}, params) + assert_equal({ controller: "people", action: "index", foo: "bar" }, params) - params = {controller: "people", action: "create", person: { name: "Josh"}} + params = { controller: "people", action: "create", person: { name: "Josh" } } assert_equal [:person], @routes.extra_keys(params) - assert_equal({controller: "people", action: "create", person: { name: "Josh"}}, params) + assert_equal({ controller: "people", action: "create", person: { name: "Josh" } }, params) end def test_unicode_path - assert_equal({controller: "news", action: "index"}, @routes.recognize_path(URI.parser.escape("こんにちは/世界"), method: :get)) + assert_equal({ controller: "news", action: "index" }, @routes.recognize_path(URI.parser.escape("こんにちは/世界"), method: :get)) end def test_downcased_unicode_path - assert_equal({controller: "news", action: "index"}, @routes.recognize_path(URI.parser.escape("こんにちは/世界").downcase, method: :get)) + assert_equal({ controller: "news", action: "index" }, @routes.recognize_path(URI.parser.escape("こんにちは/世界").downcase, method: :get)) end private diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 3fb0ee8059..25420ead3b 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -192,7 +192,7 @@ class SendFileTest < ActionController::TestCase end def test_send_file_without_content_disposition_header - @controller.options = {disposition: nil} + @controller.options = { disposition: nil } process("data") assert_nil @controller.headers["Content-Disposition"] end diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 45bc770e86..2d78fc71a9 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -239,7 +239,7 @@ XML def test_document_body_and_params_with_post post :test_params, params: { id: 1 } - assert_equal({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body)) + assert_equal({ "id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body)) end def test_document_body_with_post @@ -525,15 +525,15 @@ XML end def test_query_param_named_action - get :test_query_parameters, params: {action: "foobar"} + get :test_query_parameters, params: { action: "foobar" } parsed_params = JSON.parse(@response.body) - assert_equal({"action" => "foobar"}, parsed_params) + assert_equal({ "action" => "foobar" }, parsed_params) end def test_request_param_named_action - post :test_request_parameters, params: {action: "foobar"} + post :test_request_parameters, params: { action: "foobar" } parsed_params = eval(@response.body) - assert_equal({"action" => "foobar"}, parsed_params) + assert_equal({ "action" => "foobar" }, parsed_params) end def test_kwarg_params_passing_with_session_and_flash @@ -548,8 +548,8 @@ XML parsed_params = ::JSON.parse(@response.body) assert_equal( - {"controller" => "test_case_test/test", "action" => "test_params", - "page" => {"name" => "Page name", "month" => "4", "year" => "2004", "day" => "6"}}, + { "controller" => "test_case_test/test", "action" => "test_params", + "page" => { "name" => "Page name", "month" => "4", "year" => "2004", "day" => "6" } }, parsed_params ) @@ -563,8 +563,8 @@ XML } parsed_params = ::JSON.parse(@response.body) assert_equal( - {"controller" => "test_case_test/test", "action" => "test_params", - "page" => {"name" => "Page name", "month" => "4", "year" => "2004", "day" => "6"}}, + { "controller" => "test_case_test/test", "action" => "test_params", + "page" => { "name" => "Page name", "month" => "4", "year" => "2004", "day" => "6" } }, parsed_params ) end @@ -573,7 +573,7 @@ XML get :test_params, params: { format: "json", count: 999 } parsed_params = ::JSON.parse(@response.body) assert_equal( - {"controller" => "test_case_test/test", "action" => "test_params", + { "controller" => "test_case_test/test", "action" => "test_params", "format" => "json", "count" => "999" }, parsed_params ) @@ -583,7 +583,7 @@ XML get :test_params, params: { format: "json", id: 1 } parsed_params = ::JSON.parse(@response.body) assert_equal( - {"controller" => "test_case_test/test", "action" => "test_params", + { "controller" => "test_case_test/test", "action" => "test_params", "format" => "json", "id" => "1" }, parsed_params ) @@ -593,7 +593,7 @@ XML assert_deprecated { get :test_params, format: "json", id: 1 } parsed_params = ::JSON.parse(@response.body) assert_equal( - {"controller" => "test_case_test/test", "action" => "test_params", + { "controller" => "test_case_test/test", "action" => "test_params", "format" => "json", "id" => "1" }, parsed_params ) @@ -607,8 +607,8 @@ XML end parsed_params = ::JSON.parse(@response.body) assert_equal( - {"controller" => "test_case_test/test", "action" => "test_params", - "frozen" => "icy", "frozens" => ["icy"], "deepfreeze" => { "frozen" => "icy" }}, + { "controller" => "test_case_test/test", "action" => "test_params", + "frozen" => "icy", "frozens" => ["icy"], "deepfreeze" => { "frozen" => "icy" } }, parsed_params ) end @@ -670,7 +670,7 @@ XML end def test_deprecared_id_converted_to_string - assert_deprecated { get :test_params, id: 20, foo: Object.new} + assert_deprecated { get :test_params, id: 20, foo: Object.new } assert_kind_of String, @request.path_parameters[:id] end @@ -731,13 +731,13 @@ XML def test_deprecated_xhr_with_params assert_deprecated { xhr :get, :test_params, params: { id: 1 } } - assert_equal({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body)) + assert_equal({ "id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body)) end def test_xhr_with_params get :test_params, params: { id: 1 }, xhr: true - assert_equal({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body)) + assert_equal({ "id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body)) end def test_xhr_with_session @@ -856,10 +856,10 @@ XML def test_multiple_mixed_method_process_should_scrub_rack_input post :test_params, params: { id: 1, foo: "an foo" } - assert_equal({"id"=>"1", "foo" => "an foo", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body)) + assert_equal({ "id"=>"1", "foo" => "an foo", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body)) get :test_params, params: { bar: "an bar" } - assert_equal({"bar"=>"an bar", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body)) + assert_equal({ "bar"=>"an bar", "controller"=>"test_case_test/test", "action"=>"test_params" }, ::JSON.parse(@response.body)) end %w(controller response request).each do |variable| @@ -1208,7 +1208,7 @@ class RoutingDefaultsTest < ActionController::TestCase end def test_route_option_can_be_passed_via_process - get :post, params: { id: 1, bucket_type: "post"} + get :post, params: { id: 1, bucket_type: "post" } assert_equal "/posts/1", @response.body end diff --git a/actionpack/test/controller/url_for_integration_test.rb b/actionpack/test/controller/url_for_integration_test.rb index fc746add9b..c7ea6c5ef6 100644 --- a/actionpack/test/controller/url_for_integration_test.rb +++ b/actionpack/test/controller/url_for_integration_test.rb @@ -78,7 +78,7 @@ module ActionPack ["/admin/users",[ { controller: "admin/users", action: "index" }]], ["/admin/users",[ { action: "index" }, { controller: "admin/users", action: "index" }, "/admin/users"]], ["/admin/users",[ { controller: "users", action: "index" }, { controller: "admin/accounts", action: "show", id: "1" }, "/admin/accounts/show/1"]], - ["/people",[ { controller: "/people", action: "index" }, {controller: "admin/accounts", action: "foo", id: "bar"}, "/admin/accounts/foo/bar"]], + ["/people",[ { controller: "/people", action: "index" }, { controller: "admin/accounts", action: "foo", id: "bar" }, "/admin/accounts/foo/bar"]], ["/admin/posts",[ { controller: "admin/posts" }]], ["/admin/posts/new",[ { controller: "admin/posts", action: "new" }]], @@ -124,7 +124,7 @@ module ActionPack ["/project",[ { controller: "project", action: "index" }]], ["/projects/1",[ { controller: "project", action: "index", project_id: "1" }]], - ["/projects/1",[ { controller: "project", action: "index"}, {project_id: "1", controller: "project", action: "index" }, "/projects/1"]], + ["/projects/1",[ { controller: "project", action: "index" }, { project_id: "1", controller: "project", action: "index" }, "/projects/1"]], ["/projects/1",[ { use_route: "project", controller: "project", action: "index", project_id: "1" }]], ["/projects/1",[ { use_route: "project", controller: "project", action: "index" }, { controller: "project", action: "index", project_id: "1" }, "/projects/1"]], @@ -164,11 +164,11 @@ module ActionPack ["/posts/show/1",[ { controller: "posts", action: "show", id: "1", format: "" }]], ["/posts",[ { controller: "posts" }]], ["/posts",[ { controller: "posts", action: "index" }]], - ["/posts/create",[ { action: "create" }, {day: nil, month: nil, controller: "posts", action: "show_date"}, "/blog"]], + ["/posts/create",[ { action: "create" }, { day: nil, month: nil, controller: "posts", action: "show_date" }, "/blog"]], ["/posts?foo=bar",[ { controller: "posts", foo: "bar" }]], ["/posts?foo%5B%5D=bar&foo%5B%5D=baz", [{ controller: "posts", foo: ["bar", "baz"] }]], ["/posts?page=2", [{ controller: "posts", page: 2 }]], - ["/posts?q%5Bfoo%5D%5Ba%5D=b", [{ controller: "posts", q: { foo: { a: "b"}} }]], + ["/posts?q%5Bfoo%5D%5Ba%5D=b", [{ controller: "posts", q: { foo: { a: "b" } } }]], ["/news.rss", [{ controller: "news", action: "index", format: "rss" }]], ].each_with_index do |(url, params), i| diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index ad4acf3462..8d7190365d 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -222,19 +222,19 @@ module AbstractController def test_trailing_slash add_host! - options = {controller: "foo", trailing_slash: true, action: "bar", id: "33"} + options = { controller: "foo", trailing_slash: true, action: "bar", id: "33" } assert_equal("http://www.basecamphq.com/foo/bar/33/", W.new.url_for(options) ) end def test_trailing_slash_with_protocol add_host! - options = { trailing_slash: true,protocol: "https", controller: "foo", action: "bar", id: "33"} + options = { trailing_slash: true,protocol: "https", controller: "foo", action: "bar", id: "33" } assert_equal("https://www.basecamphq.com/foo/bar/33/", W.new.url_for(options) ) assert_equal "https://www.basecamphq.com/foo/bar/33/?query=string", W.new.url_for(options.merge(query: "string")) end def test_trailing_slash_with_only_path - options = {controller: "foo", trailing_slash: true} + options = { controller: "foo", trailing_slash: true } assert_equal "/foo/", W.new.url_for(options.merge(only_path: true)) options.update(action: "bar", id: "33") assert_equal "/foo/bar/33/", W.new.url_for(options.merge(only_path: true)) @@ -242,7 +242,7 @@ module AbstractController end def test_trailing_slash_with_anchor - options = {trailing_slash: true, controller: "foo", action: "bar", id: "33", only_path: true, anchor: "chapter7"} + options = { trailing_slash: true, controller: "foo", action: "bar", id: "33", only_path: true, anchor: "chapter7" } assert_equal "/foo/bar/33/#chapter7", W.new.url_for(options) assert_equal "/foo/bar/33/?query=string#chapter7", W.new.url_for(options.merge(query: "string")) end @@ -250,8 +250,8 @@ module AbstractController def test_trailing_slash_with_params url = W.new.url_for(trailing_slash: true, only_path: true, controller: "cont", action: "act", p1: "cafe", p2: "link") params = extract_params(url) - assert_equal({p1: "cafe"}.to_query, params[0]) - assert_equal({p2: "link"}.to_query, params[1]) + assert_equal({ p1: "cafe" }.to_query, params[0]) + assert_equal({ p2: "link" }.to_query, params[1]) end def test_relative_url_root_is_respected @@ -348,40 +348,40 @@ module AbstractController def test_two_parameters url = W.new.url_for(only_path: true, controller: "c", action: "a", p1: "X1", p2: "Y2") params = extract_params(url) - assert_equal({p1: "X1"}.to_query, params[0]) - assert_equal({p2: "Y2"}.to_query, params[1]) + assert_equal({ p1: "X1" }.to_query, params[0]) + assert_equal({ p2: "Y2" }.to_query, params[1]) end def test_hash_parameter - url = W.new.url_for(only_path: true, controller: "c", action: "a", query: {name: "Bob", category: "prof"}) + url = W.new.url_for(only_path: true, controller: "c", action: "a", query: { name: "Bob", category: "prof" }) params = extract_params(url) - assert_equal({"query[category]" => "prof"}.to_query, params[0]) - assert_equal({"query[name]" => "Bob"}.to_query, params[1]) + assert_equal({ "query[category]" => "prof" }.to_query, params[0]) + assert_equal({ "query[name]" => "Bob" }.to_query, params[1]) end def test_array_parameter url = W.new.url_for(only_path: true, controller: "c", action: "a", query: ["Bob", "prof"]) params = extract_params(url) - assert_equal({"query[]" => "Bob"}.to_query, params[0]) - assert_equal({"query[]" => "prof"}.to_query, params[1]) + assert_equal({ "query[]" => "Bob" }.to_query, params[0]) + assert_equal({ "query[]" => "prof" }.to_query, params[1]) end def test_hash_recursive_parameters - url = W.new.url_for(only_path: true, controller: "c", action: "a", query: {person: {name: "Bob", position: "prof"}, hobby: "piercing"}) + url = W.new.url_for(only_path: true, controller: "c", action: "a", query: { person: { name: "Bob", position: "prof" }, hobby: "piercing" }) params = extract_params(url) - assert_equal({"query[hobby]" => "piercing"}.to_query, params[0]) - assert_equal({"query[person][name]" => "Bob" }.to_query, params[1]) - assert_equal({"query[person][position]" => "prof" }.to_query, params[2]) + assert_equal({ "query[hobby]" => "piercing" }.to_query, params[0]) + assert_equal({ "query[person][name]" => "Bob" }.to_query, params[1]) + assert_equal({ "query[person][position]" => "prof" }.to_query, params[2]) end def test_hash_recursive_and_array_parameters - url = W.new.url_for(only_path: true, controller: "c", action: "a", id: 101, query: {person: {name: "Bob", position: ["prof", "art director"]}, hobby: "piercing"}) + url = W.new.url_for(only_path: true, controller: "c", action: "a", id: 101, query: { person: { name: "Bob", position: ["prof", "art director"] }, hobby: "piercing" }) assert_match(%r(^/c/a/101), url) params = extract_params(url) - assert_equal({"query[hobby]" => "piercing" }.to_query, params[0]) - assert_equal({"query[person][name]" => "Bob" }.to_query, params[1]) - assert_equal({"query[person][position][]" => "art director"}.to_query, params[2]) - assert_equal({"query[person][position][]" => "prof" }.to_query, params[3]) + assert_equal({ "query[hobby]" => "piercing" }.to_query, params[0]) + assert_equal({ "query[person][name]" => "Bob" }.to_query, params[1]) + assert_equal({ "query[person][position][]" => "art director" }.to_query, params[2]) + assert_equal({ "query[person][position][]" => "prof" }.to_query, params[3]) end def test_url_action_controller_parameters @@ -407,7 +407,7 @@ module AbstractController kls.default_url_options[:host] = "www.basecamphq.com" controller = kls.new - params = {action: :index, controller: :posts, format: :xml} + params = { action: :index, controller: :posts, format: :xml } assert_equal("http://www.basecamphq.com/posts.xml", controller.send(:url_for, params)) params[:format] = nil assert_equal("http://www.basecamphq.com/", controller.send(:url_for, params)) diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb index d64ff4d6ce..a055e6d177 100644 --- a/actionpack/test/controller/url_rewriter_test.rb +++ b/actionpack/test/controller/url_rewriter_test.rb @@ -79,7 +79,7 @@ class UrlRewriterTests < ActionController::TestCase end def test_trailing_slash - options = {controller: "foo", action: "bar", id: "3", only_path: true} + options = { controller: "foo", action: "bar", id: "3", only_path: true } assert_equal "/foo/bar/3", @rewriter.rewrite(@routes, options) assert_equal "/foo/bar/3?query=string", @rewriter.rewrite(@routes, options.merge(query: "string")) options.update(trailing_slash: true) diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb index 06a54591b8..4d3d83f45a 100644 --- a/actionpack/test/dispatch/cookies_test.rb +++ b/actionpack/test/dispatch/cookies_test.rb @@ -210,12 +210,12 @@ class CookiesTest < ActionController::TestCase end def set_cookie_with_domain - cookies[:user_name] = {value: "rizwanreza", domain: :all} + cookies[:user_name] = { value: "rizwanreza", domain: :all } head :ok end def set_cookie_with_domain_all_as_string - cookies[:user_name] = {value: "rizwanreza", domain: "all"} + cookies[:user_name] = { value: "rizwanreza", domain: "all" } head :ok end @@ -230,7 +230,7 @@ class CookiesTest < ActionController::TestCase end def set_cookie_with_domain_and_tld - cookies[:user_name] = {value: "rizwanreza", domain: :all, tld_length: 2} + cookies[:user_name] = { value: "rizwanreza", domain: :all, tld_length: 2 } head :ok end @@ -240,7 +240,7 @@ class CookiesTest < ActionController::TestCase end def set_cookie_with_domains - cookies[:user_name] = {value: "rizwanreza", domain: %w(example1.com example2.com .example3.com)} + cookies[:user_name] = { value: "rizwanreza", domain: %w(example1.com example2.com .example3.com) } head :ok end @@ -293,7 +293,7 @@ class CookiesTest < ActionController::TestCase def test_setting_cookie get :authenticate assert_cookie_header "user_name=david; path=/" - assert_equal({"user_name" => "david"}, @response.cookies) + assert_equal({ "user_name" => "david" }, @response.cookies) end def test_setting_the_same_value_to_cookie @@ -305,45 +305,45 @@ class CookiesTest < ActionController::TestCase def test_setting_the_same_value_to_permanent_cookie request.cookies[:user_name] = "Jamie" get :set_permanent_cookie - assert_equal({"user_name" => "Jamie"}, response.cookies) + assert_equal({ "user_name" => "Jamie" }, response.cookies) end def test_setting_with_escapable_characters get :set_with_with_escapable_characters assert_cookie_header "that+%26+guy=foo+%26+bar+%3D%3E+baz; path=/" - assert_equal({"that & guy" => "foo & bar => baz"}, @response.cookies) + assert_equal({ "that & guy" => "foo & bar => baz" }, @response.cookies) end def test_setting_cookie_for_fourteen_days get :authenticate_for_fourteen_days assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000" - assert_equal({"user_name" => "david"}, @response.cookies) + assert_equal({ "user_name" => "david" }, @response.cookies) end def test_setting_cookie_for_fourteen_days_with_symbols get :authenticate_for_fourteen_days_with_symbols assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000" - assert_equal({"user_name" => "david"}, @response.cookies) + assert_equal({ "user_name" => "david" }, @response.cookies) end def test_setting_cookie_with_http_only get :authenticate_with_http_only assert_cookie_header "user_name=david; path=/; HttpOnly" - assert_equal({"user_name" => "david"}, @response.cookies) + assert_equal({ "user_name" => "david" }, @response.cookies) end def test_setting_cookie_with_secure @request.env["HTTPS"] = "on" get :authenticate_with_secure assert_cookie_header "user_name=david; path=/; secure" - assert_equal({"user_name" => "david"}, @response.cookies) + assert_equal({ "user_name" => "david" }, @response.cookies) end def test_setting_cookie_with_secure_when_always_write_cookie_is_true old_cookie, @request.cookie_jar.always_write_cookie = @request.cookie_jar.always_write_cookie, true get :authenticate_with_secure assert_cookie_header "user_name=david; path=/; secure" - assert_equal({"user_name" => "david"}, @response.cookies) + assert_equal({ "user_name" => "david" }, @response.cookies) ensure @request.cookie_jar.always_write_cookie = old_cookie end @@ -351,14 +351,14 @@ class CookiesTest < ActionController::TestCase def test_not_setting_cookie_with_secure get :authenticate_with_secure assert_not_cookie_header "user_name=david; path=/; secure" - assert_not_equal({"user_name" => "david"}, @response.cookies) + assert_not_equal({ "user_name" => "david" }, @response.cookies) end def test_multiple_cookies get :set_multiple_cookies assert_equal 2, @response.cookies.size assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000\nlogin=XJ-122; path=/" - assert_equal({"login" => "XJ-122", "user_name" => "david"}, @response.cookies) + assert_equal({ "login" => "XJ-122", "user_name" => "david" }, @response.cookies) end def test_setting_test_cookie @@ -369,7 +369,7 @@ class CookiesTest < ActionController::TestCase request.cookies[:user_name] = "Joe" get :logout assert_cookie_header "user_name=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000" - assert_equal({"user_name" => nil}, @response.cookies) + assert_equal({ "user_name" => nil }, @response.cookies) end def test_delete_cookie_with_path @@ -656,7 +656,7 @@ class CookiesTest < ActionController::TestCase request.cookies[:user_name] = "Joe" get :delete_and_set_cookie assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000" - assert_equal({"user_name" => "david"}, @response.cookies) + assert_equal({ "user_name" => "david" }, @response.cookies) end def test_raise_data_overflow diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb index b55bd9b204..2c5e09e283 100644 --- a/actionpack/test/dispatch/debug_exceptions_test.rb +++ b/actionpack/test/dispatch/debug_exceptions_test.rb @@ -156,7 +156,7 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest test "rescue with text error for xhr request" do @app = DevelopmentApp - xhr_request_env = {"action_dispatch.show_exceptions" => true, "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest"} + xhr_request_env = { "action_dispatch.show_exceptions" => true, "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest" } get "/", headers: xhr_request_env assert_response 500 @@ -399,9 +399,9 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest backtrace_cleaner = ActiveSupport::BacktraceCleaner.new backtrace_cleaner.add_silencer { true } - env = {"action_dispatch.show_exceptions" => true, + env = { "action_dispatch.show_exceptions" => true, "action_dispatch.logger" => Logger.new(output), - "action_dispatch.backtrace_cleaner" => backtrace_cleaner} + "action_dispatch.backtrace_cleaner" => backtrace_cleaner } get "/", headers: env assert_operator((output.rewind && output.read).lines.count, :>, 10) diff --git a/actionpack/test/dispatch/header_test.rb b/actionpack/test/dispatch/header_test.rb index 12f1c2712d..7a155d70cb 100644 --- a/actionpack/test/dispatch/header_test.rb +++ b/actionpack/test/dispatch/header_test.rb @@ -18,14 +18,14 @@ class HeaderTest < ActiveSupport::TestCase "HTTP_REFERER" => "/some/page", "Host" => "http://test.com") - assert_equal({"Content-Type" => "application/json", + assert_equal({ "Content-Type" => "application/json", "HTTP_REFERER" => "/some/page", - "Host" => "http://test.com"}, headers.env) + "Host" => "http://test.com" }, headers.env) end test "#env returns the headers as env variables" do - assert_equal({"CONTENT_TYPE" => "text/plain", - "HTTP_REFERER" => "/some/page"}, @headers.env) + assert_equal({ "CONTENT_TYPE" => "text/plain", + "HTTP_REFERER" => "/some/page" }, @headers.env) end test "#each iterates through the env variables" do @@ -105,28 +105,28 @@ class HeaderTest < ActiveSupport::TestCase test "#merge! headers with mutation" do @headers.merge!("Host" => "http://example.test", "Content-Type" => "text/html") - assert_equal({"HTTP_HOST" => "http://example.test", + assert_equal({ "HTTP_HOST" => "http://example.test", "CONTENT_TYPE" => "text/html", - "HTTP_REFERER" => "/some/page"}, @headers.env) + "HTTP_REFERER" => "/some/page" }, @headers.env) end test "#merge! env with mutation" do @headers.merge!("HTTP_HOST" => "http://first.com", "CONTENT_TYPE" => "text/html") - assert_equal({"HTTP_HOST" => "http://first.com", + assert_equal({ "HTTP_HOST" => "http://first.com", "CONTENT_TYPE" => "text/html", - "HTTP_REFERER" => "/some/page"}, @headers.env) + "HTTP_REFERER" => "/some/page" }, @headers.env) end test "merge without mutation" do combined = @headers.merge("HTTP_HOST" => "http://example.com", "CONTENT_TYPE" => "text/html") - assert_equal({"HTTP_HOST" => "http://example.com", + assert_equal({ "HTTP_HOST" => "http://example.com", "CONTENT_TYPE" => "text/html", - "HTTP_REFERER" => "/some/page"}, combined.env) + "HTTP_REFERER" => "/some/page" }, combined.env) - assert_equal({"CONTENT_TYPE" => "text/plain", - "HTTP_REFERER" => "/some/page"}, @headers.env) + assert_equal({ "CONTENT_TYPE" => "text/plain", + "HTTP_REFERER" => "/some/page" }, @headers.env) end test "env variables with . are not modified" do @@ -151,11 +151,11 @@ class HeaderTest < ActiveSupport::TestCase end test "headers directly modifies the passed environment" do - env = {"HTTP_REFERER" => "/"} + env = { "HTTP_REFERER" => "/" } headers = make_headers(env) headers["Referer"] = "http://example.com/" headers.merge! "CONTENT_TYPE" => "text/plain" - assert_equal({"HTTP_REFERER"=>"http://example.com/", - "CONTENT_TYPE"=>"text/plain"}, env) + assert_equal({ "HTTP_REFERER"=>"http://example.com/", + "CONTENT_TYPE"=>"text/plain" }, env) end end diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb index 8d2699fef6..1596d23b1e 100644 --- a/actionpack/test/dispatch/mapper_test.rb +++ b/actionpack/test/dispatch/mapper_test.rb @@ -58,7 +58,7 @@ module ActionDispatch fakeset = FakeSet.new mapper = Mapper.new fakeset mapper.get "/foo", to: "posts#index", as: :main, format: true - assert_equal({controller: "posts", action: "index"}, + assert_equal({ controller: "posts", action: "index" }, fakeset.defaults.first) assert_equal "/foo.:format", fakeset.asts.first.to_s end @@ -69,7 +69,7 @@ module ActionDispatch mapper.scope(format: true) do mapper.get "/foo", to: "posts#index", as: :main end - assert_equal({controller: "posts", action: "index"}, + assert_equal({ controller: "posts", action: "index" }, fakeset.defaults.first) assert_equal "/foo.:format", fakeset.asts.first.to_s end @@ -80,13 +80,13 @@ module ActionDispatch mapper.scope(omg: :awesome) do mapper.get "/", to: "posts#index", as: :main end - assert_equal({omg: :awesome, controller: "posts", action: "index"}, + assert_equal({ omg: :awesome, controller: "posts", action: "index" }, fakeset.defaults.first) assert_equal("GET", fakeset.routes.first.verb) end def test_mapping_requirements - options = { } + options = {} scope = Mapper::Scope.new({}) ast = Journey::Parser.parse "/store/:name(*rest)" m = Mapper::Mapping.build(scope, FakeSet.new, ast, "foo", "bar", nil, [:get], nil, {}, true, options) diff --git a/actionpack/test/dispatch/middleware_stack_test.rb b/actionpack/test/dispatch/middleware_stack_test.rb index b00488edd5..27da5935b5 100644 --- a/actionpack/test/dispatch/middleware_stack_test.rb +++ b/actionpack/test/dispatch/middleware_stack_test.rb @@ -62,7 +62,7 @@ class MiddlewareStackTest < ActiveSupport::TestCase @stack.use BazMiddleware, true, foo: "bar" end assert_equal BazMiddleware, @stack.last.klass - assert_equal([true, {foo: "bar"}], @stack.last.args) + assert_equal([true, { foo: "bar" }], @stack.last.args) end test "use should push middleware class with block arguments onto the stack" do diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb index 179b65b236..a7d5ba2345 100644 --- a/actionpack/test/dispatch/mount_test.rb +++ b/actionpack/test/dispatch/mount_test.rb @@ -15,13 +15,13 @@ class TestRoutingMount < ActionDispatch::IntegrationTest def self.routes; Object.new; end def self.call(env) - [200, {"Content-Type" => "text/html"}, ["OK"]] + [200, { "Content-Type" => "text/html" }, ["OK"]] end end Router.draw do SprocketsApp = lambda { |env| - [200, {"Content-Type" => "text/html"}, ["#{env["SCRIPT_NAME"]} -- #{env["PATH_INFO"]}"]] + [200, { "Content-Type" => "text/html" }, ["#{env["SCRIPT_NAME"]} -- #{env["PATH_INFO"]}"]] } mount SprocketsApp, at: "/sprockets" diff --git a/actionpack/test/dispatch/prefix_generation_test.rb b/actionpack/test/dispatch/prefix_generation_test.rb index ea11a943f2..bb2fc53add 100644 --- a/actionpack/test/dispatch/prefix_generation_test.rb +++ b/actionpack/test/dispatch/prefix_generation_test.rb @@ -238,7 +238,7 @@ module TestGenerationPrefix end test "[APP] generating engine's route includes default_url_options[:script_name]" do - RailsApplication.routes.default_url_options = {script_name: "/something"} + RailsApplication.routes.default_url_options = { script_name: "/something" } get "/generate" assert_equal "/something/awesome/blog/posts/1", last_response.body end @@ -277,7 +277,7 @@ module TestGenerationPrefix end test "[OBJECT] generating engine's route includes default_url_options[:script_name]" do - RailsApplication.routes.default_url_options = {script_name: "/something"} + RailsApplication.routes.default_url_options = { script_name: "/something" } assert_equal "/something/pure-awesomeness/blog/posts/3", engine_object.post_path(id: 3, omg: "pure-awesomeness") end @@ -286,7 +286,7 @@ module TestGenerationPrefix end test "[OBJECT] generating application's route includes default_url_options[:script_name]" do - RailsApplication.routes.default_url_options = {script_name: "/something"} + RailsApplication.routes.default_url_options = { script_name: "/something" } assert_equal "/something/", app_object.root_path end diff --git a/actionpack/test/dispatch/reloader_test.rb b/actionpack/test/dispatch/reloader_test.rb index 761237d5dc..e74b8e40fd 100644 --- a/actionpack/test/dispatch/reloader_test.rb +++ b/actionpack/test/dispatch/reloader_test.rb @@ -197,7 +197,7 @@ class ReloaderTest < ActiveSupport::TestCase x.check = lambda { true } @response ||= "response" - @reloader ||= Reloader.new(block || proc {[200, {}, @response]}, x) + @reloader ||= Reloader.new(block || proc { [200, {}, @response] }, x) @reloader.call("rack.input" => StringIO.new(""))[2] end end diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb index e24b1e12e3..d0cd32a242 100644 --- a/actionpack/test/dispatch/request/json_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb @@ -18,21 +18,21 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest test "parses json params for application json" do assert_parses( - {"person" => {"name" => "David"}}, + { "person" => { "name" => "David" } }, "{\"person\": {\"name\": \"David\"}}", "CONTENT_TYPE" => "application/json" ) end test "parses boolean and number json params for application json" do assert_parses( - {"item" => {"enabled" => false, "count" => 10}}, + { "item" => { "enabled" => false, "count" => 10 } }, "{\"item\": {\"enabled\": false, \"count\": 10}}", "CONTENT_TYPE" => "application/json" ) end test "parses json params for application jsonrequest" do assert_parses( - {"person" => {"name" => "David"}}, + { "person" => { "name" => "David" } }, "{\"person\": {\"name\": \"David\"}}", "CONTENT_TYPE" => "application/jsonrequest" ) end @@ -46,15 +46,15 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest test "nils are stripped from collections" do assert_parses( - {"person" => []}, + { "person" => [] }, "{\"person\":[null]}", "CONTENT_TYPE" => "application/json" ) assert_parses( - {"person" => ["foo"]}, + { "person" => ["foo"] }, "{\"person\":[\"foo\",null]}", "CONTENT_TYPE" => "application/json" ) assert_parses( - {"person" => []}, + { "person" => [] }, "{\"person\":[null, null]}", "CONTENT_TYPE" => "application/json" ) end @@ -133,21 +133,21 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest test "parses json params for application json" do assert_parses( - {"user" => {"username" => "sikachu"}, "username" => "sikachu"}, + { "user" => { "username" => "sikachu" }, "username" => "sikachu" }, "{\"username\": \"sikachu\"}", "CONTENT_TYPE" => "application/json" ) end test "parses json params for application jsonrequest" do assert_parses( - {"user" => {"username" => "sikachu"}, "username" => "sikachu"}, + { "user" => { "username" => "sikachu" }, "username" => "sikachu" }, "{\"username\": \"sikachu\"}", "CONTENT_TYPE" => "application/jsonrequest" ) end test "parses json with non-object JSON content" do assert_parses( - {"user" => {"_json" => "string content" }, "_json" => "string content" }, + { "user" => { "_json" => "string content" }, "_json" => "string content" }, "\"string content\"", "CONTENT_TYPE" => "application/json" ) end @@ -157,7 +157,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest Mime::Type.unregister :json Mime::Type.register "application/json", :json, %w(application/vnd.rails+json) assert_parses( - {"user" => {"username" => "meinac"}, "username" => "meinac"}, + { "user" => { "username" => "meinac" }, "username" => "meinac" }, "{\"username\": \"meinac\"}", "CONTENT_TYPE" => "application/json" ) ensure @@ -171,7 +171,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest Mime::Type.unregister :json Mime::Type.register "application/json", :json, %w(application/vnd.rails+json) assert_parses( - {"user" => {"username" => "meinac"}, "username" => "meinac"}, + { "user" => { "username" => "meinac" }, "username" => "meinac" }, "{\"username\": \"meinac\"}", "CONTENT_TYPE" => "application/vnd.rails+json" ) ensure diff --git a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb index 2714b7f50b..e572c722a0 100644 --- a/actionpack/test/dispatch/request/multipart_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/multipart_params_parsing_test.rb @@ -32,11 +32,11 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest end test "parses bracketed parameters" do - assert_equal({ "foo" => { "baz" => "bar"}}, parse_multipart("bracketed_param")) + assert_equal({ "foo" => { "baz" => "bar" } }, parse_multipart("bracketed_param")) end test "parse single utf8 parameter" do - assert_equal({ "Iñtërnâtiônàlizætiøn_name" => "Iñtërnâtiônàlizætiøn_value"}, + assert_equal({ "Iñtërnâtiônàlizætiøn_name" => "Iñtërnâtiônàlizætiøn_value" }, parse_multipart("single_utf8_param"), "request.request_parameters") assert_equal( "Iñtërnâtiônàlizætiøn_value", @@ -45,10 +45,10 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest test "parse bracketed utf8 parameter" do assert_equal({ "Iñtërnâtiônàlizætiøn_name" => { - "Iñtërnâtiônàlizætiøn_nested_name" => "Iñtërnâtiônàlizætiøn_value"} }, + "Iñtërnâtiônàlizætiøn_nested_name" => "Iñtërnâtiônàlizætiøn_value" } }, parse_multipart("bracketed_utf8_param"), "request.request_parameters") assert_equal( - {"Iñtërnâtiônàlizætiøn_nested_name" => "Iñtërnâtiônàlizætiøn_value"}, + { "Iñtërnâtiônàlizætiøn_nested_name" => "Iñtërnâtiônàlizætiøn_value" }, TestController.last_parameters["Iñtërnâtiônàlizætiøn_name"], "request.parameters") end diff --git a/actionpack/test/dispatch/request/query_string_parsing_test.rb b/actionpack/test/dispatch/request/query_string_parsing_test.rb index 6763dbf243..5c992be216 100644 --- a/actionpack/test/dispatch/request/query_string_parsing_test.rb +++ b/actionpack/test/dispatch/request/query_string_parsing_test.rb @@ -29,92 +29,92 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest test "query string" do assert_parses( - {"action" => "create_customer", "full_name" => "David Heinemeier Hansson", "customerId" => "1"}, + { "action" => "create_customer", "full_name" => "David Heinemeier Hansson", "customerId" => "1" }, "action=create_customer&full_name=David%20Heinemeier%20Hansson&customerId=1" ) end test "deep query string" do assert_parses( - {"x" => {"y" => {"z" => "10"}}}, + { "x" => { "y" => { "z" => "10" } } }, "x[y][z]=10" ) end test "deep query string with array" do - assert_parses({"x" => {"y" => {"z" => ["10"]}}}, "x[y][z][]=10") - assert_parses({"x" => {"y" => {"z" => ["10", "5"]}}}, "x[y][z][]=10&x[y][z][]=5") + assert_parses({ "x" => { "y" => { "z" => ["10"] } } }, "x[y][z][]=10") + assert_parses({ "x" => { "y" => { "z" => ["10", "5"] } } }, "x[y][z][]=10&x[y][z][]=5") end test "deep query string with array of hash" do - assert_parses({"x" => {"y" => [{"z" => "10"}]}}, "x[y][][z]=10") - assert_parses({"x" => {"y" => [{"z" => "10", "w" => "10"}]}}, "x[y][][z]=10&x[y][][w]=10") - assert_parses({"x" => {"y" => [{"z" => "10", "v" => {"w" => "10"}}]}}, "x[y][][z]=10&x[y][][v][w]=10") + assert_parses({ "x" => { "y" => [{ "z" => "10" }] } }, "x[y][][z]=10") + assert_parses({ "x" => { "y" => [{ "z" => "10", "w" => "10" }] } }, "x[y][][z]=10&x[y][][w]=10") + assert_parses({ "x" => { "y" => [{ "z" => "10", "v" => { "w" => "10" } }] } }, "x[y][][z]=10&x[y][][v][w]=10") end test "deep query string with array of hashes with one pair" do - assert_parses({"x" => {"y" => [{"z" => "10"}, {"z" => "20"}]}}, "x[y][][z]=10&x[y][][z]=20") + assert_parses({ "x" => { "y" => [{ "z" => "10" }, { "z" => "20" }] } }, "x[y][][z]=10&x[y][][z]=20") end test "deep query string with array of hashes with multiple pairs" do assert_parses( - {"x" => {"y" => [{"z" => "10", "w" => "a"}, {"z" => "20", "w" => "b"}]}}, + { "x" => { "y" => [{ "z" => "10", "w" => "a" }, { "z" => "20", "w" => "b" }] } }, "x[y][][z]=10&x[y][][w]=a&x[y][][z]=20&x[y][][w]=b" ) end test "query string with nil" do assert_parses( - { "action" => "create_customer", "full_name" => ""}, + { "action" => "create_customer", "full_name" => "" }, "action=create_customer&full_name=" ) end test "query string with array" do assert_parses( - { "action" => "create_customer", "selected" => ["1", "2", "3"]}, + { "action" => "create_customer", "selected" => ["1", "2", "3"] }, "action=create_customer&selected[]=1&selected[]=2&selected[]=3" ) end test "query string with amps" do assert_parses( - { "action" => "create_customer", "name" => "Don't & Does"}, + { "action" => "create_customer", "name" => "Don't & Does" }, "action=create_customer&name=Don%27t+%26+Does" ) end test "query string with many equal" do assert_parses( - { "action" => "create_customer", "full_name" => "abc=def=ghi"}, + { "action" => "create_customer", "full_name" => "abc=def=ghi" }, "action=create_customer&full_name=abc=def=ghi" ) end test "query string without equal" do - assert_parses({"action" => nil}, "action") - assert_parses({"action" => {"foo" => nil}}, "action[foo]") - assert_parses({"action" => {"foo" => { "bar" => nil }}}, "action[foo][bar]") - assert_parses({"action" => {"foo" => { "bar" => [] }}}, "action[foo][bar][]") - assert_parses({"action" => {"foo" => [] }}, "action[foo][]") - assert_parses({"action"=>{"foo"=>[{"bar"=>nil}]}}, "action[foo][][bar]") + assert_parses({ "action" => nil }, "action") + assert_parses({ "action" => { "foo" => nil } }, "action[foo]") + assert_parses({ "action" => { "foo" => { "bar" => nil } } }, "action[foo][bar]") + assert_parses({ "action" => { "foo" => { "bar" => [] } } }, "action[foo][bar][]") + assert_parses({ "action" => { "foo" => [] } }, "action[foo][]") + assert_parses({ "action"=>{ "foo"=>[{ "bar"=>nil }] } }, "action[foo][][bar]") end def test_array_parses_without_nil - assert_parses({"action" => ["1"]}, "action[]=1&action[]") + assert_parses({ "action" => ["1"] }, "action[]=1&action[]") end test "perform_deep_munge" do old_perform_deep_munge = ActionDispatch::Request::Utils.perform_deep_munge ActionDispatch::Request::Utils.perform_deep_munge = false begin - assert_parses({"action" => nil}, "action") - assert_parses({"action" => {"foo" => nil}}, "action[foo]") - assert_parses({"action" => {"foo" => {"bar" => nil}}}, "action[foo][bar]") - assert_parses({"action" => {"foo" => {"bar" => [nil]}}}, "action[foo][bar][]") - assert_parses({"action" => {"foo" => [nil]}}, "action[foo][]") - assert_parses({"action" => {"foo" => [{"bar" => nil}]}}, "action[foo][][bar]") - assert_parses({"action" => ["1",nil]}, "action[]=1&action[]") + assert_parses({ "action" => nil }, "action") + assert_parses({ "action" => { "foo" => nil } }, "action[foo]") + assert_parses({ "action" => { "foo" => { "bar" => nil } } }, "action[foo][bar]") + assert_parses({ "action" => { "foo" => { "bar" => [nil] } } }, "action[foo][bar][]") + assert_parses({ "action" => { "foo" => [nil] } }, "action[foo][]") + assert_parses({ "action" => { "foo" => [{ "bar" => nil }] } }, "action[foo][][bar]") + assert_parses({ "action" => ["1",nil] }, "action[]=1&action[]") ensure ActionDispatch::Request::Utils.perform_deep_munge = old_perform_deep_munge end @@ -129,14 +129,14 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest test "query string with many ampersands" do assert_parses( - { "action" => "create_customer", "full_name" => "David Heinemeier Hansson"}, + { "action" => "create_customer", "full_name" => "David Heinemeier Hansson" }, "&action=create_customer&&&full_name=David%20Heinemeier%20Hansson" ) end test "unbalanced query string with array" do assert_parses( - {"location" => ["1", "2"], "age_group" => ["2"]}, + { "location" => ["1", "2"], "age_group" => ["2"] }, "location[]=1&location[]=2&age_group[]=2" ) end diff --git a/actionpack/test/dispatch/request/session_test.rb b/actionpack/test/dispatch/request/session_test.rb index cc3c4d48f3..311b80ea0a 100644 --- a/actionpack/test/dispatch/request/session_test.rb +++ b/actionpack/test/dispatch/request/session_test.rb @@ -19,7 +19,7 @@ module ActionDispatch s = Session.create(store, req, {}) s["foo"] = "bar" assert_equal "bar", s["foo"] - assert_equal({"foo" => "bar"}, s.to_hash) + assert_equal({ "foo" => "bar" }, s.to_hash) end def test_create_merges_old @@ -98,7 +98,7 @@ module ActionDispatch assert_equal "2", session.fetch(:two, "2") assert_nil session.fetch(:two, nil) - assert_equal "three", session.fetch(:three) {|el| el.to_s } + assert_equal "three", session.fetch(:three) { |el| el.to_s } assert_raise KeyError do session.fetch(:three) diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index 0dc8a2508e..13a87b8976 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -22,7 +22,7 @@ class BaseRequestTest < ActiveSupport::TestCase def stub_request(env = {}) ip_spoofing_check = env.key?(:ip_spoofing_check) ? env.delete(:ip_spoofing_check) : true @trusted_proxies ||= nil - ip_app = ActionDispatch::RemoteIp.new(Proc.new { }, ip_spoofing_check, @trusted_proxies) + ip_app = ActionDispatch::RemoteIp.new(Proc.new {}, ip_spoofing_check, @trusted_proxies) ActionDispatch::Http::URL.tld_length = env.delete(:tld_length) if env.key?(:tld_length) ip_app.call(env) @@ -596,7 +596,7 @@ class RequestParamsParsing < BaseRequestTest "rack.input" => StringIO.new("flamenco=love") ) - assert_equal({"flamenco"=> "love"}, request.request_parameters) + assert_equal({ "flamenco"=> "love" }, request.request_parameters) end test "doesnt interpret request uri as query string when missing" do @@ -784,21 +784,21 @@ end class RequestFormat < BaseRequestTest test "xml format" do request = stub_request - assert_called(request, :parameters, times: 2, returns: {format: :xml}) do + assert_called(request, :parameters, times: 2, returns: { format: :xml }) do assert_equal Mime[:xml], request.format end end test "xhtml format" do request = stub_request - assert_called(request, :parameters, times: 2, returns: {format: :xhtml}) do + assert_called(request, :parameters, times: 2, returns: { format: :xhtml }) do assert_equal Mime[:html], request.format end end test "txt format" do request = stub_request - assert_called(request, :parameters, times: 2, returns: {format: :txt}) do + assert_called(request, :parameters, times: 2, returns: { format: :txt }) do assert_equal Mime[:text], request.format end end @@ -817,14 +817,14 @@ class RequestFormat < BaseRequestTest test "can override format with parameter negative" do request = stub_request - assert_called(request, :parameters, times: 2, returns: {format: :txt}) do + assert_called(request, :parameters, times: 2, returns: { format: :txt }) do assert !request.format.xml? end end test "can override format with parameter positive" do request = stub_request - assert_called(request, :parameters, times: 2, returns: {format: :xml}) do + assert_called(request, :parameters, times: 2, returns: { format: :xml }) do assert request.format.xml? end end @@ -852,21 +852,21 @@ class RequestFormat < BaseRequestTest test "formats format:text with accept header" do request = stub_request - assert_called(request, :parameters, times: 2, returns: {format: :txt}) do + assert_called(request, :parameters, times: 2, returns: { format: :txt }) do assert_equal [Mime[:text]], request.formats end end test "formats format:unknown with accept header" do request = stub_request - assert_called(request, :parameters, times: 2, returns: {format: :unknown}) do + assert_called(request, :parameters, times: 2, returns: { format: :unknown }) do assert_instance_of Mime::NullType, request.format end end test "format is not nil with unknown format" do request = stub_request - assert_called(request, :parameters, times: 2, returns: {format: :hello}) do + assert_called(request, :parameters, times: 2, returns: { format: :hello }) do assert request.format.nil? assert_not request.format.html? assert_not request.format.xml? @@ -921,7 +921,7 @@ class RequestFormat < BaseRequestTest request = stub_request "HTTP_ACCEPT" => "application/xml", "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest" - assert_called(request, :parameters, times: 2, returns: {format: :json}) do + assert_called(request, :parameters, times: 2, returns: { format: :json }) do assert_equal [ Mime[:json] ], request.formats end ensure @@ -997,11 +997,11 @@ class RequestParameters < BaseRequestTest test "parameters" do request = stub_request - assert_called(request, :request_parameters, times: 2, returns: {"foo" => 1}) do - assert_called(request, :query_parameters, times: 2, returns: {"bar" => 2}) do - assert_equal({"foo" => 1, "bar" => 2}, request.parameters) - assert_equal({"foo" => 1}, request.request_parameters) - assert_equal({"bar" => 2}, request.query_parameters) + assert_called(request, :request_parameters, times: 2, returns: { "foo" => 1 }) do + assert_called(request, :query_parameters, times: 2, returns: { "bar" => 2 }) do + assert_equal({ "foo" => 1, "bar" => 2 }, request.parameters) + assert_equal({ "foo" => 1 }, request.request_parameters) + assert_equal({ "bar" => 2 }, request.query_parameters) end end end @@ -1072,14 +1072,14 @@ end class RequestParameterFilter < BaseRequestTest test "process parameter filter" do test_hashes = [ - [{"foo"=>"bar"},{"foo"=>"bar"},%w'food'], - [{"foo"=>"bar"},{"foo"=>"[FILTERED]"},%w'foo'], - [{"foo"=>"bar", "bar"=>"foo"},{"foo"=>"[FILTERED]", "bar"=>"foo"},%w'foo baz'], - [{"foo"=>"bar", "baz"=>"foo"},{"foo"=>"[FILTERED]", "baz"=>"[FILTERED]"},%w'foo baz'], - [{"bar"=>{"foo"=>"bar","bar"=>"foo"}},{"bar"=>{"foo"=>"[FILTERED]","bar"=>"foo"}},%w'fo'], - [{"foo"=>{"foo"=>"bar","bar"=>"foo"}},{"foo"=>"[FILTERED]"},%w'f banana'], - [{"deep"=>{"cc"=>{"code"=>"bar","bar"=>"foo"},"ss"=>{"code"=>"bar"}}},{"deep"=>{"cc"=>{"code"=>"[FILTERED]","bar"=>"foo"},"ss"=>{"code"=>"bar"}}},%w'deep.cc.code'], - [{"baz"=>[{"foo"=>"baz"}, "1"]}, {"baz"=>[{"foo"=>"[FILTERED]"}, "1"]}, [/foo/]]] + [{ "foo"=>"bar" },{ "foo"=>"bar" },%w'food'], + [{ "foo"=>"bar" },{ "foo"=>"[FILTERED]" },%w'foo'], + [{ "foo"=>"bar", "bar"=>"foo" },{ "foo"=>"[FILTERED]", "bar"=>"foo" },%w'foo baz'], + [{ "foo"=>"bar", "baz"=>"foo" },{ "foo"=>"[FILTERED]", "baz"=>"[FILTERED]" },%w'foo baz'], + [{ "bar"=>{ "foo"=>"bar","bar"=>"foo" } },{ "bar"=>{ "foo"=>"[FILTERED]","bar"=>"foo" } },%w'fo'], + [{ "foo"=>{ "foo"=>"bar","bar"=>"foo" } },{ "foo"=>"[FILTERED]" },%w'f banana'], + [{ "deep"=>{ "cc"=>{ "code"=>"bar","bar"=>"foo" },"ss"=>{ "code"=>"bar" } } },{ "deep"=>{ "cc"=>{ "code"=>"[FILTERED]","bar"=>"foo" },"ss"=>{ "code"=>"bar" } } },%w'deep.cc.code'], + [{ "baz"=>[{ "foo"=>"baz" }, "1"] }, { "baz"=>[{ "foo"=>"[FILTERED]" }, "1"] }, [/foo/]]] test_hashes.each do |before_filter, after_filter, filter_words| parameter_filter = ActionDispatch::Http::ParameterFilter.new(filter_words) @@ -1091,8 +1091,8 @@ class RequestParameterFilter < BaseRequestTest } parameter_filter = ActionDispatch::Http::ParameterFilter.new(filter_words) - before_filter["barg"] = {:bargain=>"gain", "blah"=>"bar", "bar"=>{"bargain"=>{"blah"=>"foo"}}} - after_filter["barg"] = {:bargain=>"niag", "blah"=>"[FILTERED]", "bar"=>{"bargain"=>{"blah"=>"[FILTERED]"}}} + before_filter["barg"] = { :bargain=>"gain", "blah"=>"bar", "bar"=>{ "bargain"=>{ "blah"=>"foo" } } } + after_filter["barg"] = { :bargain=>"niag", "blah"=>"[FILTERED]", "bar"=>{ "bargain"=>{ "blah"=>"[FILTERED]" } } } assert_equal after_filter, parameter_filter.filter(before_filter) end diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index d539092244..4e547ab7d5 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -40,7 +40,7 @@ class ResponseTest < ActiveSupport::TestCase def test_each_isnt_called_if_str_body_is_written # Controller writes and reads response body each_counter = 0 - @response.body = Object.new.tap {|o| o.singleton_class.send(:define_method, :each) { |&block| each_counter += 1; block.call "foo" } } + @response.body = Object.new.tap { |o| o.singleton_class.send(:define_method, :each) { |&block| each_counter += 1; block.call "foo" } } @response["X-Foo"] = @response.body assert_equal 1, each_counter, "#each was not called once" @@ -224,7 +224,7 @@ class ResponseTest < ActiveSupport::TestCase @response.set_cookie("user_name", value: "david", path: "/") _status, headers, _body = @response.to_a assert_equal "user_name=david; path=/", headers["Set-Cookie"] - assert_equal({"user_name" => "david"}, @response.cookies) + assert_equal({ "user_name" => "david" }, @response.cookies) end test "multiple cookies" do @@ -232,14 +232,14 @@ class ResponseTest < ActiveSupport::TestCase @response.set_cookie("login", value: "foo&bar", path: "/", expires: Time.utc(2005, 10, 10,5)) _status, headers, _body = @response.to_a assert_equal "user_name=david; path=/\nlogin=foo%26bar; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000", headers["Set-Cookie"] - assert_equal({"login" => "foo&bar", "user_name" => "david"}, @response.cookies) + assert_equal({ "login" => "foo&bar", "user_name" => "david" }, @response.cookies) end test "delete cookies" do @response.set_cookie("user_name", value: "david", path: "/") @response.set_cookie("login", value: "foo&bar", path: "/", expires: Time.utc(2005, 10, 10,5)) @response.delete_cookie("login") - assert_equal({"user_name" => "david", "login" => nil}, @response.cookies) + assert_equal({ "user_name" => "david", "login" => nil }, @response.cookies) end test "read ETag and Cache-Control" do @@ -254,7 +254,7 @@ class ResponseTest < ActiveSupport::TestCase assert resp.weak_etag? assert_not resp.strong_etag? assert_equal('W/"202cb962ac59075b964b07152d234b70"', resp.etag) - assert_equal({public: true}, resp.cache_control) + assert_equal({ public: true }, resp.cache_control) assert_equal("public", resp.headers["Cache-Control"]) assert_equal('W/"202cb962ac59075b964b07152d234b70"', resp.headers["ETag"]) @@ -461,14 +461,14 @@ class ResponseIntegrationTest < ActionDispatch::IntegrationTest assert_equal('W/"202cb962ac59075b964b07152d234b70"', @response.headers["ETag"]) assert_equal('W/"202cb962ac59075b964b07152d234b70"', @response.etag) - assert_equal({public: true}, @response.cache_control) + assert_equal({ public: true }, @response.cache_control) end test "response cache control from rackish app" do @app = lambda { |env| [200, - {"ETag" => 'W/"202cb962ac59075b964b07152d234b70"', - "Cache-Control" => "public"}, ["Hello"]] + { "ETag" => 'W/"202cb962ac59075b964b07152d234b70"', + "Cache-Control" => "public" }, ["Hello"]] } get "/" @@ -478,7 +478,7 @@ class ResponseIntegrationTest < ActionDispatch::IntegrationTest assert_equal('W/"202cb962ac59075b964b07152d234b70"', @response.headers["ETag"]) assert_equal('W/"202cb962ac59075b964b07152d234b70"', @response.etag) - assert_equal({public: true}, @response.cache_control) + assert_equal({ public: true }, @response.cache_control) end test "response charset and content type from railsish app" do @@ -503,7 +503,7 @@ class ResponseIntegrationTest < ActionDispatch::IntegrationTest test "response charset and content type from rackish app" do @app = lambda { |env| [200, - {"Content-Type" => "application/xml; charset=utf-16"}, + { "Content-Type" => "application/xml; charset=utf-16" }, ["Hello"]] } diff --git a/actionpack/test/dispatch/routing/inspector_test.rb b/actionpack/test/dispatch/routing/inspector_test.rb index 97137a4762..a4babf8554 100644 --- a/actionpack/test/dispatch/routing/inspector_test.rb +++ b/actionpack/test/dispatch/routing/inspector_test.rb @@ -172,7 +172,7 @@ module ActionDispatch def test_rails_routes_shows_route_with_defaults output = draw do - get "photos/:id" => "photos#show", :defaults => {format: "jpg"} + get "photos/:id" => "photos#show", :defaults => { format: "jpg" } end assert_equal [ @@ -291,7 +291,7 @@ module ActionDispatch output = draw do get "/foo" => redirect("/foo/bar"), :constraints => { subdomain: "admin" } get "/bar" => redirect(path: "/foo/bar", status: 307) - get "/foobar" => redirect{ "/foo/bar" } + get "/foobar" => redirect { "/foo/bar" } end assert_equal [ diff --git a/actionpack/test/dispatch/routing_assertions_test.rb b/actionpack/test/dispatch/routing_assertions_test.rb index 56ab4e883f..917ce7e668 100644 --- a/actionpack/test/dispatch/routing_assertions_test.rb +++ b/actionpack/test/dispatch/routing_assertions_test.rb @@ -98,7 +98,7 @@ class RoutingAssertionsTest < ActionController::TestCase end def test_assert_routing_with_extras - assert_routing("/articles", { controller: "articles", action: "index", page: "1" }, { }, page: "1") + assert_routing("/articles", { controller: "articles", action: "index", page: "1" }, {}, page: "1") end def test_assert_routing_with_hash_constraint diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index e64dedf817..56be08f54f 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -4,7 +4,7 @@ require "controller/fake_controllers" class TestRoutingMapper < ActionDispatch::IntegrationTest SprocketsApp = lambda { |env| - [200, {"Content-Type" => "text/html"}, ["javascripts"]] + [200, { "Content-Type" => "text/html" }, ["javascripts"]] } class IpRestrictor @@ -245,7 +245,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest def test_redirect_proc draw do - get "account/proc/:name", to: redirect {|params, req| "/#{params[:name].pluralize}" } + get "account/proc/:name", to: redirect { |params, req| "/#{params[:name].pluralize}" } end get "/account/proc/person" @@ -254,7 +254,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest def test_redirect_proc_with_request draw do - get "account/proc_req" => redirect {|params, req| "/#{req.method}" } + get "account/proc_req" => redirect { |params, req| "/#{req.method}" } end get "/account/proc_req" @@ -480,7 +480,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end # without dup, additional (and possibly unwanted) values will be present in the options (eg. :host) - original_options = {controller: "projects", action: "status"} + original_options = { controller: "projects", action: "status" } options = original_options.dup url_for options @@ -495,7 +495,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end controller = "/projects" - options = {controller: controller, action: "status", only_path: true} + options = { controller: controller, action: "status", only_path: true } url = url_for(options) assert_equal "/projects/status", url @@ -958,15 +958,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end def test_resource_does_not_modify_passed_options - options = {id: /.+?/, format: /json|xml/} + options = { id: /.+?/, format: /json|xml/ } draw { resource :user, options } - assert_equal({id: /.+?/, format: /json|xml/}, options) + assert_equal({ id: /.+?/, format: /json|xml/ }, options) end def test_resources_does_not_modify_passed_options - options = {id: /.+?/, format: /json|xml/} + options = { id: /.+?/, format: /json|xml/ } draw { resources :users, options } - assert_equal({id: /.+?/, format: /json|xml/}, options) + assert_equal({ id: /.+?/, format: /json|xml/ }, options) end def test_path_names @@ -2557,7 +2557,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get "/movies/00001" assert_equal "Not Found", @response.body - assert_raises(ActionController::UrlGenerationError){ movie_path(id: "00001") } + assert_raises(ActionController::UrlGenerationError) { movie_path(id: "00001") } get "/movies/0001/reviews" assert_equal "reviews#index", @response.body @@ -2565,7 +2565,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get "/movies/00001/reviews" assert_equal "Not Found", @response.body - assert_raises(ActionController::UrlGenerationError){ movie_reviews_path(movie_id: "00001") } + assert_raises(ActionController::UrlGenerationError) { movie_reviews_path(movie_id: "00001") } get "/movies/0001/reviews/0001" assert_equal "reviews#show", @response.body @@ -2573,7 +2573,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get "/movies/00001/reviews/0001" assert_equal "Not Found", @response.body - assert_raises(ActionController::UrlGenerationError){ movie_path(movie_id: "00001", id: "00001") } + assert_raises(ActionController::UrlGenerationError) { movie_path(movie_id: "00001", id: "00001") } get "/movies/0001/trailer" assert_equal "trailers#show", @response.body @@ -2581,7 +2581,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get "/movies/00001/trailer" assert_equal "Not Found", @response.body - assert_raises(ActionController::UrlGenerationError){ movie_trailer_path(movie_id: "00001") } + assert_raises(ActionController::UrlGenerationError) { movie_trailer_path(movie_id: "00001") } end def test_only_should_be_read_from_scope @@ -3009,7 +3009,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get "/cities", to: "countries#cities" end - get "/countries/:country/(*other)", to: redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : "/countries/all" } + get "/countries/:country/(*other)", to: redirect { |params, req| params[:other] ? "/countries/all/#{params[:other]}" : "/countries/all" } end get "/countries/France" @@ -3030,7 +3030,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest scope "/italians" do get "/writers", to: "italians#writers", constraints: ::TestRoutingMapper::IpRestrictor get "/sculptors", to: "italians#sculptors" - get "/painters/:painter", to: "italians#painters", constraints: {painter: /michelangelo/} + get "/painters/:painter", to: "italians#painters", constraints: { painter: /michelangelo/ } end end @@ -3120,7 +3120,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get "/lists/2/todos/1" assert_equal "Not Found", @response.body - assert_raises(ActionController::UrlGenerationError){ list_todo_path(list_id: "2", id: "1") } + assert_raises(ActionController::UrlGenerationError) { list_todo_path(list_id: "2", id: "1") } end def test_redirect_argument_error @@ -3720,13 +3720,13 @@ class TestAltApp < ActionDispatch::IntegrationTest class XHeader def call(env) - [200, {"Content-Type" => "text/html"}, ["XHeader"]] + [200, { "Content-Type" => "text/html" }, ["XHeader"]] end end class AltApp def call(env) - [200, {"Content-Type" => "text/html"}, ["Alternative App"]] + [200, { "Content-Type" => "text/html" }, ["Alternative App"]] end end @@ -3736,7 +3736,7 @@ class TestAltApp < ActionDispatch::IntegrationTest end }.new AltRoutes.draw do - get "/" => TestAltApp::XHeader.new, :constraints => {x_header: /HEADER/} + get "/" => TestAltApp::XHeader.new, :constraints => { x_header: /HEADER/ } get "/" => TestAltApp::AltApp.new end @@ -3903,7 +3903,7 @@ class TestDefaultScope < ActionDispatch::IntegrationTest end DefaultScopeRoutes = ActionDispatch::Routing::RouteSet.new - DefaultScopeRoutes.default_scope = {module: :blog} + DefaultScopeRoutes.default_scope = { module: :blog } DefaultScopeRoutes.draw do resources :posts end @@ -4144,7 +4144,7 @@ class TestGlobRoutingMapper < ActionDispatch::IntegrationTest app.draw do ok = lambda { |env| [200, { "Content-Type" => "text/plain" }, []] } - get "/*id" => redirect("/not_cars"), :constraints => {id: /dummy/} + get "/*id" => redirect("/not_cars"), :constraints => { id: /dummy/ } get "/cars" => ok end end @@ -4629,24 +4629,24 @@ class TestUrlGenerationErrors < ActionDispatch::IntegrationTest message = "No route matches #{url.inspect} missing required keys: #{missing.inspect}" # Optimized url helper - error = assert_raises(ActionController::UrlGenerationError){ product_path(nil) } + error = assert_raises(ActionController::UrlGenerationError) { product_path(nil) } assert_equal message, error.message # Non-optimized url helper - error = assert_raises(ActionController::UrlGenerationError, message){ product_path(id: nil) } + error = assert_raises(ActionController::UrlGenerationError, message) { product_path(id: nil) } assert_equal message, error.message end test "url helpers raise message with mixed parameters when generation fails " do - url, missing = { action: "show", controller: "products", id: nil, "id"=>"url-tested"}, [:id] + url, missing = { action: "show", controller: "products", id: nil, "id"=>"url-tested" }, [:id] message = "No route matches #{url.inspect} missing required keys: #{missing.inspect}" # Optimized url helper - error = assert_raises(ActionController::UrlGenerationError){ product_path(nil, "id"=>"url-tested") } + error = assert_raises(ActionController::UrlGenerationError) { product_path(nil, "id"=>"url-tested") } assert_equal message, error.message # Non-optimized url helper - error = assert_raises(ActionController::UrlGenerationError, message){ product_path(id: nil, "id"=>"url-tested") } + error = assert_raises(ActionController::UrlGenerationError, message) { product_path(id: nil, "id"=>"url-tested") } assert_equal message, error.message end end diff --git a/actionpack/test/dispatch/session/cache_store_test.rb b/actionpack/test/dispatch/session/cache_store_test.rb index 5252d93850..a60629a7ee 100644 --- a/actionpack/test/dispatch/session/cache_store_test.rb +++ b/actionpack/test/dispatch/session/cache_store_test.rb @@ -156,7 +156,7 @@ class CacheStoreTest < ActionDispatch::IntegrationTest assert_response :success assert_not_equal "0xhax", cookies["_session_id"] assert_equal nil, @cache.read("_session_id:0xhax") - assert_equal({"foo" => "bar"}, @cache.read("_session_id:#{cookies['_session_id']}")) + assert_equal({ "foo" => "bar" }, @cache.read("_session_id:#{cookies['_session_id']}")) end end diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb index e8f0ce21e9..f72823a80e 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -3,7 +3,7 @@ require "zlib" module StaticTests DummyApp = lambda { |env| - [200, {"Content-Type" => "text/plain"}, ["Hello, World!"]] + [200, { "Content-Type" => "text/plain" }, ["Hello, World!"]] } def setup @@ -168,7 +168,7 @@ module StaticTests def test_does_not_modify_path_info file_name = "/gzip/application-a71b3024f80aea3181c09774ca17e712.js" - env = {"PATH_INFO" => file_name, "HTTP_ACCEPT_ENCODING" => "gzip", "REQUEST_METHOD" => "POST"} + env = { "PATH_INFO" => file_name, "HTTP_ACCEPT_ENCODING" => "gzip", "REQUEST_METHOD" => "POST" } @app.call(env) assert_equal file_name, env["PATH_INFO"] end @@ -266,7 +266,7 @@ class StaticTest < ActiveSupport::TestCase def setup super @root = "#{FIXTURE_LOAD_PATH}/public" - @app = ActionDispatch::Static.new(DummyApp, @root, headers: {"Cache-Control" => "public, max-age=60"}) + @app = ActionDispatch::Static.new(DummyApp, @root, headers: { "Cache-Control" => "public, max-age=60" }) end def public_path @@ -308,7 +308,7 @@ class StaticEncodingTest < StaticTest def setup super @root = "#{FIXTURE_LOAD_PATH}/公共" - @app = ActionDispatch::Static.new(DummyApp, @root, headers: {"Cache-Control" => "public, max-age=60"}) + @app = ActionDispatch::Static.new(DummyApp, @root, headers: { "Cache-Control" => "public, max-age=60" }) end def public_path diff --git a/actionpack/test/dispatch/test_request_test.rb b/actionpack/test/dispatch/test_request_test.rb index 9beab1ee07..35af3076ba 100644 --- a/actionpack/test/dispatch/test_request_test.rb +++ b/actionpack/test/dispatch/test_request_test.rb @@ -33,24 +33,24 @@ class TestRequestTest < ActiveSupport::TestCase assert_equal nil, req.env["HTTP_COOKIE"] req.cookie_jar["user_name"] = "david" - assert_cookies({"user_name" => "david"}, req.cookie_jar) + assert_cookies({ "user_name" => "david" }, req.cookie_jar) req.cookie_jar["login"] = "XJ-122" - assert_cookies({"user_name" => "david", "login" => "XJ-122"}, req.cookie_jar) + assert_cookies({ "user_name" => "david", "login" => "XJ-122" }, req.cookie_jar) assert_nothing_raised do req.cookie_jar["login"] = nil - assert_cookies({"user_name" => "david", "login" => nil}, req.cookie_jar) + assert_cookies({ "user_name" => "david", "login" => nil }, req.cookie_jar) end req.cookie_jar.delete(:login) - assert_cookies({"user_name" => "david"}, req.cookie_jar) + assert_cookies({ "user_name" => "david" }, req.cookie_jar) req.cookie_jar.clear assert_cookies({}, req.cookie_jar) req.cookie_jar.update(user_name: "david") - assert_cookies({"user_name" => "david"}, req.cookie_jar) + assert_cookies({ "user_name" => "david" }, req.cookie_jar) end test "does not complain when there is no application config" do diff --git a/actionpack/test/journey/gtg/transition_table_test.rb b/actionpack/test/journey/gtg/transition_table_test.rb index 23b05cc5f6..4c8b5032eb 100644 --- a/actionpack/test/journey/gtg/transition_table_test.rb +++ b/actionpack/test/journey/gtg/transition_table_test.rb @@ -95,7 +95,7 @@ module ActionDispatch parser = Journey::Parser.new paths.map { |x| ast = parser.parse x - ast.each { |n| n.memo = ast} + ast.each { |n| n.memo = ast } ast } end diff --git a/actionpack/test/journey/nfa/simulator_test.rb b/actionpack/test/journey/nfa/simulator_test.rb index 918b971fec..183c892a53 100644 --- a/actionpack/test/journey/nfa/simulator_test.rb +++ b/actionpack/test/journey/nfa/simulator_test.rb @@ -49,7 +49,7 @@ module ActionDispatch parser = Journey::Parser.new asts = paths.map { |x| ast = parser.parse x - ast.each { |n| n.memo = ast} + ast.each { |n| n.memo = ast } ast } diff --git a/actionpack/test/journey/path/pattern_test.rb b/actionpack/test/journey/path/pattern_test.rb index 224ab689fc..d61a8c023a 100644 --- a/actionpack/test/journey/path/pattern_test.rb +++ b/actionpack/test/journey/path/pattern_test.rb @@ -194,7 +194,7 @@ module ActionDispatch end def test_to_regexp_with_strexp - path = Pattern.build("/:controller", { }, SEPARATORS, true) + path = Pattern.build("/:controller", {}, SEPARATORS, true) x = %r{\A/([^/.?]+)\Z} assert_equal(x.source, path.source) diff --git a/actionpack/test/journey/route_test.rb b/actionpack/test/journey/route_test.rb index 886cf857e8..b6414fd101 100644 --- a/actionpack/test/journey/route_test.rb +++ b/actionpack/test/journey/route_test.rb @@ -34,7 +34,7 @@ module ActionDispatch def test_ip_address path = Path::Pattern.from_string "/messages/:id(.:format)" - route = Route.build("name", nil, path, {ip: "192.168.1.1"}, [], + route = Route.build("name", nil, path, { ip: "192.168.1.1" }, [], controller: "foo", action: "bar") assert_equal "192.168.1.1", route.ip end @@ -57,7 +57,7 @@ module ActionDispatch def test_connects_all_match path = Path::Pattern.from_string "/:controller(/:action(/:id(.:format)))" - route = Route.build("name", nil, path, {action: "bar"}, [], controller: "foo") + route = Route.build("name", nil, path, { action: "bar" }, [], controller: "foo") assert_equal "/foo/bar/10", route.format( controller: "foo", @@ -67,28 +67,28 @@ module ActionDispatch def test_extras_are_not_included_if_optional path = Path::Pattern.from_string "/page/:id(/:action)" - route = Route.build("name", nil, path, { }, [], action: "show") + route = Route.build("name", nil, path, {}, [], action: "show") assert_equal "/page/10", route.format(id: 10) end def test_extras_are_not_included_if_optional_with_parameter path = Path::Pattern.from_string "(/sections/:section)/pages/:id" - route = Route.build("name", nil, path, { }, [], action: "show") + route = Route.build("name", nil, path, {}, [], action: "show") assert_equal "/pages/10", route.format(id: 10) end def test_extras_are_not_included_if_optional_parameter_is_nil path = Path::Pattern.from_string "(/sections/:section)/pages/:id" - route = Route.build("name", nil, path, { }, [], action: "show") + route = Route.build("name", nil, path, {}, [], action: "show") assert_equal "/pages/10", route.format(id: 10, section: nil) end def test_score constraints = {} - defaults = {controller: "pages", action: "show"} + defaults = { controller: "pages", action: "show" } path = Path::Pattern.from_string "/page/:id(/:action)(.:format)" specific = Route.build "name", nil, path, constraints, [:controller, :action], defaults @@ -96,7 +96,7 @@ module ActionDispatch path = Path::Pattern.from_string "/:controller(/:action(/:id))(.:format)" generic = Route.build "name", nil, path, constraints, [], {} - knowledge = {id: 20, controller: "pages", action: "show"} + knowledge = { id: 20, controller: "pages", action: "show" } routes = [specific, generic] diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb index c75475bffb..2b99637f56 100644 --- a/actionpack/test/journey/router_test.rb +++ b/actionpack/test/journey/router_test.rb @@ -58,31 +58,31 @@ module ActionDispatch get "/foo/:id", id: /\d/, anchor: false, to: "foo#bar" assert_raises(ActionController::UrlGenerationError) do - @formatter.generate(nil, { controller: "foo", action: "bar", id: "10" }, { }) + @formatter.generate(nil, { controller: "foo", action: "bar", id: "10" }, {}) end end def test_required_parts_are_verified_when_building get "/foo/:id", id: /\d+/, anchor: false, to: "foo#bar" - path, _ = @formatter.generate(nil, { controller: "foo", action: "bar", id: "10" }, { }) + path, _ = @formatter.generate(nil, { controller: "foo", action: "bar", id: "10" }, {}) assert_equal "/foo/10", path assert_raises(ActionController::UrlGenerationError) do - @formatter.generate(nil, { id: "aa" }, { }) + @formatter.generate(nil, { id: "aa" }, {}) end end def test_only_required_parts_are_verified get "/foo(/:id)", id: /\d/, to: "foo#bar" - path, _ = @formatter.generate(nil, { controller: "foo", action: "bar", id: "10" }, { }) + path, _ = @formatter.generate(nil, { controller: "foo", action: "bar", id: "10" }, {}) assert_equal "/foo/10", path - path, _ = @formatter.generate(nil, { controller: "foo", action: "bar" }, { }) + path, _ = @formatter.generate(nil, { controller: "foo", action: "bar" }, {}) assert_equal "/foo", path - path, _ = @formatter.generate(nil, { controller: "foo", action: "bar", id: "aa" }, { }) + path, _ = @formatter.generate(nil, { controller: "foo", action: "bar", id: "aa" }, {}) assert_equal "/foo/aa", path end @@ -91,7 +91,7 @@ module ActionDispatch get "/foo/:id", as: route_name, id: /\d+/, to: "foo#bar" error = assert_raises(ActionController::UrlGenerationError) do - @formatter.generate(route_name, { }, { }) + @formatter.generate(route_name, {}, {}) end assert_match(/missing required keys: \[:id\]/, error.message) @@ -101,7 +101,7 @@ module ActionDispatch route_name = "gorby_thunderhorse" error = assert_raises(ActionController::UrlGenerationError) do - @formatter.generate(route_name, { }, { }) + @formatter.generate(route_name, {}, {}) end assert_no_match(/missing required keys: \[\]/, error.message) @@ -130,12 +130,12 @@ module ActionDispatch env = rails_env "PATH_INFO" => "/foo/10" router.recognize(env) do |r, params| - assert_equal({id: "10", controller: "foo", action: "bar"}, params) + assert_equal({ id: "10", controller: "foo", action: "bar" }, params) end env = rails_env "PATH_INFO" => "/foo" router.recognize(env) do |r, params| - assert_equal({id: nil, controller: "foo", action: "bar"}, params) + assert_equal({ id: nil, controller: "foo", action: "bar" }, params) end end @@ -242,9 +242,9 @@ module ActionDispatch get "/:controller(/:action)", to: "foo#bar" path, params = @formatter.generate( - nil, {id: 1, controller: "tasks", action: "show"}, {}) + nil, { id: 1, controller: "tasks", action: "show" }, {}) assert_equal "/tasks/show", path - assert_equal({id: 1}, params) + assert_equal({ id: 1 }, params) end def test_generate_escapes @@ -277,7 +277,7 @@ module ActionDispatch relative_url_root: nil }, {}) assert_equal "/tasks/show", path - assert_equal({id: 1, relative_url_root: nil}, params) + assert_equal({ id: 1, relative_url_root: nil }, params) end def test_generate_missing_keys_no_matches_different_format_keys @@ -297,7 +297,7 @@ module ActionDispatch } request_parameters = primarty_parameters.merge(redirection_parameters).merge(missing_parameters) - message = "No route matches #{Hash[request_parameters.sort_by{|k,v|k.to_s}].inspect} missing required keys: #{[missing_key.to_sym].inspect}" + message = "No route matches #{Hash[request_parameters.sort_by { |k,v|k.to_s }].inspect} missing required keys: #{[missing_key.to_sym].inspect}" error = assert_raises(ActionController::UrlGenerationError) do @formatter.generate( @@ -311,7 +311,7 @@ module ActionDispatch path, params = @formatter.generate( nil, - {controller: "tasks", id: 10}, + { controller: "tasks", id: 10 }, action: "index") assert_equal "/tasks/index/10", path assert_equal({}, params) @@ -322,7 +322,7 @@ module ActionDispatch path, params = @formatter.generate( "tasks", - {controller: "tasks"}, + { controller: "tasks" }, controller: "tasks", action: "index") assert_equal "/tasks", path assert_equal({}, params) |