From 8934765608f0f263b44eb081cbc1a4f8c000fd70 Mon Sep 17 00:00:00 2001 From: Pierre Merlin Date: Wed, 12 Jul 2023 19:13:18 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Desrialize=20an=20unexpected=20prop?= =?UTF-8?q?=20set=20to=20null=20raise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/base_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/base_spec.rb b/spec/base_spec.rb index 9ef652c..037da37 100644 --- a/spec/base_spec.rb +++ b/spec/base_spec.rb @@ -124,6 +124,20 @@ def foo BaseTest.bucket.default_collection.remove 'doc_1' end + it "raises ActiveModel::UnknownAttributeError on loading objects with unexpected properties even valued to null" do + too_much_properties_valued_to_null_doc = { + type: BaseTest.design_document, + name: 'Pierre', + job: 'dev', + age: nil + } + BaseTest.bucket.default_collection.upsert 'doc_1', too_much_properties_valued_to_null_doc + + expect { BaseTest.find_by_id('doc_1') }.to raise_error(ActiveModel::UnknownAttributeError) + + BaseTest.bucket.default_collection.remove 'doc_1' + end + it "loads objects even if there is a missing property in doc" do missing_properties_doc = { type: BaseTest.design_document,