sunspot_matchers 2.0.0.4 → 2.0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/sunspot_matchers/matchers.rb +3 -2
- data/lib/sunspot_matchers/version.rb +1 -1
- data/spec/sunspot_matchers_spec.rb +34 -0
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -103,11 +103,12 @@ module SunspotMatchers
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def compare_multi_value(actual, comparison)
|
106
|
+
actual = [actual] unless actual.is_a?(Array)
|
107
|
+
comparison = [comparison] unless comparison.is_a?(Array)
|
106
108
|
filter_values(comparison).reject do |value|
|
107
109
|
next false unless actual
|
108
110
|
value_matcher = Regexp.new(Regexp.escape(value))
|
109
|
-
|
110
|
-
cmp_value.any?{ |actual_value| actual_value =~ value_matcher }
|
111
|
+
actual.any?{ |actual_value| actual_value =~ value_matcher }
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
@@ -514,6 +514,14 @@ describe "Sunspot Matchers" do
|
|
514
514
|
Sunspot.session.should have_search_params(:facet, :category_ids)
|
515
515
|
end
|
516
516
|
|
517
|
+
it "should match if multiple facet exists" do
|
518
|
+
Sunspot.search(Post) do
|
519
|
+
facet :category_ids
|
520
|
+
facet :blog_id
|
521
|
+
end
|
522
|
+
Sunspot.session.should have_search_params(:facet, :category_ids)
|
523
|
+
end
|
524
|
+
|
517
525
|
it "should not match if facet does not exist" do
|
518
526
|
Sunspot.search(Post) do
|
519
527
|
paginate :page => 5, :per_page => 15
|
@@ -557,6 +565,32 @@ describe "Sunspot Matchers" do
|
|
557
565
|
}
|
558
566
|
end
|
559
567
|
|
568
|
+
it "should match if multiple facet exists, but the facet you are matching on only has a single row" do
|
569
|
+
Sunspot.search(Post) do
|
570
|
+
facet(:average_rating) do
|
571
|
+
row(1.0..2.0) do
|
572
|
+
with(:average_rating, 1.0..2.0)
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
facet(:popularity) do
|
577
|
+
row(1..5) do
|
578
|
+
with(:popularity, 1..5)
|
579
|
+
end
|
580
|
+
row(6..10) do
|
581
|
+
with(:popularity, 6..10)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
end
|
585
|
+
Sunspot.session.should have_search_params(:facet) {
|
586
|
+
facet(:average_rating) do
|
587
|
+
row(1.0..2.0) do
|
588
|
+
with(:average_rating, 1.0..2.0)
|
589
|
+
end
|
590
|
+
end
|
591
|
+
}
|
592
|
+
end
|
593
|
+
|
560
594
|
it "should not match if actual search is missing a facet" do
|
561
595
|
Sunspot.search(Post) do
|
562
596
|
facet(:average_rating) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|