Compare commits

..

2 Commits

2 changed files with 7 additions and 3 deletions

8
app.rb
View File

@ -18,8 +18,12 @@ class App < Roda
end
r.get String do | url_code |
link = links.filter(:code => url_code).first[:url]
r.redirect link
link = links.filter(:code => url_code)
if link.first.nil?
flash['message'] = "Link #{url_code} doesn't exist"
r.redirect '/'
end
r.redirect link.first[:url]
end
r.post "create" do

View File

@ -42,5 +42,5 @@ Feature: Homepage
Scenario: Accessing a nonexistent URL code
Given I visit the "/aaaaaa" location
Then I should be redirected to "/"
Then I should be on "/" page
And I should see the message "Link aaaaaa doesn't exist"