aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/cache
diff options
context:
space:
mode:
authorGannon McGibbon <gannon.mcgibbon@gmail.com>2018-12-13 13:08:49 -0500
committerGannon McGibbon <gannon.mcgibbon@gmail.com>2018-12-27 01:39:43 -0600
commit94ecf95674f81c5590c8f08549208907b81e3bf8 (patch)
tree07da284fc15dc25fa893737a6161e579bce65f68 /activesupport/test/cache
parent3a3a3d607eb2f706c117926015d2cb6ef6599ded (diff)
downloadrails-94ecf95674f81c5590c8f08549208907b81e3bf8.tar.gz
rails-94ecf95674f81c5590c8f08549208907b81e3bf8.tar.bz2
rails-94ecf95674f81c5590c8f08549208907b81e3bf8.zip
Preserve key order passed to ActiveSupport::CacheStore#fetch_multi
fetch_multi(*names) now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
Diffstat (limited to 'activesupport/test/cache')
-rw-r--r--activesupport/test/cache/behaviors/cache_store_behavior.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activesupport/test/cache/behaviors/cache_store_behavior.rb b/activesupport/test/cache/behaviors/cache_store_behavior.rb
index 9f54b1e7de..a696760bb2 100644
--- a/activesupport/test/cache/behaviors/cache_store_behavior.rb
+++ b/activesupport/test/cache/behaviors/cache_store_behavior.rb
@@ -130,7 +130,7 @@ module CacheStoreBehavior
assert_equal("fufu", @cache.read("fu"))
end
- def test_multi_with_objects
+ def test_fetch_multi_with_objects
cache_struct = Struct.new(:cache_key, :title)
foo = cache_struct.new("foo", "FOO!")
bar = cache_struct.new("bar")
@@ -142,6 +142,14 @@ module CacheStoreBehavior
assert_equal({ foo => "FOO!", bar => "BAM!" }, values)
end
+ def test_fetch_multi_returns_ordered_names
+ @cache.write("bam", "BAM")
+
+ values = @cache.fetch_multi("foo", "bar", "bam") { |key| key.upcase }
+
+ assert_equal(%w(foo bar bam), values.keys)
+ end
+
def test_fetch_multi_without_block
assert_raises(ArgumentError) do
@cache.fetch_multi("foo")