Compare commits

..

No commits in common. "144731062ba0332ef8908d27939b41b82497cac3" and "ae2360a48074df6501ae2312c83d1fe67c87f6ea" have entirely different histories.

3 changed files with 1 additions and 39 deletions

14
app.rb
View File

@ -34,20 +34,6 @@ class App < Roda
flash['message'] = "Please enter a valid URL";
r.redirect '/'
end
begin
OpenURI.open_uri(url)
rescue URI::BadURIError
flash['message'] = "Invalid URL"
r.redirect '/'
rescue OpenURI::HTTPError
flash['message'] = "URL not found"
r.redirect '/'
rescue SocketError => e
flash['message'] = "URL does not resolve"
r.redirect '/'
end
if links.filter(:url => url).first.nil?
code = SecureRandom.urlsafe_base64 4
links.insert(url: url, code: code)

View File

@ -63,7 +63,7 @@ Then('I should be redirected to {string}') do |string|
end
Then('The status code should be {int}') do |code|
page.status_code.should eq(code)
puts page.status_code.should eq(code)
end

View File

@ -26,27 +26,3 @@ Feature: Submit
And I click the "Submit" button
Then I should be on "/create" page
And I should see the message "Link exists"
@db-test
Scenario: Submitting the form with a URL that is 404
Given I visit the "/" page
When I type "http://google.com/example" in the "url" field
And I click the "Submit" button
Then I should be on "/" page
And I should see the message "URL not found"
@db-test
Scenario: Submitting the form with a URL that does not resolve
Given I visit the "/" page
When I type "http://bad.tld" in the "url" field
And I click the "Submit" button
Then I should be on "/" page
And I should see the message "URL does not resolve"
@db-test
Scenario: Submitting the form with an invalid URL
Given I visit the "/" page
When I type "not-an-url" in the "url" field
And I click the "Submit" button
Then I should be on "/" page
And I should see the message "Invalid URL"