forked from mongodb/mongoid
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calling find with nil should raise a proper exception
- Loading branch information
Showing
5 changed files
with
47 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
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,19 @@ | ||
# encoding: utf-8 | ||
module Mongoid #:nodoc | ||
module Errors #:nodoc | ||
|
||
# Raised when invalid arguments are passed to #find. | ||
class InvalidFind < MongoidError | ||
|
||
# Create the new invalid find error. | ||
# | ||
# @example Create the error. | ||
# InvalidFind.new | ||
# | ||
# @since 2.2.0 | ||
def initialize | ||
super(translate("calling_document_find_with_nil_is_invalid", {})) | ||
end | ||
end | ||
end | ||
end |
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,17 @@ | ||
require "spec_helper" | ||
|
||
describe Mongoid::Errors::InvalidFind do | ||
|
||
describe "#message" do | ||
|
||
let(:error) do | ||
described_class.new | ||
end | ||
|
||
it "returns the warning find with nil" do | ||
error.message.should include( | ||
"Calling Document#find with nil is invalid" | ||
) | ||
end | ||
end | ||
end |