fixes remaining RuboCop issues [Vipul A M, Xavier Noria]
This commit is contained in:
parent
8c402ef425
commit
bb1ecdcc67
|
@ -21,7 +21,7 @@ namespace :test do
|
|||
task :isolated do
|
||||
Dir.glob("test/**/*_test.rb").all? do |file|
|
||||
sh(Gem.ruby, "-w", "-Ilib:test", file)
|
||||
end or raise "Failures"
|
||||
end || raise("Failures")
|
||||
end
|
||||
|
||||
task :integration do
|
||||
|
|
|
@ -89,7 +89,7 @@ module ActionCable
|
|||
code ||= 1000
|
||||
reason ||= ""
|
||||
|
||||
unless code == 1000 or (code >= 3000 and code <= 4999)
|
||||
unless code == 1000 || (code >= 3000 && code <= 4999)
|
||||
raise ArgumentError, "Failed to execute 'close' on WebSocket: " +
|
||||
"The code must be either 1000, or between 3000 and 4999. " +
|
||||
"#{code} is neither."
|
||||
|
|
|
@ -18,6 +18,6 @@ namespace :test do
|
|||
task :isolated do
|
||||
Dir.glob("test/**/*_test.rb").all? do |file|
|
||||
sh(Gem.ruby, "-w", "-Ilib:test", file)
|
||||
end or raise "Failures"
|
||||
end || raise("Failures")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace :test do
|
|||
task :isolated do
|
||||
test_files.all? do |file|
|
||||
sh(Gem.ruby, "-w", "-Ilib:test", file)
|
||||
end or raise "Failures"
|
||||
end || raise("Failures")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ module ActionController #:nodoc:
|
|||
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
|
||||
# for the Cache-Control header spec.
|
||||
def send_file(path, options = {}) #:doc:
|
||||
raise MissingFile, "Cannot read file #{path}" unless File.file?(path) and File.readable?(path)
|
||||
raise MissingFile, "Cannot read file #{path}" unless File.file?(path) && File.readable?(path)
|
||||
|
||||
options[:filename] ||= File.basename(path) unless options[:url_based_filename]
|
||||
send_file_headers! options
|
||||
|
|
|
@ -61,7 +61,7 @@ module ActionController
|
|||
|
||||
def method_for_action(action_name)
|
||||
super || if template_exists?(action_name.to_s, _prefixes)
|
||||
"default_render"
|
||||
"default_render"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ module ActionController
|
|||
`fallback_location` represents the location to use if the request has
|
||||
no HTTP referer information.
|
||||
MESSAGE
|
||||
request.headers["Referer"] or raise RedirectBackError
|
||||
request.headers["Referer"] || raise(RedirectBackError)
|
||||
when Proc
|
||||
_compute_redirect_to_location request, options.call
|
||||
else
|
||||
|
|
|
@ -19,7 +19,7 @@ module ActionDispatch
|
|||
|
||||
# Get a session from the cache.
|
||||
def find_session(env, sid)
|
||||
unless sid and session = @cache.read(cache_key(sid))
|
||||
unless sid && (session = @cache.read(cache_key(sid)))
|
||||
sid, session = generate_sid, {}
|
||||
end
|
||||
[sid, session]
|
||||
|
|
|
@ -1607,7 +1607,7 @@ module ActionDispatch
|
|||
def root(path, options = {})
|
||||
if path.is_a?(String)
|
||||
options[:to] = path
|
||||
elsif path.is_a?(Hash) and options.empty?
|
||||
elsif path.is_a?(Hash) && options.empty?
|
||||
options = path
|
||||
else
|
||||
raise ArgumentError, "must be called with a path and/or options"
|
||||
|
|
|
@ -596,8 +596,8 @@ module ActionDispatch
|
|||
# :controller, :action or :id is not found, don't pull any
|
||||
# more keys from the recall.
|
||||
def normalize_controller_action_id!
|
||||
use_recall_for(:controller) or return
|
||||
use_recall_for(:action) or return
|
||||
use_recall_for(:controller) || return
|
||||
use_recall_for(:action) || return
|
||||
use_recall_for(:id)
|
||||
end
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ class TestController < ActionController::Base
|
|||
end
|
||||
|
||||
def head_and_return
|
||||
head :ok and return
|
||||
head(:ok) && return
|
||||
raise "should not reach this line"
|
||||
end
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
|
|||
def test_class_and_lambda_constraints
|
||||
subdomain = Class.new {
|
||||
def matches?(request)
|
||||
request.subdomain.present? and request.subdomain != "clients"
|
||||
request.subdomain.present? && request.subdomain != "clients"
|
||||
end
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
|
|||
def test_lambda_constraints
|
||||
rs.draw do
|
||||
get "/", constraints: lambda { |req|
|
||||
req.subdomain.present? and req.subdomain != "clients" },
|
||||
req.subdomain.present? && req.subdomain != "clients" },
|
||||
to: lambda { |env| [200, {}, %w{default}] }
|
||||
|
||||
get "/", constraints: lambda { |req|
|
||||
|
|
|
@ -3672,12 +3672,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
|||
def test_multiple_roots
|
||||
draw do
|
||||
namespace :foo do
|
||||
root "pages#index", constraints: { host: 'www.example.com' }
|
||||
root "admin/pages#index", constraints: { host: 'admin.example.com' }
|
||||
root "pages#index", constraints: { host: "www.example.com" }
|
||||
root "admin/pages#index", constraints: { host: "admin.example.com" }
|
||||
end
|
||||
|
||||
root "pages#index", constraints: { host: 'www.example.com' }
|
||||
root "admin/pages#index", constraints: { host: 'admin.example.com' }
|
||||
root "pages#index", constraints: { host: "www.example.com" }
|
||||
root "admin/pages#index", constraints: { host: "admin.example.com" }
|
||||
end
|
||||
|
||||
get "http://www.example.com/foo"
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace :test do
|
|||
task :isolated do
|
||||
Dir.glob("test/{actionpack,activerecord,template}/**/*_test.rb").all? do |file|
|
||||
sh(Gem.ruby, "-w", "-Ilib:test", file)
|
||||
end or raise "Failures"
|
||||
end || raise("Failures")
|
||||
end
|
||||
|
||||
Rake::TestTask.new(:template) do |t|
|
||||
|
|
|
@ -37,7 +37,7 @@ module ActionView
|
|||
def capture(*args)
|
||||
value = nil
|
||||
buffer = with_output_buffer { value = yield(*args) }
|
||||
if string = buffer.presence || value and string.is_a?(String)
|
||||
if (string = buffer.presence || value) && string.is_a?(String)
|
||||
ERB::Util.html_escape string
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1287,7 +1287,7 @@ module ActionView
|
|||
@object_name, @object, @template, @options = object_name, object, template, options
|
||||
@default_options = @options ? @options.slice(:index, :namespace) : {}
|
||||
if @object_name.to_s.match(/\[\]$/)
|
||||
if object ||= @template.instance_variable_get("@#{Regexp.last_match.pre_match}") and object.respond_to?(:to_param)
|
||||
if (object ||= @template.instance_variable_get("@#{Regexp.last_match.pre_match}")) && object.respond_to?(:to_param)
|
||||
@auto_index = object.to_param
|
||||
else
|
||||
raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}"
|
||||
|
|
|
@ -284,12 +284,12 @@ class TagHelperTest < ActionView::TestCase
|
|||
|
||||
def test_tag_does_not_honor_html_safe_double_quotes_as_attributes
|
||||
assert_dom_equal '<p title=""">content</p>',
|
||||
content_tag('p', "content", title: '"'.html_safe)
|
||||
content_tag("p", "content", title: '"'.html_safe)
|
||||
end
|
||||
|
||||
def test_data_tag_does_not_honor_html_safe_double_quotes_as_attributes
|
||||
assert_dom_equal '<p data-title=""">content</p>',
|
||||
content_tag('p', "content", data: { title: '"'.html_safe })
|
||||
content_tag("p", "content", data: { title: '"'.html_safe })
|
||||
end
|
||||
|
||||
def test_skip_invalid_escaped_attributes
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace :test do
|
|||
dir = File.dirname(__FILE__)
|
||||
Dir.glob("#{dir}/test/cases/**/*_test.rb").all? do |file|
|
||||
sh(Gem.ruby, "-w", "-I#{dir}/lib", "-I#{dir}/test", file)
|
||||
end or raise "Failures"
|
||||
end || raise("Failures")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ module ActiveJob
|
|||
end
|
||||
|
||||
def serialized_global_id?(hash)
|
||||
hash.size == 1 and hash.include?(GLOBALID_KEY)
|
||||
hash.size == 1 && hash.include?(GLOBALID_KEY)
|
||||
end
|
||||
|
||||
def deserialize_global_id(hash)
|
||||
|
|
|
@ -58,7 +58,7 @@ class ExceptionsTest < ActiveJob::TestCase
|
|||
|
||||
test "custom handling of job that exceeds retry attempts" do
|
||||
perform_enqueued_jobs do
|
||||
RetryJob.perform_later 'CustomCatchError', 6
|
||||
RetryJob.perform_later "CustomCatchError", 6
|
||||
assert_equal "Dealt with a job that failed to retry in a custom way after 6 attempts", JobBuffer.last_value
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,6 @@ namespace :test do
|
|||
task :isolated do
|
||||
Dir.glob("#{dir}/test/**/*_test.rb").all? do |file|
|
||||
sh(Gem.ruby, "-w", "-I#{dir}/lib", "-I#{dir}/test", file)
|
||||
end or raise "Failures"
|
||||
end || raise("Failures")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,7 +67,7 @@ end
|
|||
|x| x.include?("/adapters/")
|
||||
} + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file|
|
||||
sh(Gem.ruby, "-w" ,"-Itest", file)
|
||||
end or raise "Failures"
|
||||
end || raise("Failures")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,7 +80,7 @@ module ActiveRecord
|
|||
# If there's nothing in the database and @target has no new records
|
||||
# we are certain the current target is an empty array. This is a
|
||||
# documented side-effect of the method that may avoid an extra SELECT.
|
||||
@target ||= [] and loaded! if count == 0
|
||||
(@target ||= []) && loaded! if count == 0
|
||||
|
||||
[association_scope.limit_value, count].compact.min
|
||||
end
|
||||
|
|
|
@ -228,8 +228,8 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def find_reflection(klass, name)
|
||||
klass._reflect_on_association(name) or
|
||||
raise ConfigurationError, "Can't join '#{ klass.name }' to association named '#{ name }'; perhaps you misspelled it?"
|
||||
klass._reflect_on_association(name) ||
|
||||
raise(ConfigurationError, "Can't join '#{klass.name}' to association named '#{name}'; perhaps you misspelled it?")
|
||||
end
|
||||
|
||||
def build(associations, base_klass)
|
||||
|
|
|
@ -970,8 +970,8 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def foreign_key_for!(from_table, options_or_to_table = {}) # :nodoc:
|
||||
foreign_key_for(from_table, options_or_to_table) or \
|
||||
raise ArgumentError, "Table '#{from_table}' has no foreign key for #{options_or_to_table}"
|
||||
foreign_key_for(from_table, options_or_to_table) || \
|
||||
raise(ArgumentError, "Table '#{from_table}' has no foreign key for #{options_or_to_table}")
|
||||
end
|
||||
|
||||
def foreign_key_column_for(table_name) # :nodoc:
|
||||
|
|
|
@ -360,7 +360,7 @@ module ActiveRecord
|
|||
|
||||
# Resets the sequence of a table's primary key to the maximum value.
|
||||
def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
|
||||
unless pk and sequence
|
||||
unless pk && sequence
|
||||
default_pk, default_sequence = pk_and_sequence_for(table)
|
||||
|
||||
pk ||= default_pk
|
||||
|
@ -403,7 +403,7 @@ module ActiveRecord
|
|||
AND dep.refobjid = '#{quote_table_name(table)}'::regclass
|
||||
end_sql
|
||||
|
||||
if result.nil? or result.empty?
|
||||
if result.nil? || result.empty?
|
||||
result = query(<<-end_sql, "SCHEMA")[0]
|
||||
SELECT attr.attname, nsp.nspname,
|
||||
CASE
|
||||
|
|
|
@ -109,7 +109,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def connection_pool
|
||||
connection_handler.retrieve_connection_pool(connection_specification_name) or raise ConnectionNotEstablished
|
||||
connection_handler.retrieve_connection_pool(connection_specification_name) || raise(ConnectionNotEstablished)
|
||||
end
|
||||
|
||||
def retrieve_connection
|
||||
|
|
|
@ -229,7 +229,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def find_by!(*args) # :nodoc:
|
||||
find_by(*args) or raise RecordNotFound.new("Couldn't find #{name}", name)
|
||||
find_by(*args) || raise(RecordNotFound.new("Couldn't find #{name}", name))
|
||||
end
|
||||
|
||||
def initialize_generated_modules # :nodoc:
|
||||
|
|
|
@ -192,8 +192,8 @@ module ActiveRecord
|
|||
|
||||
new_columns = connection.columns(TestModel.table_name)
|
||||
|
||||
assert_not new_columns.find { |c| c.name == "age" and c.type == :integer }
|
||||
assert new_columns.find { |c| c.name == "age" and c.type == :string }
|
||||
assert_not new_columns.find { |c| c.name == "age" && c.type == :integer }
|
||||
assert new_columns.find { |c| c.name == "age" && c.type == :string }
|
||||
|
||||
old_columns = connection.columns(TestModel.table_name)
|
||||
assert old_columns.find { |c|
|
||||
|
@ -206,11 +206,11 @@ module ActiveRecord
|
|||
|
||||
assert_not new_columns.find { |c|
|
||||
default = connection.lookup_cast_type_from_column(c).deserialize(c.default)
|
||||
c.name == "approved" and c.type == :boolean and default == true
|
||||
c.name == "approved" && c.type == :boolean && default == true
|
||||
}
|
||||
assert new_columns.find { |c|
|
||||
default = connection.lookup_cast_type_from_column(c).deserialize(c.default)
|
||||
c.name == "approved" and c.type == :boolean and default == false
|
||||
c.name == "approved" && c.type == :boolean && default == false
|
||||
}
|
||||
change_column :test_models, :approved, :boolean, default: true
|
||||
end
|
||||
|
|
|
@ -16,6 +16,6 @@ namespace :test do
|
|||
task :isolated do
|
||||
Dir.glob("test/**/*_test.rb").all? do |file|
|
||||
sh(Gem.ruby, "-w", "-Ilib:test", file)
|
||||
end or raise "Failures"
|
||||
end || raise("Failures")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,7 +84,7 @@ module ActiveSupport
|
|||
|
||||
def create_composition_map
|
||||
@ucd.codepoints.each do |_, cp|
|
||||
if !cp.nil? and cp.combining_class == 0 and cp.decomp_type.nil? and !cp.decomp_mapping.nil? and cp.decomp_mapping.length == 2 and @ucd.codepoints[cp.decomp_mapping[0]].combining_class == 0 and !@ucd.composition_exclusion.include?(cp.code)
|
||||
if !cp.nil? && cp.combining_class == 0 && cp.decomp_type.nil? && !cp.decomp_mapping.nil? && cp.decomp_mapping.length == 2 && @ucd.codepoints[cp.decomp_mapping[0]].combining_class == 0 && !@ucd.composition_exclusion.include?(cp.code)
|
||||
@ucd.composition_map[cp.decomp_mapping[0]] ||= {}
|
||||
@ucd.composition_map[cp.decomp_mapping[0]][cp.decomp_mapping[1]] = cp.code
|
||||
end
|
||||
|
|
|
@ -371,7 +371,7 @@ module ActiveSupport #:nodoc:
|
|||
load_args = ["#{file_name}.rb"]
|
||||
load_args << const_path unless const_path.nil?
|
||||
|
||||
if !warnings_on_first_load or history.include?(expanded)
|
||||
if !warnings_on_first_load || history.include?(expanded)
|
||||
result = load_file(*load_args)
|
||||
else
|
||||
enable_warnings { result = load_file(*load_args) }
|
||||
|
|
|
@ -89,25 +89,25 @@ module ActiveSupport
|
|||
|
||||
should_break =
|
||||
# GB3. CR X LF
|
||||
if previous == database.boundary[:cr] and current == database.boundary[:lf]
|
||||
if previous == database.boundary[:cr] && current == database.boundary[:lf]
|
||||
false
|
||||
# GB4. (Control|CR|LF) ÷
|
||||
elsif previous and in_char_class?(previous, [:control,:cr,:lf])
|
||||
elsif previous && in_char_class?(previous, [:control,:cr,:lf])
|
||||
true
|
||||
# GB5. ÷ (Control|CR|LF)
|
||||
elsif in_char_class?(current, [:control,:cr,:lf])
|
||||
true
|
||||
# GB6. L X (L|V|LV|LVT)
|
||||
elsif database.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt])
|
||||
elsif database.boundary[:l] === previous && in_char_class?(current, [:l,:v,:lv,:lvt])
|
||||
false
|
||||
# GB7. (LV|V) X (V|T)
|
||||
elsif in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t])
|
||||
elsif in_char_class?(previous, [:lv,:v]) && in_char_class?(current, [:v,:t])
|
||||
false
|
||||
# GB8. (LVT|T) X (T)
|
||||
elsif in_char_class?(previous, [:lvt,:t]) and database.boundary[:t] === current
|
||||
elsif in_char_class?(previous, [:lvt,:t]) && database.boundary[:t] === current
|
||||
false
|
||||
# GB8a. Regional_Indicator X Regional_Indicator
|
||||
elsif database.boundary[:regional_indicator] === previous and database.boundary[:regional_indicator] === current
|
||||
elsif database.boundary[:regional_indicator] === previous && database.boundary[:regional_indicator] === current
|
||||
false
|
||||
# GB9. X Extend
|
||||
elsif database.boundary[:extend] === current
|
||||
|
@ -158,7 +158,7 @@ module ActiveSupport
|
|||
def decompose(type, codepoints)
|
||||
codepoints.inject([]) do |decomposed, cp|
|
||||
# if it's a hangul syllable starter character
|
||||
if HANGUL_SBASE <= cp and cp < HANGUL_SLAST
|
||||
if HANGUL_SBASE <= cp && cp < HANGUL_SLAST
|
||||
sindex = cp - HANGUL_SBASE
|
||||
ncp = [] # new codepoints
|
||||
ncp << HANGUL_LBASE + sindex / HANGUL_NCOUNT
|
||||
|
@ -167,7 +167,7 @@ module ActiveSupport
|
|||
ncp << (HANGUL_TBASE + tindex) unless tindex == 0
|
||||
decomposed.concat ncp
|
||||
# if the codepoint is decomposable in with the current decomposition type
|
||||
elsif (ncp = database.codepoints[cp].decomp_mapping) and (!database.codepoints[cp].decomp_type || type == :compatibility)
|
||||
elsif (ncp = database.codepoints[cp].decomp_mapping) && (!database.codepoints[cp].decomp_type || type == :compatibility)
|
||||
decomposed.concat decompose(type, ncp.dup)
|
||||
else
|
||||
decomposed << cp
|
||||
|
@ -186,11 +186,11 @@ module ActiveSupport
|
|||
pos += 1
|
||||
lindex = starter_char - HANGUL_LBASE
|
||||
# -- Hangul
|
||||
if 0 <= lindex and lindex < HANGUL_LCOUNT
|
||||
if 0 <= lindex && lindex < HANGUL_LCOUNT
|
||||
vindex = codepoints[starter_pos+1] - HANGUL_VBASE rescue vindex = -1
|
||||
if 0 <= vindex and vindex < HANGUL_VCOUNT
|
||||
if 0 <= vindex && vindex < HANGUL_VCOUNT
|
||||
tindex = codepoints[starter_pos+2] - HANGUL_TBASE rescue tindex = -1
|
||||
if 0 <= tindex and tindex < HANGUL_TCOUNT
|
||||
if 0 <= tindex && tindex < HANGUL_TCOUNT
|
||||
j = starter_pos + 2
|
||||
eoa -= 2
|
||||
else
|
||||
|
@ -392,7 +392,7 @@ module ActiveSupport
|
|||
database.codepoints
|
||||
string.each_codepoint.map do |codepoint|
|
||||
cp = database.codepoints[codepoint]
|
||||
if cp and (ncp = cp.send(mapping)) and ncp > 0
|
||||
if cp && (ncp = cp.send(mapping)) && ncp > 0
|
||||
ncp
|
||||
else
|
||||
codepoint
|
||||
|
|
|
@ -68,7 +68,7 @@ module ActiveSupport
|
|||
|
||||
module Subscribers # :nodoc:
|
||||
def self.new(pattern, listener)
|
||||
if listener.respond_to?(:start) and listener.respond_to?(:finish)
|
||||
if listener.respond_to?(:start) && listener.respond_to?(:finish)
|
||||
subscriber = Evented.new pattern, listener
|
||||
else
|
||||
subscriber = Timed.new pattern, listener
|
||||
|
|
|
@ -33,7 +33,7 @@ class MultibyteGraphemeBreakConformanceTest < ActiveSupport::TestCase
|
|||
lines = 0
|
||||
max_test_lines = 0 # Don't limit below 21, because that's the header of the testfile
|
||||
File.open(File.join(CACHE_DIR, UNIDATA_FILE), "r") do | f |
|
||||
until f.eof? || (max_test_lines > 21 and lines > max_test_lines)
|
||||
until f.eof? || (max_test_lines > 21 && lines > max_test_lines)
|
||||
lines += 1
|
||||
line = f.gets.chomp!
|
||||
next if line.empty? || line.start_with?("#")
|
||||
|
|
|
@ -88,7 +88,7 @@ class MultibyteNormalizationConformanceTest < ActiveSupport::TestCase
|
|||
lines = 0
|
||||
max_test_lines = 0 # Don't limit below 38, because that's the header of the testfile
|
||||
File.open(File.join(CACHE_DIR, UNIDATA_FILE), "r") do | f |
|
||||
until f.eof? || (max_test_lines > 38 and lines > max_test_lines)
|
||||
until f.eof? || (max_test_lines > 38 && lines > max_test_lines)
|
||||
lines += 1
|
||||
line = f.gets.chomp!
|
||||
next if line.empty? || line.start_with?("#")
|
||||
|
|
|
@ -50,7 +50,7 @@ EOS
|
|||
|
||||
# If we exhaust the search there is no executable, this could be a
|
||||
# call to generate a new application, so restore the original cwd.
|
||||
Dir.chdir(original_cwd) and return if Pathname.new(Dir.pwd).root?
|
||||
Dir.chdir(original_cwd) && return if Pathname.new(Dir.pwd).root?
|
||||
|
||||
# Otherwise keep moving upwards in search of an executable.
|
||||
Dir.chdir("..")
|
||||
|
|
|
@ -310,9 +310,9 @@ module Rails
|
|||
|
||||
# Returns default for the option name given doing a lookup in config.
|
||||
def self.default_for_option(config, name, options, default)
|
||||
if generator_name and c = config[generator_name.to_sym] and c.key?(name)
|
||||
if generator_name && (c = config[generator_name.to_sym]) && c.key?(name)
|
||||
c[name]
|
||||
elsif base_name and c = config[base_name.to_sym] and c.key?(name)
|
||||
elsif base_name && (c = config[base_name.to_sym]) && c.key?(name)
|
||||
c[name]
|
||||
elsif config[:rails].key?(name)
|
||||
config[:rails][name]
|
||||
|
|
|
@ -6,7 +6,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest
|
|||
def test_prevent_null_query
|
||||
# Make sure we have data to find
|
||||
klass = Class.new(ActiveRecord::Base) do
|
||||
def self.name; 'Foo'; end
|
||||
def self.name; "Foo"; end
|
||||
establish_connection adapter: "sqlite3", database: ":memory:"
|
||||
connection.create_table "foos" do |t|
|
||||
t.string :title
|
||||
|
@ -26,24 +26,24 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
}
|
||||
|
||||
assert_nil app.call(make_env({ 't' => nil }))
|
||||
assert_nil app.call(make_env({ 't' => [nil] }))
|
||||
assert_nil app.call(make_env("t" => nil))
|
||||
assert_nil app.call(make_env("t" => [nil]))
|
||||
|
||||
[[[nil]], [[[nil]]]].each do |data|
|
||||
assert_nil app.call(make_env({ 't' => data }))
|
||||
assert_nil app.call(make_env("t" => data))
|
||||
end
|
||||
ensure
|
||||
klass.connection.drop_table("foos")
|
||||
end
|
||||
|
||||
private
|
||||
def make_env json
|
||||
def make_env(json)
|
||||
data = JSON.dump json
|
||||
content_length = data.length
|
||||
{
|
||||
'CONTENT_LENGTH' => content_length,
|
||||
'CONTENT_TYPE' => 'application/json',
|
||||
'rack.input' => StringIO.new(data)
|
||||
"CONTENT_LENGTH" => content_length,
|
||||
"CONTENT_TYPE" => "application/json",
|
||||
"rack.input" => StringIO.new(data)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -72,7 +72,7 @@ module CodeTools
|
|||
fail Error.new("#{path} is a directory") if File.directory?(path)
|
||||
ruby_extension = File.extname(path) == ".rb"
|
||||
ruby_executable = File.open(path, "rb") { |f| f.readline } =~ [/\A#!.*ruby/]
|
||||
fail Error.new("Not a ruby file") unless ruby_extension or ruby_executable
|
||||
fail Error.new("Not a ruby file") unless ruby_extension || ruby_executable
|
||||
end
|
||||
|
||||
module RequireProfiler
|
||||
|
|
Loading…
Reference in New Issue