Skip to content

Commit 8e7d2a8

Browse files
committed
Fixed issue with mutating options
1 parent 5731d25 commit 8e7d2a8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/searchkick/relation.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ def ensure_permitted(obj)
695695

696696
def initialize_copy(other)
697697
super
698+
@options = @options.deep_dup
698699
@execute = nil
699700
end
700701
end

test/relation_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ def test_mutating
2323
assert_equal ["Product A"], products.map(&:name)
2424
end
2525

26+
def test_non_mutating
27+
store_names ["Product A", "Product B"]
28+
products = Product.search("*").order(:name)
29+
products.limit(1)
30+
assert_equal ["Product A", "Product B"], products.map(&:name)
31+
end
32+
2633
def test_load
2734
products = Product.search("*")
2835
refute products.loaded?

0 commit comments

Comments
 (0)