public
Fork of robbyrussell/rubyurl
Description: bloat me makes long urls short
Homepage: http://bloat.me
Clone URL: git://github.com/kohlhofer/rubyurl.git
Click here to lend your support to: rubyurl and make a donation at www.pledgie.com !
handle case where params[:link] is nil
mikehale (author)
Mon Sep 01 18:00:36 -0700 2008
commit  e470c9fa7b262df409851ce71dafb101721aa438
tree    4347e614bf6ac2faaf5c8fb600221a3c2389bd58
parent  0586e1381d0b09760c15260a5f2ffbedf05ae31c
...
5
6
7
8
 
 
9
10
11
...
25
26
27
28
 
29
30
31
...
5
6
7
 
8
9
10
11
12
...
26
27
28
 
29
30
31
32
0
@@ -5,7 +5,8 @@ class LinksController < ApplicationController
0
   end
0
   
0
   def create
0
-    website_url = params.include?(:website_url) ? params[:website_url] : params[:link][:website_url]
0
+    website_url = params[:link][:website_url] if params.include?(:link)
0
+        
0
     @link = Link.find_or_create_by_website_url( website_url )
0
     @link.ip_address = request.remote_ip if @link.new_record?
0
     
0
@@ -25,7 +26,7 @@ class LinksController < ApplicationController
0
       @link.add_visit(request)
0
       redirect_to @link.website_url, { :status => 301 }
0
     else
0
-      redirect_to :action => 'invalid'
0
+      redirect_to :action => :invalid
0
     end
0
   end
0
 end
...
27
28
29
 
 
 
 
 
30
31
32
...
27
28
29
30
31
32
33
34
35
36
37
0
@@ -27,6 +27,11 @@ describe LinksController do
0
     post :create, :link => valid_attributes.except(:website_url)
0
     assigns(:link).should have_at_least(1).errors_on(:website_url)
0
   end
0
+
0
+  it "should not save a new link wihout a website url" do
0
+    post :create
0
+    assigns(:link).should have_at_least(1).errors_on(:website_url)
0
+  end
0
   
0
   it "should save a new link with valid attributes" do
0
     lambda do

Comments