Skip to content

Commit

Permalink
Fixing find(blank) issue
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Sep 5, 2010
1 parent 31770ba commit 5c21de8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions history.txt
@@ -1,3 +1,10 @@
== Next Version

* Major enhancements

* Minor enhancements
* Fixing find("") issue (thanks epochwolf)

== CouchRest Model 1.0.0.beta8

* Major enhancements
Expand Down
1 change: 1 addition & 0 deletions lib/couchrest/model/document_queries.rb
Expand Up @@ -70,6 +70,7 @@ def get(id, db = database)
# 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
Expand Down
10 changes: 8 additions & 2 deletions spec/couchrest/persistence_spec.rb
Expand Up @@ -282,11 +282,17 @@
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

Expand Down

0 comments on commit 5c21de8

Please sign in to comment.