Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

crazy hustling rasta frog test suite works

  • Loading branch information...
commit f9d8585c31abac9be196762e4b6ce3a1248f3f74 1 parent ae69731
Dan Croak authored

Showing 3 changed files with 8 additions and 6 deletions. Show diff stats Hide diff stats

  1. +3 3 README.md
  2. +0 1  features/test_helper.rb
  3. +5 2 shorty.rb
6 README.md
Source Rendered
@@ -13,8 +13,8 @@ Hosting
13 13
14 14 I recommend using [Heroku](http://heroku.com) for the app and [MongoHQ](http://mongohq.com) for storage.
15 15
16   -Features
17   ---------
  16 +Feature
  17 +-------
18 18
19 19 Feature 'Shorten URL' do
20 20 Given 'I am on the homepage' do
@@ -35,7 +35,7 @@ Features
35 35 end
36 36
37 37 Then 'I should be on http://dancroak.com' do
38   - assert_equal 'http://dancroak.org', current_url
  38 + assert_equal 'http://dancroak.com', current_url
39 39 end
40 40 end
41 41
1  features/test_helper.rb
@@ -47,4 +47,3 @@ def default_test
47 47 def class_name(name)
48 48 name.gsub(' ', '_').gsub(/(?:^|_)(.)/) { $1.upcase }
49 49 end
50   -
7 shorty.rb
@@ -4,7 +4,8 @@
4 4
5 5 include Mongo
6 6
7   -DB = Connection.new(ENV['DATABASE_URL'] || 'localhost').db('shorty')
  7 +ConnectFour = Connection.new(ENV['DATABASE_URL'] || 'localhost')
  8 +DB = ConnectFour.db('shorty')
8 9 if ENV['DATABASE_USER'] && ENV['DATABASE_PASSWORD']
9 10 auth = DB.authenticate(ENV['DATABASE_USER'], ENV['DATABASE_PASSWORD'])
10 11 end
@@ -46,7 +47,9 @@ def reject_blank(url)
46 47 end
47 48
48 49 def shorten(url)
49   - DB['urls'].insert('url' => url, 'slug' => DB['urls'].count.to_s(36))
  50 + if DB['urls'].find('url' => url).count == 0
  51 + DB['urls'].insert('url' => url, 'slug' => DB['urls'].count.to_s(36))
  52 + end
50 53 end
51 54
52 55 def slug_for(url)

0 comments on commit f9d8585

Please sign in to comment.
Something went wrong with that request. Please try again.