From 711dcdc5f42769366364ce9d36eb062bb228a705 Mon Sep 17 00:00:00 2001 From: Shawn McGuire Date: Wed, 13 Oct 2010 14:36:03 -0500 Subject: [PATCH 1/2] Issue #280 Fixed trailing whitespace error --- app/controllers/requests_controller.rb | 2 +- app/models/request.rb | 1 + spec/models/request_spec.rb | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 79a29461e..82f31152c 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -33,7 +33,7 @@ class RequestsController < ApplicationController aspect = current_user.aspect_by_id(params[:request][:aspect_id]) begin - rel_hash = relationship_flow(params[:request][:destination_url]) + rel_hash = relationship_flow(params[:request][:destination_url].strip!) rescue Exception => e raise e unless e.message.include? "not found" flash[:error] = I18n.t 'requests.create.error' diff --git a/app/models/request.rb b/app/models/request.rb index d57470745..d910cfaa2 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -48,6 +48,7 @@ class Request protected def clean_link if self.destination_url + self.destination_url = self.destination_url.strip self.destination_url = 'http://' + self.destination_url unless self.destination_url.match('https?://') self.destination_url = self.destination_url + '/' if self.destination_url[-1,1] != '/' end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index c40d1a25e..83730f10b 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -38,4 +38,11 @@ describe Request do Request.for_user(user).all.count.should == 1 end + it 'should strip the destination url' do + person_request = Request.new + person_request.destination_url = " http://google.com/ " + person_request.send(:clean_linl) + person_request.destination_url.should == "http://google.com/" + end + end From 5c26b895f2812ec18b46098649e2b92584e107e4 Mon Sep 17 00:00:00 2001 From: Shawn McGuire Date: Wed, 13 Oct 2010 14:39:04 -0500 Subject: [PATCH 2/2] Fixed trailing whitespace bug --- spec/models/request_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 83730f10b..dc5145f2a 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -41,7 +41,7 @@ describe Request do it 'should strip the destination url' do person_request = Request.new person_request.destination_url = " http://google.com/ " - person_request.send(:clean_linl) + person_request.send(:clean_link) person_request.destination_url.should == "http://google.com/" end