Changeset 1128
- Timestamp:
- 12/22/07 14:07:06 (1 year ago)
- Files:
-
- trunk/Rakefile (modified) (1 diff)
- trunk/lib/merb/router.rb (modified) (1 diff)
- trunk/spec/fixtures/models/router_spec_models.rb (modified) (1 diff)
- trunk/spec/spec_helpers/url_shared_behaviour.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Rakefile
r1123 r1128 130 130 Spec::Rake::SpecTask.new('rcov') do |t| 131 131 t.spec_opts = ["--format", "specdoc", "--colour"] 132 t.rcov_opts = ["--exclude","gems"] 132 133 t.spec_files = Dir['spec/**/*_spec.rb'].sort 133 134 t.libs = ['lib', 'server/lib' ] trunk/lib/merb/router.rb
r1104 r1128 142 142 params[segment] || fallback[segment] 143 143 else 144 if params.respond_to?(segment) 144 if segment == :id && params.respond_to?(:to_param) 145 params.to_param 146 elsif params.respond_to?(segment) 145 147 params.send(segment) 146 148 else trunk/spec/fixtures/models/router_spec_models.rb
r380 r1128 19 19 end 20 20 end 21 22 23 class Blog 24 def id 25 42 26 end 27 def to_param 28 "hello#{id}" 29 end 30 end trunk/spec/spec_helpers/url_shared_behaviour.rb
r1079 r1128 56 56 it "should handle an object as the second arg" do 57 57 c = new_url_controller(@resource_routes, :controller => "blogs", :action => "show") 58 blog = mock("blog") 59 blog.should_receive(:id).once.and_return(7) 58 blog = Blog.new 60 59 url = c.url(:blog, blog) 61 url.should == "/blogs/ 7"60 url.should == "/blogs/hello42" 62 61 end 63 62 64 63 it "should point to /blogs/:blog_id if @blog is not new_record" do 65 64 c = new_url_controller(@resource_routes, :controller => "blogs", :action => "index") 66 blog = mock("blog") 67 blog.should_receive(:id).once.and_return(7) 65 blog = Blog.new 68 66 blog.should_receive(:new_record?).once.and_return(false) 69 67 url = c.url(:blog, blog) 70 url.should == "/blogs/ 7"68 url.should == "/blogs/hello42" 71 69 end 72 70 73 71 it "should point to /blogs/ if @blog is new_record" do 74 72 c = new_url_controller(@resource_routes, :controller => "blogs", :action => "index") 75 blog = mock("blog")73 blog = Blog.new 76 74 blog.should_receive(:new_record?).once.and_return(true) 77 75 url = c.url(:blog, blog)
