Permalink
Browse files

crazy hustling rasta frog test suite works

  • Loading branch information...
1 parent ae69731 commit f9d8585c31abac9be196762e4b6ce3a1248f3f74 @croaky committed Nov 4, 2009
Showing with 8 additions and 6 deletions.
  1. +3 −3 README.md
  2. +0 −1 features/test_helper.rb
  3. +5 −2 shorty.rb
View
@@ -13,8 +13,8 @@ Hosting
I recommend using [Heroku](http://heroku.com) for the app and [MongoHQ](http://mongohq.com) for storage.
-Features
---------
+Feature
+-------
Feature 'Shorten URL' do
Given 'I am on the homepage' do
@@ -35,7 +35,7 @@ Features
end
Then 'I should be on http://dancroak.com' do
- assert_equal 'http://dancroak.org', current_url
+ assert_equal 'http://dancroak.com', current_url
end
end
View
@@ -47,4 +47,3 @@ def default_test
def class_name(name)
name.gsub(' ', '_').gsub(/(?:^|_)(.)/) { $1.upcase }
end
-
View
@@ -4,7 +4,8 @@
include Mongo
-DB = Connection.new(ENV['DATABASE_URL'] || 'localhost').db('shorty')
+ConnectFour = Connection.new(ENV['DATABASE_URL'] || 'localhost')
+DB = ConnectFour.db('shorty')
if ENV['DATABASE_USER'] && ENV['DATABASE_PASSWORD']
auth = DB.authenticate(ENV['DATABASE_USER'], ENV['DATABASE_PASSWORD'])
end
@@ -46,7 +47,9 @@ def reject_blank(url)
end
def shorten(url)
- DB['urls'].insert('url' => url, 'slug' => DB['urls'].count.to_s(36))
+ if DB['urls'].find('url' => url).count == 0
+ DB['urls'].insert('url' => url, 'slug' => DB['urls'].count.to_s(36))
+ end
end
def slug_for(url)

0 comments on commit f9d8585

Please sign in to comment.