Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ Deserialize an unexpected prop set to null raise an error #5

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading