Skip to content

Commit

Permalink
Merge 0d88000 into a8f66d8
Browse files Browse the repository at this point in the history
  • Loading branch information
dlibanori committed Jul 11, 2013
2 parents a8f66d8 + 0d88000 commit c0fd087
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mongoid/extensions/float.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def mongoize(object)
nil
end
end
alias :demongoize :mongoize
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions spec/mongoid/extensions/float_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
expect(Float.demongoize(nil)).to be_nil
end
end

context "when the value is a float string" do

it "returns a float" do
expect(Float.demongoize(number.to_s)).to eq(number)
end
end

context "when the value is a no float string" do

it "returns a float" do
expect(Float.demongoize('asdf')).to eq(0)
end
end
end

describe ".mongoize" do
Expand Down

0 comments on commit c0fd087

Please sign in to comment.