Skip to content
Browse files

Redirect to homepage if attempting to create a short url and failing

  • Loading branch information...
1 parent e371b33 commit ac115ceb9fa84e0ab8275c57adb0b270732572d9 @joshuaclayton committed Nov 2, 2009
Showing with 9 additions and 1 deletion.
  1. +3 −1 app/controllers/peas_controller.rb
  2. +6 −0 features/generate_shortened_urls.feature
View
4 app/controllers/peas_controller.rb
@@ -18,7 +18,9 @@ def create
if (pea = Pea.find_by_long_url(params[:pea][:long_url]))
return redirect_to(pea_path(pea))
end
- create!
+ create! do |success, failure|
+ failure.html { redirect_to root_path }
+ end
end
def redir
View
6 features/generate_shortened_urls.feature
@@ -17,3 +17,9 @@ Feature: Generate shortened URLs
And I press "Shorten"
Then I should see "http://www.google.com was shortened to:"
And I should see a short URL for "http://www.google.com"
+
+ Scenario: Shorten an empty string
+ When I go to the homepage
+ And I fill in "Enter your long URL" with ""
+ And I press "Shorten"
+ Then I should be on the homepage

0 comments on commit ac115ce

Please sign in to comment.
Something went wrong with that request. Please try again.