Skip to content

Commit

Permalink
✅ Desrialize an unexpected prop set to null raise
Browse files Browse the repository at this point in the history
  • Loading branch information
pimpin committed Jul 12, 2023
1 parent c1ba1e4 commit fcf9e4f
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 @@ -82,6 +82,20 @@ class BaseTestWithIgnoredProperties < CouchbaseOrm::Base
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 fcf9e4f

Please sign in to comment.