Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Show a message when a link doesn't exist

  • Loading branch information...
commit ceb441881b32f56ebad9fb1567855ee3b3f028eb 1 parent e3dffe9
@drapergeek authored
View
7 app/controllers/short_urls_controller.rb
@@ -15,6 +15,11 @@ def create
def show
short_url = ShortUrl.find_by_name(params[:name])
- redirect_to short_url.url
+ if short_url
+ redirect_to short_url.url
+ else
+ flash[:notice] = "This link does not exist."
+ redirect_to root_path
+ end
end
end
View
6 spec/features/visit_short_url_spec.rb
@@ -9,4 +9,10 @@
page.should have_content 'Google'
end
+
+ scenario 'visiting an invalid link' do
+ visit '/linkthatdoesnotexist'
+
+ page.should have_content 'This link does not exist.'
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.