hiptest / i18n-coverage

Simple gem to provide a coverage of I18n keys used during test suite
25 stars 3 forks source link

KeyLogger bug #12

Open ClayShentrup opened 2 years ago

ClayShentrup commented 2 years ago

key_logger.rb has this:

      def lookup(locale, key, scope = [], options = {})
        key = (Array(scope || []) + [key]).compact.join('.')
        I18n::Coverage::KeyLogger.store_key(key)
        super
      end

This coverts a key like unauthenticated into devise.failure.unauthenticated, resulting in failures in otherwise perfectly functioning code.

I assume this was just an oversight, and you didn't realize super would pass through the altered key rather than the original argument. Proof of concept demo.

irb(main):001:1* class Parent
irb(main):002:2*   def foo(key)
irb(main):003:2*     puts "key is #{key}"
irb(main):004:1*   end
irb(main):005:0> end
=> :foo
irb(main):006:1* class Child < Parent
irb(main):007:2*   def foo(key)
irb(main):008:2*     key = "banana"
irb(main):009:2*     super
irb(main):010:1*   end
irb(main):011:0> end
=> :foo
irb(main):012:0> Child.new.foo("ohai")
key is banana
ClayShentrup commented 2 years ago

Fixed by this PR.