From 9f1eea8d32a3a4765b0a317cfdb9b3816d72472c Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Fri, 18 Jun 2010 21:11:02 +0200 Subject: [PATCH] Fixes and testing for class proxy --- lib/couchrest/mixins/class_proxy.rb | 2 +- spec/couchrest/class_proxy_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/couchrest/mixins/class_proxy.rb b/lib/couchrest/mixins/class_proxy.rb index ab8daf6..f6285d8 100644 --- a/lib/couchrest/mixins/class_proxy.rb +++ b/lib/couchrest/mixins/class_proxy.rb @@ -51,7 +51,7 @@ module CouchRest elsif m.to_s =~ /^find_(by_.+)/ view_name = $1 if has_view?(view_name) - return find_first_from_view(view_name, *args) + return first_from_view(view_name, *args) end end super diff --git a/spec/couchrest/class_proxy_spec.rb b/spec/couchrest/class_proxy_spec.rb index f8d5f92..dc28c03 100644 --- a/spec/couchrest/class_proxy_spec.rb +++ b/spec/couchrest/class_proxy_spec.rb @@ -60,6 +60,10 @@ describe "Proxy Class" do @us.first_from_view('by_title', 'bbb', :limit => 1) end + it "should allow dynamic view matching for single elements" do + @us.should_receive(:first_from_view).with('by_title', 'bbb') + @us.find_by_title('bbb') + end it "should yield" do things = []