Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete Release 3 #38

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Complete Release 3 #38

wants to merge 9 commits into from

Conversation

lnestor
Copy link

@lnestor lnestor commented May 14, 2018

@jaybobo I haven't completed all parts, but I figured I'll commit each time I finish a step. I'll ping you when it is completely done too.

@lnestor lnestor changed the title WIP Complete Release 0 WIP Complete Release 3 May 14, 2018
@jaybobo
Copy link
Member

jaybobo commented May 15, 2018

@lnestor cool! i'm loving the early specs and TDD approach by the way.

@lnestor lnestor changed the title WIP Complete Release 3 Complete Release 3 May 15, 2018
@lnestor
Copy link
Author

lnestor commented May 15, 2018

@jaybobo I've done all the main tasks, so I'm tagging you. I'll go ahead and work on the extra credit part.


<ul>
<% @urls.each do |url| %>
<li><%= "0.0.0.0:3000/urls/#{url.id} ====> #{url.long_url} (clicked #{url.click_count} times)" %></li>
Copy link
Member

@mikegee mikegee May 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your routes file has a :urls resource with a :show action, so it should generate route helper methods for you. The name of it is kinda unfortunate in this case:

I think url_url(url) should output something like "0.0.0.0:3000/urls/#{url.id}" here. (and will remain correct in non-development environments)

@mikegee
Copy link
Member

mikegee commented May 16, 2018

I don't see implementation for these URL validations yet:

  • Any string that the Ruby URI module says is valid
  • Any URL-looking thing which responds to a HTTP request, i.e., we actually check to see if the URL is accessible via HTTP

private

def reset_click_count
self.click_count = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the migration put a default of zero in the db, ActiveRecord would respect that when you make new instances of this class.


def long_url_is_reachable
begin
response = HTTParty.get(long_url, timeout: 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default timeout == ain't nobody got time for that 👍

class Url < ActiveRecord::Base
before_create :reset_click_count

validates :long_url, presence: true, format: { with: /http(|s):\/\/.+/ }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could nitpick this format regexp, but I'm not sure if it is needed. Is the URI::regexp matching sufficient?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - this is leftover from before I implemented the URI matching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants