From 2dc50b4431dbf01c2ad9402a5a6f8772ce0a7cc7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 9 Oct 2020 08:26:38 +0100 Subject: [PATCH] Fix new rubocop warnings --- lib/potlatch.rb | 6 +++--- test/controllers/api/changesets_controller_test.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/potlatch.rb b/lib/potlatch.rb index 75b81bbc5..4d9fd1c23 100644 --- a/lib/potlatch.rb +++ b/lib/potlatch.rb @@ -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) diff --git a/test/controllers/api/changesets_controller_test.rb b/test/controllers/api/changesets_controller_test.rb index 871eac9ed..1f394d126 100644 --- a/test/controllers/api/changesets_controller_test.rb +++ b/test/controllers/api/changesets_controller_test.rb @@ -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... -- 2.45.2