aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorKseniya Tomskikh <ktomskih@datamonsters.co>2018-04-12 13:59:43 +0700
committerGitHub <noreply@github.com>2018-04-12 13:59:43 +0700
commit4a769764836a14ca3afa4d6a6f7f09943e290ec2 (patch)
tree113cf2991823c93b784cc4fa72d8f116b2e13be5 /src/test
parent4cfa6a09c6f6692f5513ff6e31f261a020d07068 (diff)
downloaddriver-core-4a769764836a14ca3afa4d6a6f7f09943e290ec2.tar.gz
driver-core-4a769764836a14ca3afa4d6a6f7f09943e290ec2.tar.bz2
driver-core-4a769764836a14ca3afa4d6a6f7f09943e290ec2.zip
Fixed merge JsValues when field is absent in old value (#153)v1.8.21
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/xyz/driver/core/rest/PatchDirectivesTest.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/core/rest/PatchDirectivesTest.scala b/src/test/scala/xyz/driver/core/rest/PatchDirectivesTest.scala
index 6a6b035..987717d 100644
--- a/src/test/scala/xyz/driver/core/rest/PatchDirectivesTest.scala
+++ b/src/test/scala/xyz/driver/core/rest/PatchDirectivesTest.scala
@@ -72,6 +72,15 @@ class PatchDirectivesTest
}
}
+ it should "handle optional values correctly when old value is null" in {
+ val fooRetrieve = Future.successful(Some(testFoo.copy(bar = None)))
+
+ Patch("/api/v1/foos/1", jsonEntity("""{"bar": {"name": "My Bar","size":10}}""")) ~> route(fooRetrieve) ~> check {
+ handled shouldBe true
+ responseAs[Foo] shouldBe testFoo.copy(bar = Some(Bar(Name("My Bar"), 10)))
+ }
+ }
+
it should "return a 400 for nulls on non-optional values" in {
val fooRetrieve = Future.successful(Some(testFoo))