Skip to content

Commit

Permalink
fix(query): Fix InsideBoundingBox & InsidePolygon
Browse files Browse the repository at this point in the history
  • Loading branch information
ElPicador committed Mar 10, 2017
1 parent df6d502 commit 623fb82
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/algolia/objects/InsideBoundingBox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ case class InsideBoundingBox(p1Lat: String,
p2Lat: String,
p2Lng: String) {

override def toString = s"$p1Lat,$p1Lng,$p2Lat,$p2Lng"
override def toString = s"[$p1Lat,$p1Lng,$p2Lat,$p2Lng]"

}
2 changes: 1 addition & 1 deletion src/main/scala/algolia/objects/InsidePolygon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ case class InsidePolygon(p1Lat: String,
p3Lat: String,
p3Lng: String) {

override def toString = s"$p1Lat,$p1Lng,$p2Lat,$p2Lng,$p3Lat,$p3Lng"
override def toString = s"[$p1Lat,$p1Lng,$p2Lat,$p2Lng,$p3Lat,$p3Lng]"

}
36 changes: 31 additions & 5 deletions src/test/scala/algolia/integration/SearchIntegrationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ package algolia.integration

import algolia.AlgoliaDsl._
import algolia.AlgoliaTest
import algolia.objects.{IndexSettings, Query}
import algolia.objects.{IndexSettings, InsideBoundingBox, InsidePolygon, Query}
import algolia.responses._
import org.json4s._

Expand All @@ -44,11 +44,9 @@ class SearchIntegrationTest extends AlgoliaTest {
}

before {
val obj = Test("algolia", 10, alien = false)
val insert1 = client.execute {
index into "indexToSearch" objectId "563481290" `object` Test("algolia",
10,
alien =
false)
index into "indexToSearch" objectId "563481290" `object` obj
}

taskShouldBeCreatedAndWaitForIt(insert1, "indexToSearch")
Expand Down Expand Up @@ -104,6 +102,34 @@ class SearchIntegrationTest extends AlgoliaTest {
result.asHit[EnhanceTest].head should be(hit)
}
}

it("should be able to search on insideBoundingBox") {
val box = Seq(InsideBoundingBox("1", "2", "3", "4"),
InsideBoundingBox("5", "6", "7", "8"))
val s = client.execute {
search into "indexToSearch" query Query(query = Some("a"),
insideBoundingBox = Some(box))
}

whenReady(s) { result =>
result.hits should be(empty)
}
}

it("should be able to search on insidePolygon") {
val polygon = Seq(
InsidePolygon("1", "2", "3", "4", "5", "6"),
InsidePolygon("7", "8", "9", "10", "11", "12")
)
val s = client.execute {
search into "indexToSearch" query Query(query = Some("a"),
insidePolygon = Some(polygon))
}

whenReady(s) { result =>
result.hits should be(empty)
}
}
}

describe("multi queries") {
Expand Down

0 comments on commit 623fb82

Please sign in to comment.