diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2018-04-12 13:59:43 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-12 13:59:43 +0700 |
commit | 4a769764836a14ca3afa4d6a6f7f09943e290ec2 (patch) | |
tree | 113cf2991823c93b784cc4fa72d8f116b2e13be5 /src/test | |
parent | 4cfa6a09c6f6692f5513ff6e31f261a020d07068 (diff) | |
download | driver-core-1.8.21.tar.gz driver-core-1.8.21.tar.bz2 driver-core-1.8.21.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.scala | 9 |
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)) |