added favorite unit tests

This commit is contained in:
albert
2010-02-12 18:46:43 -05:00
parent b1c7fd04a8
commit 661c214094
7 changed files with 80 additions and 5 deletions

View File

@@ -221,11 +221,13 @@ class Post < ActiveRecord::Base
def add_favorite(user)
self.fav_string += " fav:#{user.name}"
self.fav_string.strip!
Favorite.create(user, self)
end
def remove_favorite(user)
self.fav_string.gsub!(/fav:#{user.name}\b\s*/, " ")
self.fav_string.strip!
Favorite.destroy(user, self)
end
end