Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate JRuby test failures #460

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/i18n/backend/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def cache_key(locale, key, options)
private

def digest_item(key)
I18n.cache_key_digest ? I18n.cache_key_digest.hexdigest(key.to_s) : key.hash
I18n.cache_key_digest ? I18n.cache_key_digest.hexdigest(key.to_s) : key.to_s.hash
end
end
end
Expand Down
8 changes: 5 additions & 3 deletions test/backend/cache_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ def setup
I18n.backend = Backend.new
super
I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store)
I18n.cache_store.clear
I18n.cache_key_digest = nil
end

def teardown
super
I18n.cache_store.clear
I18n.cache_store = nil
end

Expand Down Expand Up @@ -67,13 +69,13 @@ def teardown
end

test "adds locale and hash of key and hash of options" do
options = { :bar=>1 }
assert_equal "i18n//en/#{:foo.hash}/#{options.hash}", I18n.backend.send(:cache_key, :en, :foo, options)
options = { :bar => 1 }
assert_equal "i18n//en/#{:foo.to_s.hash}/#{options.to_s.hash}", I18n.backend.send(:cache_key, :en, :foo, options)
end

test "cache_key uses configured digest method" do
md5 = Digest::MD5.new
options = { :bar=>1 }
options = { :bar => 1 }
options_hash = options.inspect
with_cache_key_digest(md5) do
assert_equal "i18n//en/#{md5.hexdigest(:foo.to_s)}/#{md5.hexdigest(options_hash)}", I18n.backend.send(:cache_key, :en, :foo, options)
Expand Down