Index: app/controllers/application_controller.rb =================================================================== --- app/controllers/application_controller.rb (revision 17354) +++ app/controllers/application_controller.rb (working copy) @@ -112,7 +112,7 @@ if (key = api_key_from_request) # Use API key user = User.find_by_api_key(key) - elsif request.authorization.to_s =~ /\ABasic /i + elsif /\ABasic /i.match?(request.authorization.to_s) # HTTP Basic, either username/password or API key/random authenticate_with_http_basic do |username, password| user = User.try_to_login(username, password) || User.find_by_api_key(username) @@ -438,11 +438,11 @@ path = uri.to_s # Ensure that the remaining URL starts with a slash, followed by a # non-slash character or the end - if path !~ %r{\A/([^/]|\z)} + if !%r{\A/([^/]|\z)}.match?(path) return false end - if path.match(%r{/(login|account/register|account/lost_password)}) + if %r{/(login|account/register|account/lost_password)}.match?(path) return false end @@ -623,7 +623,7 @@ # Returns a string that can be used as filename value in Content-Disposition header def filename_for_content_disposition(name) - request.env['HTTP_USER_AGENT'] =~ %r{(MSIE|Trident|Edge)} ? ERB::Util.url_encode(name) : name + %r{(MSIE|Trident|Edge)}.match?(request.env['HTTP_USER_AGENT']) ? ERB::Util.url_encode(name) : name end def api_request? Index: app/controllers/repositories_controller.rb =================================================================== --- app/controllers/repositories_controller.rb (revision 17354) +++ app/controllers/repositories_controller.rb (working copy) @@ -311,7 +311,7 @@ @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip @rev_to = params[:rev_to] - unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE) + unless REV_PARAM_RE.match?(@rev.to_s) && REV_PARAM_RE.match?(@rev_to.to_s) if @repository.branches.blank? raise InvalidRevisionParam end Index: app/controllers/sys_controller.rb =================================================================== --- app/controllers/sys_controller.rb (revision 17354) +++ app/controllers/sys_controller.rb (working copy) @@ -50,7 +50,7 @@ scope = Project.active.has_module(:repository) if params[:id] project = nil - if params[:id].to_s =~ /^\d*$/ + if /^\d*$/.match?(params[:id].to_s) project = scope.find(params[:id]) else project = scope.find_by_identifier(params[:id]) Index: app/helpers/queries_helper.rb =================================================================== --- app/helpers/queries_helper.rb (revision 17354) +++ app/helpers/queries_helper.rb (working copy) @@ -30,7 +30,7 @@ group = :label_relations elsif field_options[:type] == :tree group = query.is_a?(IssueQuery) ? :label_relations : nil - elsif field =~ /^cf_\d+\./ + elsif /^cf_\d+\./.match?(field) group = (field_options[:through] || field_options[:field]).try(:name) elsif field =~ /^(.+)\./ # association filters Index: app/models/attachment.rb =================================================================== --- app/models/attachment.rb (revision 17354) +++ app/models/attachment.rb (working copy) @@ -243,7 +243,7 @@ end def is_diff? - self.filename =~ /\.(patch|diff)$/i + /\.(patch|diff)$/i.match?(filename) end def is_pdf? @@ -484,7 +484,7 @@ def self.disk_filename(filename, directory=nil) timestamp = DateTime.now.strftime("%y%m%d%H%M%S") ascii = '' - if filename =~ %r{^[a-zA-Z0-9_\.\-]*$} && filename.length <= 50 + if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50 ascii = filename else ascii = Digest::MD5.hexdigest(filename) Index: app/models/import.rb =================================================================== --- app/models/import.rb (revision 17354) +++ app/models/import.rb (working copy) @@ -77,7 +77,7 @@ # Returns the full path of the file to import # It is stored in tmp/imports with a random hex as filename def filepath - if filename.present? && filename =~ /\A[0-9a-f]+\z/ + if filename.present? && /\A[0-9a-f]+\z/.match?(filename) File.join(Rails.root, "tmp", "imports", filename) else nil Index: app/models/issue.rb =================================================================== --- app/models/issue.rb (revision 17354) +++ app/models/issue.rb (working copy) @@ -521,7 +521,7 @@ # Project and Tracker must be set before since new_statuses_allowed_to depends on it. if (p = attrs.delete('project_id')) && safe_attribute?('project_id') - if p.is_a?(String) && !p.match(/^\d*$/) + if p.is_a?(String) && !/^\d*$/.match?(p) p_id = Project.find_by_identifier(p).try(:id) else p_id = p.to_i @@ -762,7 +762,7 @@ user = new_record? ? author : current_journal.try(:user) required_attribute_names(user).each do |attribute| - if attribute =~ /^\d+$/ + if /^\d+$/.match?(attribute) attribute = attribute.to_i v = custom_field_values.detect {|v| v.custom_field_id == attribute } if v && Array(v.value).detect(&:present?).nil? Index: app/models/mail_handler.rb =================================================================== --- app/models/mail_handler.rb (revision 17354) +++ app/models/mail_handler.rb (working copy) @@ -102,7 +102,7 @@ value = email.header[key] if value value = value.to_s.downcase - if (ignored_value.is_a?(Regexp) && value.match(ignored_value)) || value == ignored_value + if (ignored_value.is_a?(Regexp) && ignored_value.match?(value)) || value == ignored_value if logger logger.info "MailHandler: ignoring email with #{key}:#{value} header" end @@ -315,7 +315,7 @@ else regexp = %r{\A#{Regexp.escape(pattern).gsub("\\*", ".*")}\z}i end - if attachment.filename.to_s =~ regexp + if regexp.match?(attachment.filename.to_s) logger.info "MailHandler: ignoring attachment #{attachment.filename} matching #{pattern}" return false end Index: app/models/principal.rb =================================================================== --- app/models/principal.rb (revision 17354) +++ app/models/principal.rb (working copy) @@ -172,7 +172,7 @@ principal ||= principals.detect {|a| keyword.casecmp(a.login.to_s) == 0} principal ||= principals.detect {|a| keyword.casecmp(a.mail.to_s) == 0} - if principal.nil? && keyword.match(/ /) + if principal.nil? && / /.match?(keyword) firstname, lastname = *(keyword.split) # "First Last Throwaway" principal ||= principals.detect {|a| a.is_a?(User) && Index: app/models/project.rb =================================================================== --- app/models/project.rb (revision 17354) +++ app/models/project.rb (working copy) @@ -311,7 +311,7 @@ end def self.find(*args) - if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/) + if args.first && args.first.is_a?(String) && !/^\d*$/.match?(args.first) project = find_by_identifier(*args) raise ActiveRecord::RecordNotFound, "Couldn't find Project with identifier=#{args.first}" if project.nil? project @@ -351,7 +351,7 @@ nil else # id is used for projects with a numeric identifier (compatibility) - @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier) + @to_param ||= (%r{^\d*$}.match?(identifier.to_s) ? id.to_s : identifier) end end Index: app/models/query.rb =================================================================== --- app/models/query.rb (revision 17354) +++ app/models/query.rb (working copy) @@ -414,17 +414,17 @@ if values_for(field) case type_for(field) when :integer - add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(,[+-]?\d+)*\z/) } + add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !/\A[+-]?\d+(,[+-]?\d+)*\z/.match?(v) } when :float - add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(\.\d*)?\z/) } + add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !/\A[+-]?\d+(\.\d*)?\z/.match?(v) } when :date, :date_past case operator_for(field) when "=", ">=", "<=", "><" add_filter_error(field, :invalid) if values_for(field).detect {|v| - v.present? && (!v.match(/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){0,2}(Z|\d{2}:?\d{2})?)?\z/) || parse_date(v).nil?) + v.present? && (!/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){0,2}(Z|\d{2}:?\d{2})?)?\z/.match?(v) || parse_date(v).nil?) } when ">t-", "t+", "]/ + if /[<>]/.match?(operator) where = "(#{where}) AND #{db_table}.#{db_field} <> ''" end "#{queried_table_name}.#{customized_key} #{not_in} IN (" + @@ -1345,7 +1345,7 @@ # Returns a Date or Time from the given filter value def parse_date(arg) - if arg.to_s =~ /\A\d{4}-\d{2}-\d{2}T/ + if /\A\d{4}-\d{2}-\d{2}T/.match?(arg.to_s) Time.parse(arg) rescue nil else Date.parse(arg) rescue nil Index: app/models/repository.rb =================================================================== --- app/models/repository.rb (revision 17354) +++ app/models/repository.rb (working copy) @@ -149,7 +149,7 @@ end def self.find_by_identifier_param(param) - if param.to_s =~ /^\d+$/ + if /^\d+$/.match?(param.to_s) find_by_id(param) else find_by_identifier(param) @@ -248,7 +248,7 @@ def find_changeset_by_name(name) return nil if name.blank? s = name.to_s - if s.match(/^\d*$/) + if /^\d*$/.match?(s) changesets.where("revision = ?", s).first else changesets.where("revision LIKE ?", s + '%').first @@ -469,7 +469,7 @@ regexp = Redmine::Configuration["scm_#{scm_name.to_s.downcase}_path_regexp"] if changes[attribute] && regexp.present? regexp = regexp.to_s.strip.gsub('%project%') {Regexp.escape(project.try(:identifier).to_s)} - unless send(attribute).to_s.match(Regexp.new("\\A#{regexp}\\z")) + unless Regexp.new("\\A#{regexp}\\z").match?(send(attribute).to_s) errors.add(attribute, :invalid) end end Index: app/models/repository/mercurial.rb =================================================================== --- app/models/repository/mercurial.rb (revision 17354) +++ app/models/repository/mercurial.rb (working copy) @@ -96,7 +96,7 @@ def find_changeset_by_name(name) return nil if name.blank? s = name.to_s - if /[^\d]/ =~ s or s.size > 8 + if /[^\d]/.match?(s) || s.size > 8 cs = changesets.where(:scmid => s).first else cs = changesets.where(:revision => s).first Index: app/models/token.rb =================================================================== --- app/models/token.rb (revision 17354) +++ app/models/token.rb (working copy) @@ -110,7 +110,7 @@ def self.find_token(action, key, validity_days=nil) action = action.to_s key = key.to_s - return nil unless action.present? && key =~ /\A[a-z0-9]+\z/i + return nil unless action.present? && /\A[a-z0-9]+\z/i.match?(key) token = Token.where(:action => action, :value => key).first if token && (token.action == action) && (token.value == key) && token.user Index: app/models/workflow_permission.rb =================================================================== --- app/models/workflow_permission.rb (revision 17354) +++ app/models/workflow_permission.rb (working copy) @@ -62,7 +62,7 @@ protected def validate_field_name - unless Tracker::CORE_FIELDS_ALL.include?(field_name) || field_name.to_s.match(/^\d+$/) + unless Tracker::CORE_FIELDS_ALL.include?(field_name) || /^\d+$/.match?(field_name.to_s) errors.add :field_name, :invalid end end Index: lib/plugins/open_id_authentication/lib/open_id_authentication.rb =================================================================== --- lib/plugins/open_id_authentication/lib/open_id_authentication.rb (revision 17354) +++ lib/plugins/open_id_authentication/lib/open_id_authentication.rb (working copy) @@ -87,7 +87,7 @@ # dodge XRIs -- TODO: validate, don't just skip. unless ['=', '@', '+', '$', '!', '('].include?(identifier.at(0)) # does it begin with http? if not, add it. - identifier = "http://#{identifier}" unless identifier =~ /^http/i + identifier = "http://#{identifier}" unless /^http/i.match?(identifier) # strip any fragments identifier.gsub!(/\#(.*)$/, '') Index: lib/redmine/codeset_util.rb =================================================================== --- lib/redmine/codeset_util.rb (revision 17354) +++ lib/redmine/codeset_util.rb (working copy) @@ -39,7 +39,7 @@ return str if str.nil? str.force_encoding('ASCII-8BIT') return str if str.empty? - return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii + return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match?(str) # for us-ascii str.force_encoding('UTF-8') encodings = Setting.repositories_encodings.split(',').collect(&:strip) encodings.each do |encoding| Index: lib/redmine/configuration.rb =================================================================== --- lib/redmine/configuration.rb (revision 17354) +++ lib/redmine/configuration.rb (working copy) @@ -114,7 +114,7 @@ # Checks the validness of regular expressions set for repository paths at startup def check_regular_expressions @config.each do |name, value| - if value.present? && name =~ /^scm_.+_path_regexp$/ + if value.present? && /^scm_.+_path_regexp$/.match?(name) begin Regexp.new value.to_s.strip rescue => e Index: lib/redmine/core_ext/active_record.rb =================================================================== --- lib/redmine/core_ext/active_record.rb (revision 17354) +++ lib/redmine/core_ext/active_record.rb (working copy) @@ -19,7 +19,7 @@ def validate_each(record, attribute, value) before_type_cast = record.attributes_before_type_cast[attribute.to_s] if before_type_cast.is_a?(String) && before_type_cast.present? - unless before_type_cast =~ /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/ && value + unless /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/.match?(before_type_cast) && value record.errors.add attribute, :not_a_date end end Index: lib/redmine/export/pdf.rb =================================================================== --- lib/redmine/export/pdf.rb (revision 17354) +++ lib/redmine/export/pdf.rb (working copy) @@ -141,7 +141,7 @@ def self.attach(attachments, filename, encoding) filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding) atta = nil - if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i + if /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i.match?(filename_utf8) atta = Attachment.latest_attach(attachments, filename_utf8) end if atta && atta.readable? && atta.visible? Index: lib/redmine/field_format.rb =================================================================== --- lib/redmine/field_format.rb (revision 17354) +++ lib/redmine/field_format.rb (working copy) @@ -249,7 +249,7 @@ [text, url] end links = texts_and_urls.sort_by(&:first).map do |text, url| - css_class = (url =~ /^https?:\/\//) ? 'external' : nil + css_class = (/^https?:\/\//.match?(url)) ? 'external' : nil view.link_to_if uri_with_safe_scheme?(url), text, url, :class => css_class end links.join(', ').html_safe @@ -358,7 +358,7 @@ def validate_single_value(custom_field, value, customized=nil) errs = super value = value.to_s - unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp) + unless custom_field.regexp.blank? or Regexp.new(custom_field.regexp).match?(value) errs << ::I18n.t('activerecord.errors.messages.invalid') end if custom_field.min_length && value.length < custom_field.min_length @@ -440,12 +440,12 @@ url = url_from_pattern(custom_field, value, customized) else url = value.to_s - unless url =~ %r{\A[a-z]+://}i + unless %r{\A[a-z]+://}i.match?(url) # no protocol found, use http by default url = "http://" + url end end - css_class = (url =~ /^https?:\/\//) ? 'external' : nil + css_class = (/^https?:\/\//.match?(url)) ? 'external' : nil view.link_to value.to_s.truncate(40), url, :class => css_class else value.to_s @@ -490,7 +490,7 @@ def validate_single_value(custom_field, value, customized=nil) errs = super - errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value.to_s =~ /^[+-]?\d+$/ + errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless /^[+-]?\d+$/.match?(value.to_s) errs end @@ -534,7 +534,7 @@ end def validate_single_value(custom_field, value, customized=nil) - if value =~ /^\d{4}-\d{2}-\d{2}$/ && (value.to_date rescue false) + if /^\d{4}-\d{2}-\d{2}$/.match?(value) && (value.to_date rescue false) [] else [::I18n.t('activerecord.errors.messages.not_a_date')] Index: lib/redmine/platform.rb =================================================================== --- lib/redmine/platform.rb (revision 17354) +++ lib/redmine/platform.rb (working copy) @@ -19,8 +19,8 @@ module Platform class << self def mswin? - (RUBY_PLATFORM =~ /(:?mswin|mingw)/) || - (RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i) + (/(:?mswin|mingw)/.match?(RUBY_PLATFORM)) || + (RUBY_PLATFORM == 'java' && /windows/i.match?(ENV['OS'] || ENV['os'])) end end end Index: lib/redmine/scm/adapters/abstract_adapter.rb =================================================================== --- lib/redmine/scm/adapters/abstract_adapter.rb (revision 17354) +++ lib/redmine/scm/adapters/abstract_adapter.rb (working copy) @@ -183,7 +183,7 @@ def target(path, sq=true) path ||= '' - base = path.match(/^\//) ? root_url : url + base = /^\//.match?(path) ? root_url : url str = "#{base}/#{path}".gsub(/[?<>\*]/, '') if sq str = shell_quote(str) Index: lib/redmine/scm/adapters/cvs_adapter.rb =================================================================== --- lib/redmine/scm/adapters/cvs_adapter.rb (revision 17354) +++ lib/redmine/scm/adapters/cvs_adapter.rb (working copy) @@ -168,7 +168,7 @@ file_state = nil branch_map = nil io.each_line() do |line| - if state != "revision" && /^#{ENDLOG}/ =~ line + if state != "revision" && /^#{ENDLOG}/.match?(line) commit_log = String.new revision = nil state = "entry_start" @@ -181,9 +181,9 @@ logger.debug("Path #{entry_path} <=> Name #{entry_name}") elsif /^head: (.+)$/ =~ line entry_headRev = $1 #unless entry.nil? - elsif /^symbolic names:/ =~ line + elsif /^symbolic names:/.match?(line) state = "symbolic" #unless entry.nil? - elsif /^#{STARTLOG}/ =~ line + elsif /^#{STARTLOG}/.match?(line) commit_log = String.new state = "revision" end Index: lib/redmine/scm/adapters/filesystem_adapter.rb =================================================================== --- lib/redmine/scm/adapters/filesystem_adapter.rb (revision 17354) +++ lib/redmine/scm/adapters/filesystem_adapter.rb (working copy) @@ -107,7 +107,7 @@ # Here we do not shell-out, so we do not want quotes. def target(path=nil) # Prevent the use of .. - if path and !path.match(/(^|\/)\.\.(\/|$)/) + if path and !/(^|\/)\.\.(\/|$)/.match?(path) return "#{self.url}#{without_leading_slash(path)}" end return self.url Index: lib/redmine/scm/adapters/mercurial_adapter.rb =================================================================== --- lib/redmine/scm/adapters/mercurial_adapter.rb (revision 17354) +++ lib/redmine/scm/adapters/mercurial_adapter.rb (working copy) @@ -296,10 +296,10 @@ # Runs 'hg' command with the given args def hg(*args, &block) # as of hg 4.4.1, early parsing of bool options is not terminated at '--' - if args.any? { |s| s =~ HG_EARLY_BOOL_ARG } + if args.any? { |s| HG_EARLY_BOOL_ARG.match?(s) } raise HgCommandArgumentError, "malicious command argument detected" end - if args.take_while { |s| s != '--' }.any? { |s| s =~ HG_EARLY_LIST_ARG } + if args.take_while { |s| s != '--' }.any? { |s| HG_EARLY_LIST_ARG.match?(s) } raise HgCommandArgumentError, "malicious command argument detected" end Index: lib/redmine/scm/adapters/subversion_adapter.rb =================================================================== --- lib/redmine/scm/adapters/subversion_adapter.rb (revision 17354) +++ lib/redmine/scm/adapters/subversion_adapter.rb (working copy) @@ -265,7 +265,7 @@ end def target(path = '') - base = path.match(/^\//) ? root_url : url + base = /^\//.match?(path) ? root_url : url uri = "#{base}/#{path}" uri = URI.escape(URI.escape(uri), '[]') shell_quote(uri.gsub(/[?<>\*]/, '')) Index: lib/redmine/sort_criteria.rb =================================================================== --- lib/redmine/sort_criteria.rb (revision 17354) +++ lib/redmine/sort_criteria.rb (working copy) @@ -94,7 +94,7 @@ # Appends ASC/DESC to the sort criterion unless it has a fixed order def append_order(criterion, order) - if criterion =~ / (asc|desc)$/i + if / (asc|desc)$/i.match?(criterion) criterion else "#{criterion} #{order.to_s.upcase}" Index: lib/redmine/unified_diff.rb =================================================================== --- lib/redmine/unified_diff.rb (revision 17354) +++ lib/redmine/unified_diff.rb (working copy) @@ -76,7 +76,7 @@ @parsing = true end else - if line =~ %r{^[^\+\-\s@\\]} + if %r{^[^\+\-\s@\\]}.match?(line) @parsing = false return false elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/ @@ -112,9 +112,9 @@ def file_name=(arg) both_git_diff = false if file_name.nil? - @git_diff = true if arg =~ %r{^(a/|/dev/null)} + @git_diff = true if %r{^(a/|/dev/null)}.match?(arg) else - both_git_diff = (@git_diff && arg =~ %r{^(b/|/dev/null)}) + both_git_diff = (@git_diff && %r{^(b/|/dev/null)}.match?(arg)) end if both_git_diff if file_name && arg == "/dev/null" @@ -166,7 +166,7 @@ true else write_offsets - if line[0, 1] =~ /\s/ + if /\s/.match?(line[0, 1]) diff = Diff.new diff.line_right = line[1..-1] diff.nb_line_right = @line_num_r Index: lib/redmine/wiki_formatting.rb =================================================================== --- lib/redmine/wiki_formatting.rb (revision 17354) +++ lib/redmine/wiki_formatting.rb (working copy) @@ -133,7 +133,7 @@ def auto_link!(text) text.gsub!(AUTO_LINK_RE) do all, leading, proto, url, post = $&, $1, $2, $3, $6 - if leading =~ /=]?/ + if /=]?/.match?(leading) # don't replace URLs that are already linked # and URLs prefixed with ! !> !< != (textile images) all @@ -155,7 +155,7 @@ def auto_mailto!(text) text.gsub!(/((?]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/) + if /]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/.match?(text) mail else %().html_safe Index: lib/redmine/wiki_formatting/macros.rb =================================================================== --- lib/redmine/wiki_formatting/macros.rb (revision 17354) +++ lib/redmine/wiki_formatting/macros.rb (working copy) @@ -141,7 +141,7 @@ # If a block of text is given, the closing tag }} must be at the start of a new line. def macro(name, options={}, &block) options.assert_valid_keys(:desc, :parse_args) - unless name.to_s.match(/\A\w+\z/) + unless /\A\w+\z/.match?(name.to_s) raise "Invalid macro name: #{name} (only 0-9, A-Z, a-z and _ characters are accepted)" end unless block_given? @@ -238,7 +238,7 @@ filename = args.first raise 'Filename required' unless filename.present? size = options[:size] - raise 'Invalid size parameter' unless size.nil? || size.match(/^\d+$/) + raise 'Invalid size parameter' unless size.nil? || /^\d+$/.match?(size) size = size.to_i size = 200 unless size > 0 if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename) Index: test/integration/sessions_test.rb =================================================================== --- test/integration/sessions_test.rb (revision 17354) +++ test/integration/sessions_test.rb (working copy) @@ -37,7 +37,7 @@ get '/my/account' assert_response 302 - assert flash[:error].match(/Your session has expired/) + assert flash[:error].include?('Your session has expired') end def test_lock_user_kills_sessions @@ -49,7 +49,7 @@ get '/my/account' assert_response 302 - assert flash[:error].match(/Your session has expired/) + assert flash[:error].include?('Your session has expired') end def test_update_user_does_not_kill_sessions Index: test/integration/welcome_test.rb =================================================================== --- test/integration/welcome_test.rb (revision 17354) +++ test/integration/welcome_test.rb (working copy) @@ -26,6 +26,6 @@ assert_response :success assert_equal 'text/plain', @response.content_type # Redmine::Utils.relative_url_root does not effect on Rails 5.1.4. - assert @response.body.match(%r{^Disallow: /projects/ecookbook/issues\r?$}) + assert %r{^Disallow: /projects/ecookbook/issues\r?$}.match?(@response.body) end end Index: test/unit/lib/redmine/ciphering_test.rb =================================================================== --- test/unit/lib/redmine/ciphering_test.rb (revision 17354) +++ test/unit/lib/redmine/ciphering_test.rb (working copy) @@ -23,7 +23,7 @@ Redmine::Configuration.with 'database_cipher_key' => 'secret' do r = Repository::Subversion.create!(:password => 'foo', :url => 'file:///tmp', :identifier => 'svn') assert_equal 'foo', r.password - assert r.read_attribute(:password).match(/\Aaes-256-cbc:.+\Z/) + assert /\Aaes-256-cbc:.+\Z/.match?(r.read_attribute(:password)) end end @@ -71,7 +71,7 @@ r = Repository.order('id DESC').first # password can not be deciphered assert_nothing_raised do - assert r.password.match(/\Aaes-256-cbc:.+\Z/) + assert /\Aaes-256-cbc:.+\Z/.match?(r.password) end end end @@ -87,7 +87,7 @@ assert Repository.encrypt_all(:password) r = Repository.order('id DESC').first assert_equal 'bar', r.password - assert r.read_attribute(:password).match(/\Aaes-256-cbc:.+\Z/) + assert /\Aaes-256-cbc:.+\Z/.match?(r.read_attribute(:password)) end end Index: test/unit/lib/redmine/wiki_formatting/macros_test.rb =================================================================== --- test/unit/lib/redmine/wiki_formatting/macros_test.rb (revision 17354) +++ test/unit/lib/redmine/wiki_formatting/macros_test.rb (working copy) @@ -175,7 +175,7 @@ def test_macro_hello_world text = "{{hello_world}}" - assert textilizable(text).match(/Hello world!/) + assert textilizable(text).include?('Hello world!') end def test_macro_hello_world_should_escape_arguments Index: test/unit/mail_handler_test.rb =================================================================== --- test/unit/mail_handler_test.rb (revision 17354) +++ test/unit/mail_handler_test.rb (working copy) @@ -62,9 +62,9 @@ assert_equal 30, issue.done_ratio assert_equal Issue.find(4), issue.parent # keywords should be removed from the email body - assert !issue.description.match(/^Project:/i) - assert !issue.description.match(/^Status:/i) - assert !issue.description.match(/^Start Date:/i) + assert !/^Project:/i.match?(issue.description) + assert !/^Status:/i.match?(issue.description) + assert !/^Start Date:/i.match?(issue.description) end def test_add_issue_with_all_overrides @@ -250,7 +250,7 @@ assert_equal 'PostgreSQL', issue.custom_field_value(1) assert_equal 'Value for a custom field', issue.custom_field_value(2) assert_equal ['Mac OS X', 'Windows'], issue.custom_field_value(mutiple.id).sort - assert !issue.description.match(/^searchable field:/i) + assert !/^searchable field:/i.match?(issue.description) end def test_add_issue_with_version_custom_fields @@ -849,8 +849,8 @@ assert_equal User.find_by_login('jsmith'), issue.assigned_to assert_equal "52.6", issue.custom_value_for(CustomField.find_by_name('Float field')).value # keywords should be removed from the email body - assert !journal.notes.match(/^Status:/i) - assert !journal.notes.match(/^Start Date:/i) + assert !/^Status:/i.match?(journal.notes) + assert !/^Start Date:/i.match?(journal.notes) end def test_update_issue_with_attachment @@ -992,7 +992,7 @@ assert_issue_created(issue) assert issue.description.include?('This paragraph is before delimiters') assert issue.description.include?('--- This line starts with a delimiter') - assert !issue.description.match(/^---#{"\u00A0"}$/) + assert !/^---#{"\u00A0"}$/.match?(issue.description) assert !issue.description.include?('This paragraph is after the delimiter') end end @@ -1002,7 +1002,7 @@ journal = submit_email('issue_update_with_quoted_reply_above.eml') assert journal.is_a?(Journal) assert journal.notes.include?('An update to the issue by the sender.') - assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---")) + assert !Regexp.escape("--- Reply above. Do not remove this line. ---").match?(journal.notes) assert !journal.notes.include?('Looks like the JSON api for projects was missed.') end end @@ -1012,7 +1012,7 @@ journal = submit_email('issue_update_with_multiple_quoted_reply_above.eml') assert journal.is_a?(Journal) assert journal.notes.include?('An update to the issue by the sender.') - assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---")) + assert !Regexp.escape("--- Reply above. Do not remove this line. ---").match?(journal.notes) assert !journal.notes.include?('Looks like the JSON api for projects was missed.') end end @@ -1024,7 +1024,7 @@ assert issue.description.include?('This paragraph is before delimiters') assert !issue.description.include?('BREAK') assert !issue.description.include?('This paragraph is between delimiters') - assert !issue.description.match(/^---$/) + assert !/^---$/.match?(issue.description) assert !issue.description.include?('This paragraph is after the delimiter') end end Index: test/unit/principal_test.rb =================================================================== --- test/unit/principal_test.rb (revision 17354) +++ test/unit/principal_test.rb (working copy) @@ -89,7 +89,7 @@ results = Principal.like('jsmi') assert results.any? - assert results.all? {|u| u.login.match(/jsmi/i) } + assert results.all? {|u| /jsmi/i.match?(u.login) } end test "like scope should search firstname" do @@ -96,7 +96,7 @@ results = Principal.like('john') assert results.any? - assert results.all? {|u| u.firstname.match(/john/i) } + assert results.all? {|u| /john/i.match?(u.firstname) } end test "like scope should search lastname" do @@ -103,7 +103,7 @@ results = Principal.like('smi') assert results.any? - assert results.all? {|u| u.lastname.match(/smi/i) } + assert results.all? {|u| /smi/i.match?(u.lastname) } end test "like scope should search mail" do @@ -110,7 +110,7 @@ results = Principal.like('somenet') assert results.any? - assert results.all? {|u| u.mail.match(/somenet/i) } + assert results.all? {|u| /somenet/i.match?(u.mail) } end test "like scope should search firstname and lastname" do