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 end
r.get String do | url_code | r.get String do | url_code |
link = links.filter(:code => url_code).first[:url] link = links.filter(:code => url_code)
r.redirect link if link.first.nil?
flash['message'] = "Link #{url_code} doesn't exist"
r.redirect '/'
end
r.redirect link.first[:url]
end end
r.post "create" do r.post "create" do

View File

@ -42,5 +42,5 @@ Feature: Homepage
Scenario: Accessing a nonexistent URL code Scenario: Accessing a nonexistent URL code
Given I visit the "/aaaaaa" location 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" And I should see the message "Link aaaaaa doesn't exist"