Fixing find(blank) issue
This commit is contained in:
parent
31770ba571
commit
5c21de8586
|
@ -1,3 +1,10 @@
|
|||
== Next Version
|
||||
|
||||
* Major enhancements
|
||||
|
||||
* Minor enhancements
|
||||
* Fixing find("") issue (thanks epochwolf)
|
||||
|
||||
== CouchRest Model 1.0.0.beta8
|
||||
|
||||
* Major enhancements
|
||||
|
|
|
@ -70,6 +70,7 @@ module CouchRest
|
|||
# id<String, Integer>:: Document ID
|
||||
# db<Database>:: optional option to pass a custom database to use
|
||||
def get!(id, db = database)
|
||||
raise "Missing or empty document ID" if id.to_s.empty?
|
||||
doc = db.get id
|
||||
create_from_database(doc)
|
||||
end
|
||||
|
|
|
@ -282,11 +282,17 @@ describe "Model Persistence" do
|
|||
foundart = Article.get 'matt aimonetti'
|
||||
foundart.should be_nil
|
||||
end
|
||||
it "should return nil if a blank id is requested" do
|
||||
Article.get("").should be_nil
|
||||
end
|
||||
it "should raise an error if `get!` is used and the document doesn't exist" do
|
||||
lambda{foundart = Article.get!('matt aimonetti')}.should raise_error
|
||||
expect{ Article.get!('matt aimonetti') }.to raise_error
|
||||
end
|
||||
it "should raise an error if `get!` is requested with a blank id" do
|
||||
expect{ Article.get!("") }.to raise_error
|
||||
end
|
||||
it "should raise an error if `find!` is used and the document doesn't exist" do
|
||||
lambda{foundart = Article.find!('matt aimonetti')}.should raise_error
|
||||
expect{ Article.find!('matt aimonetti') }.to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue