]> git.openstreetmap.org Git - rails.git/commitdiff
Fix new rubocop warnings
authorTom Hughes <tom@compton.nu>
Fri, 9 Oct 2020 07:26:38 +0000 (08:26 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 9 Oct 2020 07:26:38 +0000 (08:26 +0100)
lib/potlatch.rb
test/controllers/api/changesets_controller_test.rb

index 75b81bbc5dbc48a75d4b0f6aeca4cc1ce3bab755..4d9fd1c23136ce4399c86551647debd059cd3522 100644 (file)
@@ -180,13 +180,13 @@ module Potlatch
       #  StringIO.open(txt) do |file|
       File.open(Rails.root.join("config/potlatch/presets.txt")) do |file|
         file.each_line do |line|
-          t = line.chomp
-          if t =~ %r{(\w+)/(\w+)}
+          case line.chomp
+          when %r{(\w+)/(\w+)}
             presettype = Regexp.last_match(1)
             presetcategory = Regexp.last_match(2)
             presetmenus[presettype].push(presetcategory)
             presetnames[presettype][presetcategory] = ["(no preset)"]
-          elsif t =~ /^([\w\s]+):\s?(.+)$/
+          when /^([\w\s]+):\s?(.+)$/
             pre = Regexp.last_match(1)
             kv = Regexp.last_match(2)
             presetnames[presettype][presetcategory].push(pre)
index 871eac9edb7021bc112d4175f0fd776256088012..1f394d126cce511e9bc5b5d8a77468a202f9f189 100644 (file)
@@ -71,7 +71,7 @@ module Api
       duration = cs.closed_at - cs.created_at
       # the difference can either be a rational, or a floating point number
       # of seconds, depending on the code path taken :-(
-      if duration.class == Rational
+      if duration.instance_of?(Rational)
         assert_equal Rational(1, 24), duration, "initial idle timeout should be an hour (#{cs.created_at} -> #{cs.closed_at})"
       else
         # must be number of seconds...