diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-10-29 01:05:58 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-10-29 01:17:49 -0200 |
commit | fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2 (patch) | |
tree | 49257bdeadca12d5b167800a25d58dd50c0d6ddb /actionpack | |
parent | f81a5ffbdec6c1d748aaef02ba10a6e0d86cbf3f (diff) | |
download | rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.tar.gz rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.tar.bz2 rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.zip |
Add more rubocop rules about whitespaces
Diffstat (limited to 'actionpack')
74 files changed, 300 insertions, 300 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index a0560a8748..d339580435 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -78,7 +78,7 @@ module AbstractController # <tt>render :action => "foo"</tt> and <tt>render "foo/bar"</tt> to # <tt>render :file => "foo/bar"</tt>. # :api: plugin - def _normalize_args(action=nil, options={}) + def _normalize_args(action = nil, options = {}) if action.respond_to?(:permitted?) if action.permitted? action diff --git a/actionpack/lib/action_controller/metal/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb index 89bf60a0bb..eb636fa3f6 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/exceptions.rb b/actionpack/lib/action_controller/metal/exceptions.rb index 3761e6172b..175dd9eb9e 100644 --- a/actionpack/lib/action_controller/metal/exceptions.rb +++ b/actionpack/lib/action_controller/metal/exceptions.rb @@ -14,7 +14,7 @@ module ActionController class RoutingError < ActionControllerError #:nodoc: attr_reader :failures - def initialize(message, failures=[]) + def initialize(message, failures = []) super(message) @failures = failures end diff --git a/actionpack/lib/action_controller/metal/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb index a335bf109e..5bf0a99fe4 100644 --- a/actionpack/lib/action_controller/metal/http_authentication.rb +++ b/actionpack/lib/action_controller/metal/http_authentication.rb @@ -224,7 +224,7 @@ module ActionController # Returns the expected response for a request of +http_method+ to +uri+ with the decoded +credentials+ and the expected +password+ # Optional parameter +password_is_ha1+ is set to +true+ by default, since best practice is to store ha1 digest instead # of a plain-text password. - def expected_response(http_method, uri, credentials, password, password_is_ha1=true) + def expected_response(http_method, uri, credentials, password, password_is_ha1 = true) ha1 = password_is_ha1 ? password : ha1(credentials, password) ha2 = ::Digest::MD5.hexdigest([http_method.to_s.upcase, uri].join(":")) ::Digest::MD5.hexdigest([ha1, credentials[:nonce], credentials[:nc], credentials[:cnonce], credentials[:qop], ha2].join(":")) @@ -246,7 +246,7 @@ module ActionController def decode_credentials(header) ActiveSupport::HashWithIndifferentAccess[header.to_s.gsub(/^Digest\s+/, "").split(",").map do |pair| key, value = pair.split("=", 2) - [key.strip, value.to_s.gsub(/^"|"$/,"").delete('\'')] + [key.strip, value.to_s.gsub(/^"|"$/, "").delete('\'')] end] end @@ -314,7 +314,7 @@ module ActionController # Can be much shorter if the Stale directive is implemented. This would # allow a user to use new nonce without prompting the user again for their # username and password. - def validate_nonce(secret_key, request, value, seconds_to_timeout=5*60) + def validate_nonce(secret_key, request, value, seconds_to_timeout = 5 * 60) return false if value.nil? t = ::Base64.decode64(value).split(":").first.to_i nonce(secret_key, t) == value && (t - Time.now.to_i).abs <= seconds_to_timeout diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb index 2ede96c667..f83396ae55 100644 --- a/actionpack/lib/action_controller/metal/instrumentation.rb +++ b/actionpack/lib/action_controller/metal/instrumentation.rb @@ -46,7 +46,7 @@ module ActionController render_output end - def send_file(path, options={}) + def send_file(path, options = {}) ActiveSupport::Notifications.instrument("send_file.action_controller", options.merge(path: path)) do super diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb index 26a16104db..fed99e6c82 100644 --- a/actionpack/lib/action_controller/metal/live.rb +++ b/actionpack/lib/action_controller/metal/live.rb @@ -247,7 +247,7 @@ module ActionController # Since we're processing the view in a different thread, copy the # thread locals from the main thread to the child thread. :'( - locals.each { |k,v| t2[k] = v } + locals.each { |k, v| t2[k] = v } begin super(name) diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb index 9d1b740025..86e817fe16 100644 --- a/actionpack/lib/action_controller/metal/params_wrapper.rb +++ b/actionpack/lib/action_controller/metal/params_wrapper.rb @@ -205,7 +205,7 @@ module ActionController model = name_or_model_or_options end - opts = Options.from_hash _wrapper_options.to_h.slice(:format).merge(options) + opts = Options.from_hash _wrapper_options.to_h.slice(:format).merge(options) opts.model = model opts.klass = self diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 67365a143e..e971917ca2 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -73,7 +73,7 @@ module ActionController end # Normalize arguments by catching blocks and setting them on :update. - def _normalize_args(action=nil, options={}, &blk) #:nodoc: + def _normalize_args(action = nil, options = {}, &blk) #:nodoc: options = super options[:update] = blk if block_given? options diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index b64617d084..9c82abb640 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -680,7 +680,7 @@ module ActionController when Parameters if object.fields_for_style? hash = object.class.new - object.each { |k,v| hash[k] = yield v } + object.each { |k, v| hash[k] = yield v } hash else yield object diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index 6513a556ee..a7cdfe6a98 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -51,7 +51,7 @@ module ActionController extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) extend ::ActionController::Railties::Helpers - options.each do |k,v| + options.each do |k, v| k = "#{k}=" if respond_to?(k) send(k, v) diff --git a/actionpack/lib/action_controller/renderer.rb b/actionpack/lib/action_controller/renderer.rb index 243a54330e..3ff80e6a39 100644 --- a/actionpack/lib/action_controller/renderer.rb +++ b/actionpack/lib/action_controller/renderer.rb @@ -83,7 +83,7 @@ module ActionController private def normalize_keys(env) new_env = {} - env.each_pair { |k,v| new_env[rack_key_for(k)] = rack_value_for(k, v) } + env.each_pair { |k, v| new_env[rack_key_for(k)] = rack_value_for(k, v) } new_env end diff --git a/actionpack/lib/action_dispatch/http/parameter_filter.rb b/actionpack/lib/action_dispatch/http/parameter_filter.rb index 01fe35f5c6..889f55a52a 100644 --- a/actionpack/lib/action_dispatch/http/parameter_filter.rb +++ b/actionpack/lib/action_dispatch/http/parameter_filter.rb @@ -50,7 +50,7 @@ module ActionDispatch def initialize(regexps, deep_regexps, blocks) @regexps = regexps @deep_regexps = deep_regexps.any? ? deep_regexps : nil - @blocks = blocks + @blocks = blocks end def call(original_params, parents = []) diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index e8173e2a99..803ac52605 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -39,7 +39,7 @@ module ActionDispatch # :nodoc: super(header) end - def []=(k,v) + def []=(k, v) if @response.sending? || @response.sent? raise ActionDispatch::IllegalStateError, "header already sent" end diff --git a/actionpack/lib/action_dispatch/http/upload.rb b/actionpack/lib/action_dispatch/http/upload.rb index 9aa73c862b..61ba052e45 100644 --- a/actionpack/lib/action_dispatch/http/upload.rb +++ b/actionpack/lib/action_dispatch/http/upload.rb @@ -24,7 +24,7 @@ module ActionDispatch attr_accessor :headers def initialize(hash) # :nodoc: - @tempfile = hash[:tempfile] + @tempfile = hash[:tempfile] raise(ArgumentError, ":tempfile is required") unless @tempfile @original_filename = hash[:filename] @@ -40,7 +40,7 @@ module ActionDispatch end # Shortcut for +tempfile.read+. - def read(length=nil, buffer=nil) + def read(length = nil, buffer = nil) @tempfile.read(length, buffer) end @@ -50,7 +50,7 @@ module ActionDispatch end # Shortcut for +tempfile.close+. - def close(unlink_now=false) + def close(unlink_now = false) @tempfile.close(unlink_now) end diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 06ffa983d1..a6937d54ff 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -66,7 +66,7 @@ module ActionDispatch end def path_for(options) - path = options[:script_name].to_s.chomp("/".freeze) + path = options[:script_name].to_s.chomp("/".freeze) path << options[:path] if options.key?(:path) add_trailing_slash(path) if options[:trailing_slash] @@ -80,7 +80,7 @@ module ActionDispatch def add_params(path, params) params = { params: params } unless params.is_a?(Hash) - params.reject! { |_,v| v.to_param.nil? } + params.reject! { |_, v| v.to_param.nil? } query = params.to_query path << "?#{query}" unless query.empty? end diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index b5a8ca7262..20ff4441a0 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -48,7 +48,7 @@ module ActionDispatch unmatched_keys = (missing_keys || []) & constraints.keys missing_keys = (missing_keys || []) - unmatched_keys - 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? message << ", possible unmatched constraints: #{unmatched_keys.sort.inspect}" if unmatched_keys && !unmatched_keys.empty? diff --git a/actionpack/lib/action_dispatch/journey/gtg/builder.rb b/actionpack/lib/action_dispatch/journey/gtg/builder.rb index 9990c66627..0f8bed89bf 100644 --- a/actionpack/lib/action_dispatch/journey/gtg/builder.rb +++ b/actionpack/lib/action_dispatch/journey/gtg/builder.rb @@ -17,7 +17,7 @@ module ActionDispatch def transition_table dtrans = TransitionTable.new marked = {} - state_id = Hash.new { |h,k| h[k] = h.length } + state_id = Hash.new { |h, k| h[k] = h.length } start = firstpos(root) dstates = [start] diff --git a/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb b/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb index 0be18dc26f..beb9f1ef3b 100644 --- a/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb +++ b/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb @@ -12,7 +12,7 @@ module ActionDispatch @regexp_states = {} @string_states = {} @accepting = {} - @memos = Hash.new { |h,k| h[k] = [] } + @memos = Hash.new { |h, k| h[k] = [] } end def add_accepting(state) @@ -56,7 +56,7 @@ module ActionDispatch end def as_json(options = nil) - simple_regexp = Hash.new { |h,k| h[k] = {} } + simple_regexp = Hash.new { |h, k| h[k] = {} } @regexp_states.each do |from, hash| hash.each do |re, to| diff --git a/actionpack/lib/action_dispatch/journey/nfa/builder.rb b/actionpack/lib/action_dispatch/journey/nfa/builder.rb index 19e5752ae5..532f765094 100644 --- a/actionpack/lib/action_dispatch/journey/nfa/builder.rb +++ b/actionpack/lib/action_dispatch/journey/nfa/builder.rb @@ -36,7 +36,7 @@ module ActionDispatch def visit_OR(node) from = @i += 1 children = node.children.map { |c| visit(c) } - to = @i += 1 + to = @i += 1 children.each do |child| @tt[from, child.first] = nil diff --git a/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb b/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb index 4737adc724..543a670da0 100644 --- a/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb +++ b/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb @@ -10,7 +10,7 @@ module ActionDispatch attr_reader :memos def initialize - @table = Hash.new { |h,f| h[f] = {} } + @table = Hash.new { |h, f| h[f] = {} } @memos = {} @accepting = nil @inverted = nil diff --git a/actionpack/lib/action_dispatch/journey/route.rb b/actionpack/lib/action_dispatch/journey/route.rb index 79cd010d64..0cc8d83ac8 100644 --- a/actionpack/lib/action_dispatch/journey/route.rb +++ b/actionpack/lib/action_dispatch/journey/route.rb @@ -83,7 +83,7 @@ module ActionDispatch def requirements # needed for rails `rails routes` - @defaults.merge(path.requirements).delete_if { |_,v| + @defaults.merge(path.requirements).delete_if { |_, v| /.+?/ == v } end @@ -98,7 +98,7 @@ module ActionDispatch def score(constraints) required_keys = path.required_names - supplied_keys = constraints.map { |k,v| v && k.to_s }.compact + supplied_keys = constraints.map { |k, v| v && k.to_s }.compact return -1 unless (required_keys - supplied_keys).empty? @@ -124,7 +124,7 @@ module ActionDispatch end def required_defaults - @required_defaults ||= @defaults.dup.delete_if do |k,_| + @required_defaults ||= @defaults.dup.delete_if do |k, _| parts.include?(k) || !required_default?(k) end end diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb index d0ef549335..084ae9325e 100644 --- a/actionpack/lib/action_dispatch/journey/router.rb +++ b/actionpack/lib/action_dispatch/journey/router.rb @@ -109,9 +109,9 @@ module ActionDispatch routes.sort_by!(&:precedence) routes.map! { |r| - match_data = r.path.match(req.path_info) + match_data = r.path.match(req.path_info) path_parameters = r.defaults.dup - match_data.names.zip(match_data.captures) { |name,val| + match_data.names.zip(match_data.captures) { |name, val| path_parameters[name.to_sym] = Utils.unescape_uri(val) if val } [match_data, path_parameters, r] diff --git a/actionpack/lib/action_dispatch/journey/visitors.rb b/actionpack/lib/action_dispatch/journey/visitors.rb index 74f3c0617a..cda859cba4 100644 --- a/actionpack/lib/action_dispatch/journey/visitors.rb +++ b/actionpack/lib/action_dispatch/journey/visitors.rb @@ -22,7 +22,7 @@ module ActionDispatch @children = [] @parameters = [] - parts.each_with_index do |object,i| + parts.each_with_index do |object, i| case object when Journey::Format @children << i diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 6f4fab396a..4fc4df4463 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -332,13 +332,13 @@ module ActionDispatch def update_cookies_from_jar request_jar = @request.cookie_jar.instance_variable_get(:@cookies) - set_cookies = request_jar.reject { |k,_| @delete_cookies.key?(k) } + set_cookies = request_jar.reject { |k, _| @delete_cookies.key?(k) } @cookies.update set_cookies if set_cookies end def to_header - @cookies.map { |k,v| "#{escape(k)}=#{escape(v)}" }.join "; " + @cookies.map { |k, v| "#{escape(k)}=#{escape(v)}" }.join "; " end def handle_options(options) #:nodoc: diff --git a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb index 99dc37c568..397f0a8b92 100644 --- a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb +++ b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb @@ -127,7 +127,7 @@ module ActionDispatch File.open(full_path, "r") do |file| start = [line - 3, 0].max lines = file.each_line.drop(start).take(6) - Hash[*(start+1..(lines.count+start)).zip(lines).flatten] + Hash[*(start + 1..(lines.count + start)).zip(lines).flatten] end end end diff --git a/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb b/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb index 8409109ede..57d325a9d8 100644 --- a/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb +++ b/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb @@ -63,7 +63,7 @@ module ActionDispatch # Other useful options include <tt>:key</tt>, <tt>:secure</tt> and # <tt>:httponly</tt>. class CookieStore < AbstractStore - def initialize(app, options={}) + def initialize(app, options = {}) super(app, options.merge!(cookie_only: true)) end @@ -102,7 +102,7 @@ module ActionDispatch end end - def persistent_session_id!(data, sid=nil) + def persistent_session_id!(data, sid = nil) data ||= {} data["session_id"] ||= sid || generate_sid data diff --git a/actionpack/lib/action_dispatch/request/session.rb b/actionpack/lib/action_dispatch/request/session.rb index b883ca0f61..8b98009efc 100644 --- a/actionpack/lib/action_dispatch/request/session.rb +++ b/actionpack/lib/action_dispatch/request/session.rb @@ -53,7 +53,7 @@ module ActionDispatch } end - def []=(k,v); @delegate[k] = v; end + def []=(k, v); @delegate[k] = v; end def to_hash; @delegate.dup; end def values_at(*args); @delegate.values_at(*args); end end @@ -124,7 +124,7 @@ module ActionDispatch # Returns the session as Hash. def to_hash load_for_read! - @delegate.dup.delete_if { |_,v| v.nil? } + @delegate.dup.delete_if { |_, v| v.nil? } end # Updates the session with given Hash. @@ -162,7 +162,7 @@ module ActionDispatch # :bar # end # # => :bar - def fetch(key, default=Unspecified, &block) + def fetch(key, default = Unspecified, &block) load_for_read! if default == Unspecified @delegate.fetch(key.to_s, &block) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index c412484895..b39d367f7f 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -567,7 +567,7 @@ module ActionDispatch # [:format] # Allows you to specify the default value for optional +format+ # segment or disable it by supplying +false+. - def match(path, options=nil) + def match(path, options = nil) end # Mount a Rack-based application to be used within the application. diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 4f1aaeefc8..432b9bf4c1 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -160,7 +160,7 @@ module ActionDispatch CACHE = { "path" => {}, "url" => {} } def self.get(action, type) - type = type.to_s + type = type.to_s CACHE[type].fetch(action) { build action, type } end @@ -266,7 +266,7 @@ module ActionDispatch args = [] - route = record_list.map { |parent| + route = record_list.map { |parent| case parent when Symbol, String parent.to_s @@ -304,7 +304,7 @@ module ActionDispatch private def get_method_for_class(klass) - name = @key_strategy.call klass.model_name + name = @key_strategy.call klass.model_name get_method_for_string name end diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb index 87bcceccc0..4e2318a45e 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 326329c65f..5853adb110 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -70,7 +70,7 @@ module ActionDispatch private :routes def initialize - @routes = {} + @routes = {} @path_helpers = Set.new @url_helpers = Set.new @url_helpers_module = Module.new @@ -207,7 +207,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}" @@ -646,11 +646,11 @@ module ActionDispatch # Generate the path indicated by the arguments, and return an array of # the keys that were not used to generate it. - def extra_keys(options, recall={}) + def extra_keys(options, recall = {}) generate_extras(options, recall).last end - def generate_extras(options, recall={}) + def generate_extras(options, recall = {}) route_key = options.delete :use_route path, params = generate(route_key, options, recall) return path, params.keys @@ -692,7 +692,7 @@ module ActionDispatch password = options.delete :password end - recall = options.delete(:_recall) { {} } + recall = options.delete(:_recall) { {} } original_script_name = options.delete(:original_script_name) script_name = find_script_name options diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index a2eaccd9ef..817737341c 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -50,7 +50,7 @@ module ActionDispatch # # # Asserts that the redirection matches the regular expression # assert_redirected_to %r(\Ahttp://example.org) - def assert_redirected_to(options = {}, message=nil) + def assert_redirected_to(options = {}, message = nil) assert_response(:redirect, message) return true if options === @response.location diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index e53bc6af12..454dcb9307 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -37,7 +37,7 @@ module ActionDispatch # # # Test a custom route # assert_recognizes({controller: 'items', action: 'show', id: '1'}, 'view/item1') - def assert_recognizes(expected_options, path, extras={}, msg=nil) + def assert_recognizes(expected_options, path, extras = {}, msg = nil) if path.is_a?(Hash) && path[:method].to_s == "all" [:get, :post, :put, :delete].each do |method| assert_recognizes(expected_options, path.merge(method: method), extras, msg) @@ -75,7 +75,7 @@ module ActionDispatch # # # Asserts that the generated route gives us our custom route # assert_generates "changesets/12", { controller: 'scm', action: 'show_diff', revision: "12" } - def assert_generates(expected_path, options, defaults={}, extras={}, message=nil) + def assert_generates(expected_path, options, defaults = {}, extras = {}, message = nil) if expected_path =~ %r{://} fail_on(URI::InvalidURIError, message) do uri = URI.parse(expected_path) @@ -119,7 +119,7 @@ module ActionDispatch # # # Tests a route with an HTTP method # assert_routing({ method: 'put', path: '/product/321' }, { controller: "product", action: "update", id: "321" }) - def assert_routing(path, options, defaults={}, extras={}, message=nil) + def assert_routing(path, options, defaults = {}, extras = {}, message = nil) assert_recognizes(options, path, extras, message) controller, default_controller = options[:controller], defaults[:controller] diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index e2ea96513c..101820fbb1 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -265,7 +265,7 @@ module ActionDispatch session.request(build_full_uri(path, request_env), request_env) @request_count += 1 - @request = ActionDispatch::Request.new(session.last_request.env) + @request = ActionDispatch::Request.new(session.last_request.env) response = _mock_session.last_response @response = ActionDispatch::TestResponse.from_response(response) @response.request = @request diff --git a/actionpack/test/abstract/collector_test.rb b/actionpack/test/abstract/collector_test.rb index 7fe19e6b10..1cd3526483 100644 --- a/actionpack/test/abstract/collector_test.rb +++ b/actionpack/test/abstract/collector_test.rb @@ -55,7 +55,7 @@ module AbstractController collector.js(:bar) { :baz } assert_equal [Mime[:html], [], nil], collector.responses[0] assert_equal [Mime[:text], [:foo], nil], collector.responses[1] - assert_equal [Mime[:js], [:bar]], collector.responses[2][0,2] + assert_equal [Mime[:js], [:bar]], collector.responses[2][0, 2] assert_equal :baz, collector.responses[2][2].call end end diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 6d28753947..11a9092527 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -351,7 +351,7 @@ class ResourcesController < ActionController::Base end class CommentsController < ResourcesController; end -class AccountsController < ResourcesController; end +class AccountsController < ResourcesController; end class ImagesController < ResourcesController; end # Skips the current run on Rubinius using Minitest::Assertions#skip diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 18490c7d73..fa8d9dc09a 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -58,7 +58,7 @@ class FragmentCachingTest < ActionController::TestCase def test_fragment_cache_key assert_equal "views/what a key", @controller.fragment_cache_key("what a key") assert_equal "views/test.host/fragment_caching_test/some_action", - @controller.fragment_cache_key(controller: "fragment_caching_test",action: "some_action") + @controller.fragment_cache_key(controller: "fragment_caching_test", action: "some_action") end def test_read_fragment_with_caching_enabled diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index a34878cee8..e0fa1fbab8 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -506,20 +506,20 @@ class FilterTest < ActionController::TestCase private def filter_one - @filters ||= [] - @filters << "filter_one" + @filters ||= [] + @filters << "filter_one" end def action_two - @filters << "action_two" + @filters << "action_two" end def non_yielding_action - @filters << "it didn't yield" + @filters << "it didn't yield" end def action_three - @filters << "action_three" + @filters << "action_three" end end @@ -911,7 +911,7 @@ class ControllerWithFilterInstance < PostsController end class ControllerWithProcFilter < PostsController - around_action(only: :no_raise) do |c,b| + around_action(only: :no_raise) do |c, b| c.instance_variable_set(:"@before", true) b.call c.instance_variable_set(:"@after", true) @@ -961,34 +961,34 @@ class YieldingAroundFiltersTest < ActionController::TestCase def test_base controller = PostsController - assert_nothing_raised { test_process(controller,"no_raise") } - assert_nothing_raised { test_process(controller,"raises_before") } - assert_nothing_raised { test_process(controller,"raises_after") } - assert_nothing_raised { test_process(controller,"no_action") } + assert_nothing_raised { test_process(controller, "no_raise") } + assert_nothing_raised { test_process(controller, "raises_before") } + assert_nothing_raised { test_process(controller, "raises_after") } + assert_nothing_raised { test_process(controller, "no_action") } end def test_with_symbol controller = ControllerWithSymbolAsFilter - assert_nothing_raised { test_process(controller,"no_raise") } - assert_raise(Before) { test_process(controller,"raises_before") } - assert_raise(After) { test_process(controller,"raises_after") } - assert_nothing_raised { test_process(controller,"no_raise") } + assert_nothing_raised { test_process(controller, "no_raise") } + assert_raise(Before) { test_process(controller, "raises_before") } + assert_raise(After) { test_process(controller, "raises_after") } + assert_nothing_raised { test_process(controller, "no_raise") } end def test_with_class controller = ControllerWithFilterClass - assert_nothing_raised { test_process(controller,"no_raise") } - assert_raise(After) { test_process(controller,"raises_after") } + assert_nothing_raised { test_process(controller, "no_raise") } + assert_raise(After) { test_process(controller, "raises_after") } end def test_with_instance controller = ControllerWithFilterInstance - assert_nothing_raised { test_process(controller,"no_raise") } - assert_raise(After) { test_process(controller,"raises_after") } + assert_nothing_raised { test_process(controller, "no_raise") } + assert_raise(After) { test_process(controller, "raises_after") } end def test_with_proc - test_process(ControllerWithProcFilter,"no_raise") + test_process(ControllerWithProcFilter, "no_raise") assert @controller.instance_variable_get(:@before) assert @controller.instance_variable_get(:@after) end @@ -997,25 +997,25 @@ class YieldingAroundFiltersTest < ActionController::TestCase controller = ControllerWithNestedFilters assert_nothing_raised do begin - test_process(controller,"raises_both") + test_process(controller, "raises_both") rescue Before, After end end assert_raise Before do begin - test_process(controller,"raises_both") + test_process(controller, "raises_both") rescue After end end end def test_action_order_with_all_action_types - test_process(ControllerWithAllTypesOfFilters,"no_raise") + test_process(ControllerWithAllTypesOfFilters, "no_raise") assert_equal "before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)", @controller.instance_variable_get(:@ran_filter).join(" ") end def test_action_order_with_skip_action_method - test_process(ControllerWithTwoLessFilters,"no_raise") + test_process(ControllerWithTwoLessFilters, "no_raise") assert_equal "before around (before yield) around (after yield)", @controller.instance_variable_get(:@ran_filter).join(" ") end diff --git a/actionpack/test/controller/flash_hash_test.rb b/actionpack/test/controller/flash_hash_test.rb index 32f0db71f5..6b3abdd5be 100644 --- a/actionpack/test/controller/flash_hash_test.rb +++ b/actionpack/test/controller/flash_hash_test.rb @@ -102,8 +102,8 @@ module ActionDispatch @hash["foo"] = "bar" things = [] - @hash.each do |k,v| - things << [k,v] + @hash.each do |k, v| + things << [k, v] end assert_equal([%w{ hello world }, %w{ foo bar }].sort, things.sort) diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb index 343b7b643d..0b59e123d7 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" @@ -180,7 +180,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase test "authentication request with password stored as ha1 digest hash" do @request.env["HTTP_AUTHORIZATION"] = encode_credentials(username: "dhh", - password: ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":")), + password: ::Digest::MD5::hexdigest(["dhh", "SuperSecret", "secret"].join(":")), password_is_ha1: true) get :display diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 67a42989c2..8f8fc64dbd 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -273,7 +273,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 @@ -283,14 +283,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 @@ -302,14 +302,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 @@ -916,7 +916,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/new_base/render_streaming_test.rb b/actionpack/test/controller/new_base/render_streaming_test.rb index 5cd8f82323..64b799f826 100644 --- a/actionpack/test/controller/new_base/render_streaming_test.rb +++ b/actionpack/test/controller/new_base/render_streaming_test.rb @@ -104,7 +104,7 @@ module RenderStreaming assert_equal nil, headers["Transfer-Encoding"] end - def assert_streaming!(cache="no-cache") + def assert_streaming!(cache = "no-cache") assert_status 200 assert_equal nil, headers["Content-Length"] assert_equal "chunked", headers["Transfer-Encoding"] diff --git a/actionpack/test/controller/parameters/mutators_test.rb b/actionpack/test/controller/parameters/mutators_test.rb index e060e5180f..e61bbdbe13 100644 --- a/actionpack/test/controller/parameters/mutators_test.rb +++ b/actionpack/test/controller/parameters/mutators_test.rb @@ -45,11 +45,11 @@ class ParametersMutatorsTest < ActiveSupport::TestCase test "keep_if retains permitted status" do @params.permit! - assert @params.keep_if { |k,v| k == "person" }.permitted? + assert @params.keep_if { |k, v| k == "person" }.permitted? end test "keep_if retains unpermitted status" do - assert_not @params.keep_if { |k,v| k == "person" }.permitted? + assert_not @params.keep_if { |k, v| k == "person" }.permitted? end test "reject! retains permitted status" do diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb index 728d8e1279..1cb7173aa0 100644 --- a/actionpack/test/controller/parameters/parameters_permit_test.rb +++ b/actionpack/test/controller/parameters/parameters_permit_test.rb @@ -28,7 +28,7 @@ class ParametersPermitTest < ActiveSupport::TestCase end def walk_permitted(params) - params.each do |k,v| + params.each do |k, v| case v when ActionController::Parameters walk_permitted v @@ -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 @@ -322,8 +322,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/render_json_test.rb b/actionpack/test/controller/render_json_test.rb index 213829bd9e..79552ec8f1 100644 --- a/actionpack/test/controller/render_json_test.rb +++ b/actionpack/test/controller/render_json_test.rb @@ -5,7 +5,7 @@ require "pathname" class RenderJsonTest < ActionController::TestCase class JsonRenderable - def as_json(options={}) + def as_json(options = {}) hash = { a: :b, c: :d, e: :f } hash.except!(*options[:except]) if options[:except] hash diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 76139d59e2..0c0f18f200 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -368,7 +368,7 @@ class ExpiresInRenderTest < ActionController::TestCase end def test_date_header_when_expires_in - time = Time.mktime(2011,10,30) + time = Time.mktime(2011, 10, 30) Time.stub :now, time do get :conditional_hello_with_expires_in assert_equal Time.now.httpdate, @response.headers["Date"] diff --git a/actionpack/test/controller/renderers_test.rb b/actionpack/test/controller/renderers_test.rb index 122f5be549..ccc700d79c 100644 --- a/actionpack/test/controller/renderers_test.rb +++ b/actionpack/test/controller/renderers_test.rb @@ -10,7 +10,7 @@ class RenderersTest < ActionController::TestCase end end class JsonRenderable - def as_json(options={}) + def as_json(options = {}) hash = { a: :b, c: :d, e: :f } hash.except!(*options[:except]) if options[:except] hash diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index b572e7e8d5..0b3dc6c41f 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -27,7 +27,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 } + member_methods = { rss: :get, atom: :get, upload: :post, fix: :post } path_names = { new: "nuevo", rss: "canal", fix: "corrigir" } with_restful_routing :messages, @@ -792,7 +792,7 @@ class ResourcesTest < ActionController::TestCase 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 :tutor_reviews, controller: "comments", as: "reviews", name_prefix: "tutor_", path_prefix: "tutors/1/", options: { tutor_id: "1" } end end @@ -1306,7 +1306,7 @@ class ResourcesTest < ActionController::TestCase end def assert_named_route(expected, route, options) - actual = @controller.send(route, options) rescue $!.class.name + actual = @controller.send(route, options) rescue $!.class.name assert_equal expected, actual, "Error on route: #{route}(#{options.inspect})" end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 7be2ad2b28..56b39510bb 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 @@ -1931,7 +1931,7 @@ class RackMountIntegrationTests < ActiveSupport::TestCase get "clients" => "projects#index" get "ignorecase/geocode/:postalcode" => "geocode#show", :postalcode => /hx\d\d-\d[a-z]{2}/i - get "extended/geocode/:postalcode" => "geocode#show",:constraints => { + get "extended/geocode/:postalcode" => "geocode#show", :constraints => { postalcode: /# Postcode format \d{5} #Prefix (-\d{4})? #Suffix diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 8dc565ac8d..a28283f4d6 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -180,7 +180,7 @@ class SendFileTest < ActionController::TestCase "file.zip" => "application/zip", "file.unk" => "application/octet-stream", "zip" => "application/octet-stream" - }.each do |filename,expected_type| + }.each do |filename, expected_type| get __method__, params: { filename: filename } assert_equal expected_type, response.content_type end diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 33f11e67ef..55ceced30c 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -231,7 +231,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 @@ -651,7 +651,7 @@ XML 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 @@ -753,10 +753,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| diff --git a/actionpack/test/controller/url_for_integration_test.rb b/actionpack/test/controller/url_for_integration_test.rb index c7ea6c5ef6..f640e77b99 100644 --- a/actionpack/test/controller/url_for_integration_test.rb +++ b/actionpack/test/controller/url_for_integration_test.rb @@ -43,7 +43,7 @@ module ActionPack get "clients" => "projects#index" get "ignorecase/geocode/:postalcode" => "geocode#show", :postalcode => /hx\d\d-\d[a-z]{2}/i - get "extended/geocode/:postalcode" => "geocode#show",:constraints => { + get "extended/geocode/:postalcode" => "geocode#show", :constraints => { postalcode: /# Postcode format \d{5} #Prefix (-\d{4})? #Suffix @@ -73,99 +73,99 @@ module ActionPack end [ - ["/admin/users",[ { use_route: "admin_users" }]], - ["/admin/users",[ { controller: "admin/users" }]], - ["/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"]], - - ["/admin/posts",[ { controller: "admin/posts" }]], - ["/admin/posts/new",[ { controller: "admin/posts", action: "new" }]], - - ["/blog/2009",[ { controller: "posts", action: "show_date", year: 2009 }]], - ["/blog/2009/1",[ { controller: "posts", action: "show_date", year: 2009, month: 1 }]], - ["/blog/2009/1/1",[ { controller: "posts", action: "show_date", year: 2009, month: 1, day: 1 }]], - - ["/archive/2010",[ { controller: "archive", action: "index", year: "2010" }]], - ["/archive",[ { controller: "archive", action: "index" }]], - ["/archive?year=january",[ { controller: "archive", action: "index", year: "january" }]], - - ["/people",[ { controller: "people", action: "index" }]], - ["/people",[ { action: "index" }, { controller: "people", action: "index" }, "/people"]], - ["/people",[ { action: "index" }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], - ["/people",[ { controller: "people", action: "index" }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], - ["/people",[ {}, { controller: "people", action: "index" }, "/people"]], - ["/people/1",[ { controller: "people", action: "show" }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], - ["/people/new",[ { use_route: "new_person" }]], - ["/people/new",[ { controller: "people", action: "new" }]], - ["/people/1",[ { use_route: "person", id: "1" }]], - ["/people/1",[ { controller: "people", action: "show", id: "1" }]], - ["/people/1.xml",[ { controller: "people", action: "show", id: "1", format: "xml" }]], - ["/people/1",[ { controller: "people", action: "show", id: 1 }]], - ["/people/1",[ { controller: "people", action: "show", id: Model.new("1") }]], - ["/people/1",[ { action: "show", id: "1" }, { controller: "people", action: "index" }, "/people"]], - ["/people/1",[ { action: "show", id: 1 }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], - ["/people",[ { controller: "people", action: "index" }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], - ["/people/1",[ {}, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], - ["/people/1",[ { controller: "people", action: "show" }, { controller: "people", action: "index", id: "1" }, "/people/index/1"]], - ["/people/1/edit",[ { controller: "people", action: "edit", id: "1" }]], - ["/people/1/edit.xml",[ { controller: "people", action: "edit", id: "1", format: "xml" }]], - ["/people/1/edit",[ { use_route: "edit_person", id: "1" }]], - ["/people/1?legacy=true",[ { controller: "people", action: "show", id: "1", legacy: "true" }]], - ["/people?legacy=true",[ { controller: "people", action: "index", legacy: "true" }]], - - ["/id_default/2",[ { controller: "foo", action: "id_default", id: "2" }]], - ["/id_default",[ { controller: "foo", action: "id_default", id: "1" }]], - ["/id_default",[ { controller: "foo", action: "id_default", id: 1 }]], - ["/id_default",[ { controller: "foo", action: "id_default" }]], - ["/optional/bar",[ { controller: "posts", action: "index", optional: "bar" }]], - ["/posts",[ { controller: "posts", action: "index" }]], - - ["/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",[ { 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"]], - - ["/clients",[ { controller: "projects", action: "index" }]], - ["/clients?project_id=1",[ { controller: "projects", action: "index", project_id: "1" }]], - ["/clients",[ { controller: "projects", action: "index" }, { project_id: "1", controller: "project", action: "index" }, "/projects/1"]], - - ["/comment/20",[ { id: 20 }, { controller: "comments", action: "show" }, "/comments/show"]], - ["/comment/20",[ { controller: "comments", id: 20, action: "show" }]], - ["/comments/boo",[ { controller: "comments", action: "boo" }]], - - ["/ws/posts/show/1",[ { controller: "posts", action: "show", id: "1", ws: true }]], - ["/ws/posts",[ { controller: "posts", action: "index", ws: true }]], - - ["/account",[ { controller: "account", action: "subscription" }]], - ["/account/billing",[ { controller: "account", action: "billing" }]], - - ["/pages/1/notes/show/1",[ { page_id: "1", controller: "notes", action: "show", id: "1" }]], - ["/pages/1/notes/list",[ { page_id: "1", controller: "notes", action: "list" }]], - ["/pages/1/notes",[ { page_id: "1", controller: "notes", action: "index" }]], - ["/pages/1/notes",[ { page_id: "1", controller: "notes" }]], - ["/notes",[ { page_id: nil, controller: "notes" }]], - ["/notes",[ { controller: "notes" }]], - ["/notes/print",[ { controller: "notes", action: "print" }]], - ["/notes/print",[ {}, { controller: "notes", action: "print" }, "/notes/print"]], - - ["/notes/index/1",[ { controller: "notes" }, { controller: "notes", action: "index", id: "1" }, "/notes/index/1"]], - ["/notes/index/1",[ { controller: "notes" }, { controller: "notes", id: "1", action: "index" }, "/notes/index/1"]], - ["/notes/index/1",[ { action: "index" }, { controller: "notes", id: "1", action: "index" }, "/notes/index/1"]], - ["/notes/index/1",[ {}, { controller: "notes", id: "1", action: "index" }, "/notes/index/1"]], - ["/notes/show/1",[ {}, { controller: "notes", action: "show", id: "1" }, "/notes/show/1"]], - ["/posts",[ { controller: "posts" }, { controller: "notes", action: "show", id: "1" }, "/notes/show/1"]], - ["/notes/list",[ { action: "list" }, { controller: "notes", action: "show", id: "1" }, "/notes/show/1"]], - - ["/posts/ping",[ { controller: "posts", action: "ping" }]], - ["/posts/show/1",[ { controller: "posts", action: "show", id: "1" }]], - ["/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?foo=bar",[ { controller: "posts", foo: "bar" }]], + ["/admin/users", [ { use_route: "admin_users" }]], + ["/admin/users", [ { controller: "admin/users" }]], + ["/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"]], + + ["/admin/posts", [ { controller: "admin/posts" }]], + ["/admin/posts/new", [ { controller: "admin/posts", action: "new" }]], + + ["/blog/2009", [ { controller: "posts", action: "show_date", year: 2009 }]], + ["/blog/2009/1", [ { controller: "posts", action: "show_date", year: 2009, month: 1 }]], + ["/blog/2009/1/1", [ { controller: "posts", action: "show_date", year: 2009, month: 1, day: 1 }]], + + ["/archive/2010", [ { controller: "archive", action: "index", year: "2010" }]], + ["/archive", [ { controller: "archive", action: "index" }]], + ["/archive?year=january", [ { controller: "archive", action: "index", year: "january" }]], + + ["/people", [ { controller: "people", action: "index" }]], + ["/people", [ { action: "index" }, { controller: "people", action: "index" }, "/people"]], + ["/people", [ { action: "index" }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], + ["/people", [ { controller: "people", action: "index" }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], + ["/people", [ {}, { controller: "people", action: "index" }, "/people"]], + ["/people/1", [ { controller: "people", action: "show" }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], + ["/people/new", [ { use_route: "new_person" }]], + ["/people/new", [ { controller: "people", action: "new" }]], + ["/people/1", [ { use_route: "person", id: "1" }]], + ["/people/1", [ { controller: "people", action: "show", id: "1" }]], + ["/people/1.xml", [ { controller: "people", action: "show", id: "1", format: "xml" }]], + ["/people/1", [ { controller: "people", action: "show", id: 1 }]], + ["/people/1", [ { controller: "people", action: "show", id: Model.new("1") }]], + ["/people/1", [ { action: "show", id: "1" }, { controller: "people", action: "index" }, "/people"]], + ["/people/1", [ { action: "show", id: 1 }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], + ["/people", [ { controller: "people", action: "index" }, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], + ["/people/1", [ {}, { controller: "people", action: "show", id: "1" }, "/people/show/1"]], + ["/people/1", [ { controller: "people", action: "show" }, { controller: "people", action: "index", id: "1" }, "/people/index/1"]], + ["/people/1/edit", [ { controller: "people", action: "edit", id: "1" }]], + ["/people/1/edit.xml", [ { controller: "people", action: "edit", id: "1", format: "xml" }]], + ["/people/1/edit", [ { use_route: "edit_person", id: "1" }]], + ["/people/1?legacy=true", [ { controller: "people", action: "show", id: "1", legacy: "true" }]], + ["/people?legacy=true", [ { controller: "people", action: "index", legacy: "true" }]], + + ["/id_default/2", [ { controller: "foo", action: "id_default", id: "2" }]], + ["/id_default", [ { controller: "foo", action: "id_default", id: "1" }]], + ["/id_default", [ { controller: "foo", action: "id_default", id: 1 }]], + ["/id_default", [ { controller: "foo", action: "id_default" }]], + ["/optional/bar", [ { controller: "posts", action: "index", optional: "bar" }]], + ["/posts", [ { controller: "posts", action: "index" }]], + + ["/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", [ { 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"]], + + ["/clients", [ { controller: "projects", action: "index" }]], + ["/clients?project_id=1", [ { controller: "projects", action: "index", project_id: "1" }]], + ["/clients", [ { controller: "projects", action: "index" }, { project_id: "1", controller: "project", action: "index" }, "/projects/1"]], + + ["/comment/20", [ { id: 20 }, { controller: "comments", action: "show" }, "/comments/show"]], + ["/comment/20", [ { controller: "comments", id: 20, action: "show" }]], + ["/comments/boo", [ { controller: "comments", action: "boo" }]], + + ["/ws/posts/show/1", [ { controller: "posts", action: "show", id: "1", ws: true }]], + ["/ws/posts", [ { controller: "posts", action: "index", ws: true }]], + + ["/account", [ { controller: "account", action: "subscription" }]], + ["/account/billing", [ { controller: "account", action: "billing" }]], + + ["/pages/1/notes/show/1", [ { page_id: "1", controller: "notes", action: "show", id: "1" }]], + ["/pages/1/notes/list", [ { page_id: "1", controller: "notes", action: "list" }]], + ["/pages/1/notes", [ { page_id: "1", controller: "notes", action: "index" }]], + ["/pages/1/notes", [ { page_id: "1", controller: "notes" }]], + ["/notes", [ { page_id: nil, controller: "notes" }]], + ["/notes", [ { controller: "notes" }]], + ["/notes/print", [ { controller: "notes", action: "print" }]], + ["/notes/print", [ {}, { controller: "notes", action: "print" }, "/notes/print"]], + + ["/notes/index/1", [ { controller: "notes" }, { controller: "notes", action: "index", id: "1" }, "/notes/index/1"]], + ["/notes/index/1", [ { controller: "notes" }, { controller: "notes", id: "1", action: "index" }, "/notes/index/1"]], + ["/notes/index/1", [ { action: "index" }, { controller: "notes", id: "1", action: "index" }, "/notes/index/1"]], + ["/notes/index/1", [ {}, { controller: "notes", id: "1", action: "index" }, "/notes/index/1"]], + ["/notes/show/1", [ {}, { controller: "notes", action: "show", id: "1" }, "/notes/show/1"]], + ["/posts", [ { controller: "posts" }, { controller: "notes", action: "show", id: "1" }, "/notes/show/1"]], + ["/notes/list", [ { action: "list" }, { controller: "notes", action: "show", id: "1" }, "/notes/show/1"]], + + ["/posts/ping", [ { controller: "posts", action: "ping" }]], + ["/posts/show/1", [ { controller: "posts", action: "show", id: "1" }]], + ["/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?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" } } }]], diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index 8d7190365d..4b6f33c545 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -223,13 +223,13 @@ module AbstractController def test_trailing_slash add_host! options = { controller: "foo", trailing_slash: true, action: "bar", id: "33" } - assert_equal("http://www.basecamphq.com/foo/bar/33/", W.new.url_for(options) ) + 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" } - assert_equal("https://www.basecamphq.com/foo/bar/33/", W.new.url_for(options) ) + 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 @@ -238,7 +238,7 @@ module AbstractController 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)) - assert_equal "/foo/bar/33/?query=string", W.new.url_for(options.merge(query: "string",only_path: true)) + assert_equal "/foo/bar/33/?query=string", W.new.url_for(options.merge(query: "string", only_path: true)) end def test_trailing_slash_with_anchor @@ -423,7 +423,7 @@ module AbstractController first_class.default_url_options[:host] = first_host second_class.default_url_options[:host] = second_host - assert_equal first_host, first_class.default_url_options[:host] + assert_equal first_host, first_class.default_url_options[:host] assert_equal second_host, second_class.default_url_options[:host] end diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb index 6dcd62572a..af3036d448 100644 --- a/actionpack/test/dispatch/cookies_test.rb +++ b/actionpack/test/dispatch/cookies_test.rb @@ -43,7 +43,7 @@ class CookieJarTest < ActiveSupport::TestCase def test_each request.cookie_jar["foo"] = :bar list = [] - request.cookie_jar.each do |k,v| + request.cookie_jar.each do |k, v| list << [k, v] end @@ -52,7 +52,7 @@ class CookieJarTest < ActiveSupport::TestCase def test_enumerable request.cookie_jar["foo"] = :bar - actual = request.cookie_jar.map { |k,v| [k.to_s, v.to_s] } + actual = request.cookie_jar.map { |k, v| [k.to_s, v.to_s] } assert_equal [["foo", "bar"]], actual end @@ -95,17 +95,17 @@ class CookiesTest < ActionController::TestCase end def authenticate_for_fourteen_days - cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10,5) } + cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10, 5) } head :ok end def authenticate_for_fourteen_days_with_symbols - cookies[:user_name] = { value: "david", expires: Time.utc(2005, 10, 10,5) } + cookies[:user_name] = { value: "david", expires: Time.utc(2005, 10, 10, 5) } head :ok end def set_multiple_cookies - cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10,5) } + cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10, 5) } cookies["login"] = "XJ-122" head :ok end @@ -205,7 +205,7 @@ class CookiesTest < ActionController::TestCase def delete_and_set_cookie cookies.delete :user_name - cookies[:user_name] = { value: "david", expires: Time.utc(2005, 10, 10,5) } + cookies[:user_name] = { value: "david", expires: Time.utc(2005, 10, 10, 5) } head :ok end diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb index bff52f2a2b..ea477e8908 100644 --- a/actionpack/test/dispatch/debug_exceptions_test.rb +++ b/actionpack/test/dispatch/debug_exceptions_test.rb @@ -287,7 +287,7 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest test "does not show filtered parameters" do @app = DevelopmentApp - get "/", params: { "foo"=>"bar" }, headers: { "action_dispatch.show_exceptions" => true, + get "/", params: { "foo" => "bar" }, headers: { "action_dispatch.show_exceptions" => true, "action_dispatch.parameter_filter" => [:foo] } assert_response 500 assert_match(""foo"=>"[FILTERED]"", body) diff --git a/actionpack/test/dispatch/header_test.rb b/actionpack/test/dispatch/header_test.rb index 6febd5cb68..958450072e 100644 --- a/actionpack/test/dispatch/header_test.rb +++ b/actionpack/test/dispatch/header_test.rb @@ -155,8 +155,8 @@ class HeaderTest < ActiveSupport::TestCase 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 test "fetch exception" do diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb index e558efb88d..2ca03c535a 100644 --- a/actionpack/test/dispatch/mime_type_test.rb +++ b/actionpack/test/dispatch/mime_type_test.rb @@ -89,7 +89,7 @@ class MimeTypeTest < ActiveSupport::TestCase # (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1) test "parse other broken acceptlines" do accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, , pronto/1.00.00, sslvpn/1.00.00.00, */*" - expect = ["image/gif", "image/x-xbitmap", "image/jpeg","image/pjpeg", "application/x-shockwave-flash", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/msword", "pronto/1.00.00", "sslvpn/1.00.00.00", "*/*"] + expect = ["image/gif", "image/x-xbitmap", "image/jpeg", "image/pjpeg", "application/x-shockwave-flash", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/msword", "pronto/1.00.00", "sslvpn/1.00.00.00", "*/*"] assert_equal expect.map(&:to_s), Mime::Type.parse(accept).map(&:to_s) end diff --git a/actionpack/test/dispatch/reloader_test.rb b/actionpack/test/dispatch/reloader_test.rb index e74b8e40fd..db68549b84 100644 --- a/actionpack/test/dispatch/reloader_test.rb +++ b/actionpack/test/dispatch/reloader_test.rb @@ -178,7 +178,7 @@ class ReloaderTest < ActiveSupport::TestCase def test_cleanup_callbacks_are_called_on_exceptions cleaned = false assert_deprecated do - Reloader.to_cleanup { cleaned = true } + Reloader.to_cleanup { cleaned = true } end begin diff --git a/actionpack/test/dispatch/request/query_string_parsing_test.rb b/actionpack/test/dispatch/request/query_string_parsing_test.rb index 5c992be216..2499c33cef 100644 --- a/actionpack/test/dispatch/request/query_string_parsing_test.rb +++ b/actionpack/test/dispatch/request/query_string_parsing_test.rb @@ -97,7 +97,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest 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" => { "foo" => [{ "bar" => nil }] } }, "action[foo][][bar]") end def test_array_parses_without_nil @@ -114,7 +114,7 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest 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" => ["1", nil] }, "action[]=1&action[]") ensure ActionDispatch::Request::Utils.perform_deep_munge = old_perform_deep_munge end diff --git a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb index 5c7558e48d..1169bf0cdb 100644 --- a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb +++ b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb @@ -55,7 +55,7 @@ class UrlEncodedParamsParsingTest < ActionDispatch::IntegrationTest "products[second]=Pc", "=Save" ].join("&") - expected = { + expected = { "customers" => { "boston" => { "first" => { diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index 13a87b8976..2f41851598 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -581,7 +581,7 @@ class RequestCookie < BaseRequestTest # some Nokia phone browsers omit the space after the semicolon separator. # some developers have grown accustomed to using comma in cookie values. - request = stub_request("HTTP_COOKIE"=>"_session_id=c84ace847,96670c052c6ceb2451fb0f2;is_admin=yes") + request = stub_request("HTTP_COOKIE" => "_session_id=c84ace847,96670c052c6ceb2451fb0f2;is_admin=yes") assert_equal "c84ace847", request.cookies["_session_id"], request.cookies.inspect assert_equal "yes", request.cookies["is_admin"], request.cookies.inspect end @@ -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 @@ -774,8 +774,8 @@ class RequestMethod < BaseRequestTest ensure # Reset original acronym set ActiveSupport::Inflector.inflections do |inflect| - inflect.send(:instance_variable_set,"@acronyms",existing_acrnoyms) - inflect.send(:instance_variable_set,"@acronym_regex",existing_acrnoym_regex) + inflect.send(:instance_variable_set, "@acronyms", existing_acrnoyms) + inflect.send(:instance_variable_set, "@acronym_regex", existing_acrnoym_regex) 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 4e547ab7d5..400af42bac 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -131,7 +131,7 @@ class ResponseTest < ActiveSupport::TestCase def test_only_set_charset_still_defaults_to_text_html response = ActionDispatch::Response.new response.charset = "utf-16" - _,headers,_ = response.to_a + _, headers, _ = response.to_a assert_equal "text/html; charset=utf-16", headers["Content-Type"] end @@ -229,7 +229,7 @@ class ResponseTest < ActiveSupport::TestCase test "multiple 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.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) @@ -237,7 +237,7 @@ class ResponseTest < ActiveSupport::TestCase 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.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) end diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index c01065932a..92d323f292 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -1933,7 +1933,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest post :preview, on: :new end - resource :admin, path_names: { new: "novo" }, path: "administrador" do + resource :admin, path_names: { new: "novo" }, path: "administrador" do post :preview, on: :new end @@ -3736,7 +3736,7 @@ private https!(old_https) end - def verify_redirect(url, status=301) + def verify_redirect(url, status = 301) assert_equal status, @response.status assert_equal url, @response.headers["Location"] assert_equal expected_redirect_body(url), @response.body @@ -4163,7 +4163,7 @@ class TestRedirectInterpolation < ActionDispatch::IntegrationTest end private - def verify_redirect(url, status=301) + def verify_redirect(url, status = 301) assert_equal status, @response.status assert_equal url, @response.headers["Location"] assert_equal expected_redirect_body(url), @response.body @@ -4696,15 +4696,15 @@ class TestUrlGenerationErrors < ActionDispatch::IntegrationTest 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}, possible unmatched constraints: #{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/static_test.rb b/actionpack/test/dispatch/static_test.rb index aca70e180c..cdb905f298 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -143,16 +143,16 @@ module StaticTests assert_equal "Accept-Encoding", response.headers["Vary"] assert_equal "gzip", response.headers["Content-Encoding"] - response = get(file_name, "HTTP_ACCEPT_ENCODING" => "Gzip") - assert_gzip file_name, response + response = get(file_name, "HTTP_ACCEPT_ENCODING" => "Gzip") + assert_gzip file_name, response - response = get(file_name, "HTTP_ACCEPT_ENCODING" => "GZIP") - assert_gzip file_name, response + response = get(file_name, "HTTP_ACCEPT_ENCODING" => "GZIP") + assert_gzip file_name, response - response = get(file_name, "HTTP_ACCEPT_ENCODING" => "compress;q=0.5, gzip;q=1.0") - assert_gzip file_name, response + response = get(file_name, "HTTP_ACCEPT_ENCODING" => "compress;q=0.5, gzip;q=1.0") + assert_gzip file_name, response - response = get(file_name, "HTTP_ACCEPT_ENCODING" => "") + response = get(file_name, "HTTP_ACCEPT_ENCODING" => "") assert_not_equal "gzip", response.headers["Content-Encoding"] end @@ -166,7 +166,7 @@ module StaticTests def test_serves_gzip_with_propper_content_type_fallback file_name = "/gzip/foo.zoo" response = get(file_name, "HTTP_ACCEPT_ENCODING" => "gzip") - assert_gzip file_name, response + assert_gzip file_name, response default_response = get(file_name) # no gzip assert_equal default_response.headers["Content-Type"], response.headers["Content-Type"] @@ -269,14 +269,14 @@ class StaticTest < ActiveSupport::TestCase filename = "shared.html.erb" assert File.exist?(File.join(@root, "..", filename)) env = { - "REQUEST_METHOD"=>"GET", - "REQUEST_PATH"=>"/..%2F#{filename}", - "PATH_INFO"=>"/..%2F#{filename}", - "REQUEST_URI"=>"/..%2F#{filename}", - "HTTP_VERSION"=>"HTTP/1.1", - "SERVER_NAME"=>"localhost", - "SERVER_PORT"=>"8080", - "QUERY_STRING"=>"" + "REQUEST_METHOD" => "GET", + "REQUEST_PATH" => "/..%2F#{filename}", + "PATH_INFO" => "/..%2F#{filename}", + "REQUEST_URI" => "/..%2F#{filename}", + "HTTP_VERSION" => "HTTP/1.1", + "SERVER_NAME" => "localhost", + "SERVER_PORT" => "8080", + "QUERY_STRING" => "" } assert_equal(DummyApp.call(nil), @app.call(env)) end diff --git a/actionpack/test/dispatch/uploaded_file_test.rb b/actionpack/test/dispatch/uploaded_file_test.rb index 60d0246a68..51680216e4 100644 --- a/actionpack/test/dispatch/uploaded_file_test.rb +++ b/actionpack/test/dispatch/uploaded_file_test.rb @@ -58,25 +58,25 @@ module ActionDispatch end def test_delegates_close_to_tempfile - tf = Class.new { def close(unlink_now=false); "thunderhorse" end } + tf = Class.new { def close(unlink_now = false); "thunderhorse" end } uf = Http::UploadedFile.new(tempfile: tf.new) assert_equal "thunderhorse", uf.close end def test_close_accepts_parameter - tf = Class.new { def close(unlink_now=false); "thunderhorse: #{unlink_now}" end } + tf = Class.new { def close(unlink_now = false); "thunderhorse: #{unlink_now}" end } uf = Http::UploadedFile.new(tempfile: tf.new) assert_equal "thunderhorse: true", uf.close(true) end def test_delegates_read_to_tempfile - tf = Class.new { def read(length=nil, buffer=nil); "thunderhorse" end } + tf = Class.new { def read(length = nil, buffer = nil); "thunderhorse" end } uf = Http::UploadedFile.new(tempfile: tf.new) assert_equal "thunderhorse", uf.read end def test_delegates_read_to_tempfile_with_params - tf = Class.new { def read(length=nil, buffer=nil); [length, buffer] end } + tf = Class.new { def read(length = nil, buffer = nil); [length, buffer] end } uf = Http::UploadedFile.new(tempfile: tf.new) assert_equal %w{ thunder horse }, uf.read(*%w{ thunder horse }) end diff --git a/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb b/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb index cd0be6d1b5..18fa5cd923 100644 --- a/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +++ b/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb @@ -1,6 +1,6 @@ module SessionAutoloadTest class Foo - def initialize(bar="baz") + def initialize(bar = "baz") @bar = bar end def inspect diff --git a/actionpack/test/journey/gtg/builder_test.rb b/actionpack/test/journey/gtg/builder_test.rb index 2b314cdd4e..aa8427b265 100644 --- a/actionpack/test/journey/gtg/builder_test.rb +++ b/actionpack/test/journey/gtg/builder_test.rb @@ -5,18 +5,18 @@ module ActionDispatch module GTG class TestBuilder < ActiveSupport::TestCase def test_following_states_multi - table = tt ["a|a"] + table = tt ["a|a"] assert_equal 1, table.move([0], "a").length end def test_following_states_multi_regexp - table = tt [":a|b"] + table = tt [":a|b"] assert_equal 1, table.move([0], "fooo").length assert_equal 2, table.move([0], "b").length end def test_multi_path - table = tt ["/:a/d", "/b/c"] + table = tt ["/:a/d", "/b/c"] [ [1, "/"], @@ -38,7 +38,7 @@ module ActionDispatch /articles/:id(.:format) } - sim = NFA::Simulator.new table + sim = NFA::Simulator.new table match = sim.match "/articles/new" assert_equal 2, match.memos.length @@ -52,7 +52,7 @@ module ActionDispatch /articles/new(.:format) } - sim = NFA::Simulator.new table + sim = NFA::Simulator.new table match = sim.match "/articles/new" assert_equal 2, match.memos.length diff --git a/actionpack/test/journey/gtg/transition_table_test.rb b/actionpack/test/journey/gtg/transition_table_test.rb index 4c8b5032eb..c7315c0338 100644 --- a/actionpack/test/journey/gtg/transition_table_test.rb +++ b/actionpack/test/journey/gtg/transition_table_test.rb @@ -92,7 +92,7 @@ module ActionDispatch private def asts(paths) - parser = Journey::Parser.new + parser = Journey::Parser.new paths.map { |x| ast = parser.parse x ast.each { |n| n.memo = ast } diff --git a/actionpack/test/journey/nfa/simulator_test.rb b/actionpack/test/journey/nfa/simulator_test.rb index 183c892a53..38f99398cb 100644 --- a/actionpack/test/journey/nfa/simulator_test.rb +++ b/actionpack/test/journey/nfa/simulator_test.rb @@ -80,7 +80,7 @@ module ActionDispatch ast = Nodes::Or.new routes - nfa = Journey::NFA::Builder.new ast + nfa = Journey::NFA::Builder.new ast sim = Simulator.new nfa.transition_table md = sim.match "/articles" assert_equal [asts.first], md.memos diff --git a/actionpack/test/journey/nfa/transition_table_test.rb b/actionpack/test/journey/nfa/transition_table_test.rb index f3cf36a064..0bc6bc1cf8 100644 --- a/actionpack/test/journey/nfa/transition_table_test.rb +++ b/actionpack/test/journey/nfa/transition_table_test.rb @@ -53,10 +53,10 @@ module ActionDispatch end def test_alphabet - table = tt "a|:a" + table = tt "a|:a" assert_equal [/[^\.\/\?]+/, "a"], table.alphabet - table = tt "a|a" + table = tt "a|a" assert_equal ["a"], table.alphabet end diff --git a/actionpack/test/journey/route_test.rb b/actionpack/test/journey/route_test.rb index b6414fd101..d2a8163ffb 100644 --- a/actionpack/test/journey/route_test.rb +++ b/actionpack/test/journey/route_test.rb @@ -26,7 +26,7 @@ module ActionDispatch end def test_path_requirements_override_defaults - path = Path::Pattern.build(":name", { name: /love/ }, "/", true) + path = Path::Pattern.build(":name", { name: /love/ }, "/", true) defaults = { name: "tender" } route = Route.build("name", nil, path, {}, [], defaults) assert_equal(/love/, route.requirements[:name]) diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb index 7b5916eb72..f223a125a3 100644 --- a/actionpack/test/journey/router_test.rb +++ b/actionpack/test/journey/router_test.rb @@ -6,8 +6,8 @@ module ActionDispatch attr_reader :mapper, :routes, :route_set, :router def setup - @app = Routing::RouteSet::Dispatcher.new({}) - @route_set = ActionDispatch::Routing::RouteSet.new + @app = Routing::RouteSet::Dispatcher.new({}) + @route_set = ActionDispatch::Routing::RouteSet.new @routes = @route_set.router.routes @router = @route_set.router @formatter = @route_set.formatter @@ -116,7 +116,7 @@ module ActionDispatch end def test_clear_trailing_slash_from_script_name_on_root_unanchored_routes - app = lambda { |env| [200, {}, ["success!"]] } + app = lambda { |env| [200, {}, ["success!"]] } get "/weblog", to: app env = rack_env("SCRIPT_NAME" => "", "PATH_INFO" => "/weblog") @@ -233,7 +233,7 @@ module ActionDispatch nil, Hash[params], {}, - lambda { |k,v| parameterized << [k,v]; v }) + lambda { |k, v| parameterized << [k, v]; v }) assert_equal params.map(&:to_s).sort, parameterized.map(&:to_s).sort end @@ -289,15 +289,15 @@ module ActionDispatch relative_url_root: nil } redirection_parameters = { - "action"=>"show", + "action" => "show", } missing_key = "name" - missing_parameters ={ + missing_parameters = { missing_key => "task_1" } 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( @@ -338,7 +338,7 @@ module ActionDispatch route = @routes.first env = rails_env "PATH_INFO" => request_path - called = false + called = false router.recognize(env) do |r, params| assert_equal route, r @@ -358,7 +358,7 @@ module ActionDispatch get "/:segment/*splat", to: "foo#bar" env = rails_env "PATH_INFO" => request_path - called = false + called = false route = @routes.first router.recognize(env) do |r, params| @@ -395,7 +395,7 @@ module ActionDispatch get "/books(/:action(.:format))", controller: "books" route = @routes.first - env = rails_env "PATH_INFO" => "/books/list.rss" + env = rails_env "PATH_INFO" => "/books/list.rss" expected = { controller: "books", action: "list", format: "rss" } called = false router.recognize(env) do |r, params| @@ -427,7 +427,7 @@ module ActionDispatch get "/books(/:action(.:format))", to: "foo#bar" env = rails_env "PATH_INFO" => "/books/list.rss", - "REQUEST_METHOD" => "HEAD" + "REQUEST_METHOD" => "HEAD" called = false router.recognize(env) do |r, params| diff --git a/actionpack/test/journey/routes_test.rb b/actionpack/test/journey/routes_test.rb index ca735ea022..d8db5ffad1 100644 --- a/actionpack/test/journey/routes_test.rb +++ b/actionpack/test/journey/routes_test.rb @@ -6,7 +6,7 @@ module ActionDispatch attr_reader :routes, :mapper def setup - @route_set = ActionDispatch::Routing::RouteSet.new + @route_set = ActionDispatch::Routing::RouteSet.new @routes = @route_set.router.routes @router = @route_set.router @mapper = ActionDispatch::Routing::Mapper.new @route_set diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb index ce9522d12a..046b4167bb 100644 --- a/actionpack/test/lib/controller/fake_models.rb +++ b/actionpack/test/lib/controller/fake_models.rb @@ -6,7 +6,7 @@ class Customer < Struct.new(:name, :id) undef_method :to_json - def to_xml(options={}) + def to_xml(options = {}) if options[:builder] options[:builder].name name else @@ -14,7 +14,7 @@ class Customer < Struct.new(:name, :id) end end - def to_js(options={}) + def to_js(options = {}) "name: #{name.inspect}" end alias :to_text :to_js |