Skip to content

Commit e5729b4

Browse files
committed
Replace with_multi_batch_size with stub_const
1 parent 129bc44 commit e5729b4

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

test/models/solid_cache/entry_test.rb

+1-13
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ class EntryTest < ActiveSupport::TestCase
7171
end
7272

7373
test "batching multi queries" do
74-
with_multi_batch_size(2) do
75-
Entry.stubs(:const_get).with(:MULTI_BATCH_SIZE).returns("stubbed_value")
76-
74+
stub_const(Entry, :MULTI_BATCH_SIZE, 2) do
7775
assert_queries_count(2) do
7876
Entry.write_multi([ { key: "hello".b, value: "there" }, { key: "foo".b, value: "bar" }, { key: "baz".b, value: "zab" } ])
7977
end
@@ -88,15 +86,5 @@ class EntryTest < ActiveSupport::TestCase
8886
def write_entries(count = 20)
8987
Entry.write_multi(count.times.map { |i| { key: "key#{i}", value: "value#{i}" } })
9088
end
91-
92-
def with_multi_batch_size(value)
93-
old_value = Entry::MULTI_BATCH_SIZE
94-
Entry.send(:remove_const, :MULTI_BATCH_SIZE)
95-
Entry.const_set(:MULTI_BATCH_SIZE, value)
96-
yield
97-
ensure
98-
Entry.send(:remove_const, :MULTI_BATCH_SIZE)
99-
Entry.const_set(:MULTI_BATCH_SIZE, old_value)
100-
end
10189
end
10290
end

0 commit comments

Comments
 (0)