Skip to content

Commit

Permalink
Merge pull request #5 from Couchbase-Ecosystem/deserialize_an_unexpec…
Browse files Browse the repository at this point in the history
…ted_property_set_to_null_raise_error

✅ Deserialize an unexpected prop set to null raise an error
  • Loading branch information
pimpin authored Jul 8, 2024
2 parents e5a5be0 + 8934765 commit a9501cc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a9501cc

Please sign in to comment.