Sha256: 4b96867c3e8bf5b84c4f4ee28e2c5f9e3a1efd61123524392de7d3e20b67e5c0

Contents?: true

Size: 1.17 KB

Versions: 275

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'

require 'backend/simple_test'

class I18nBackendMemoizeTest < I18nBackendSimpleTest
  module MemoizeSpy
    attr_accessor :spy_calls

    def available_locales
      self.spy_calls = (self.spy_calls || 0) + 1
      super
    end
  end

  class MemoizeBackend < I18n::Backend::Simple
    include MemoizeSpy
    include I18n::Backend::Memoize
  end

  def setup
    super
    I18n.backend = MemoizeBackend.new
  end

  def test_memoizes_available_locales
    I18n.backend.spy_calls = 0
    assert_equal I18n.available_locales, I18n.available_locales
    assert_equal 1, I18n.backend.spy_calls
  end

  def test_resets_available_locales_on_reload!
    I18n.available_locales
    I18n.backend.spy_calls = 0
    I18n.reload!
    assert_equal I18n.available_locales, I18n.available_locales
    assert_equal 1, I18n.backend.spy_calls
  end

  def test_resets_available_locales_on_store_translations
    I18n.available_locales
    I18n.backend.spy_calls = 0
    I18n.backend.store_translations(:copa, :ca => :bana)
    assert_equal I18n.available_locales, I18n.available_locales
    assert I18n.available_locales.include?(:copa)
    assert_equal 1, I18n.backend.spy_calls
  end
end

Version data entries

275 entries across 239 versions & 49 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/i18n-0.6.9/test/backend/memoize_test.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/i18n-0.6.11/test/backend/memoize_test.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/i18n-0.6.11/test/backend/memoize_test.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/i18n-0.6.11/test/backend/memoize_test.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/i18n-0.6.9/test/backend/memoize_test.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/i18n-0.6.9/test/backend/memoize_test.rb
logstash-codec-json-2.0.3 vendor/gems/i18n-0.6.9/test/backend/memoize_test.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/i18n-0.6.9/test/backend/memoize_test.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/i18n-0.6.9/test/backend/memoize_test.rb
classiccms-0.7.5 vendor/bundle/gems/i18n-0.6.0/test/backend/memoize_test.rb
classiccms-0.7.4 vendor/bundle/gems/i18n-0.6.0/test/backend/memoize_test.rb
classiccms-0.7.3 vendor/bundle/gems/i18n-0.6.0/test/backend/memoize_test.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/i18n-0.6.1/test/backend/memoize_test.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/i18n-0.6.2/test/backend/memoize_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/i18n-0.6.9/test/backend/memoize_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/i18n-0.6.11/test/backend/memoize_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/i18n-0.6.11/test/backend/memoize_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/i18n-0.6.9/test/backend/memoize_test.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/i18n-0.6.11/test/backend/memoize_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/i18n-0.6.11/test/backend/memoize_test.rb