forked from mongodb/mongoid
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attributes should not exist in the db if value was nil
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "spec_helper" | ||
|
||
describe Mongoid::Attributes do | ||
|
||
context "when persisting nil attributes" do | ||
|
||
before do | ||
@person = Person.create(:score => nil, :ssn => "555-66-7777") | ||
end | ||
|
||
after do | ||
Person.delete_all | ||
end | ||
|
||
it "the field should not exist" do | ||
from_db = Person.find(@person.id) | ||
from_db.attributes.has_key?(:score).should be_false | ||
end | ||
|
||
end | ||
|
||
end |