This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Daniel Fischer (author)
Fri Mar 14 03:57:04 -0700 2008
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Fri Mar 14 03:57:04 -0700 2008 | [Daniel Fischer] |
| |
README.textile | Fri Mar 14 03:48:46 -0700 2008 | [Daniel Fischer] |
| |
Rakefile | Fri Mar 14 03:32:36 -0700 2008 | [Daniel Fischer] |
| |
init.rb | Fri Mar 14 03:32:36 -0700 2008 | [Daniel Fischer] |
| |
lib/ | Fri Mar 14 03:32:36 -0700 2008 | [Daniel Fischer] |
README.textile
Fischyfriends =============
Pre-productioon plugin released to the public.
The basic idea is that there are two classes of users.
Fans, and mutual fans. If two people are fans, they are mutual fans, and thereby in my definition, friends.
Make sure you create a friendship model and this migration:
create_table "friendships", :force => true do |t|
t.integer "user_id", :null => false
t.integer "friend_id", :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
#friendship.rb
class Friendship < ActiveRecord::Base
belongs_to :friendshipped_by_me, :foreign_key => :user_id, :class_name => "User"
belongs_to :friendshipped_for_me, :foreign_key => :friend_id, :class_name => "User"
end
Also add this in your user model:
#user.rb
acts_as_fischyfriend
RSpec Example =======
require File.dirname(__FILE__) + '/../spec_helper'
describe Friendship do
before(:each) do
@friendship = Friendship.new
end
it "should be valid" do
@friendship.should be_valid
end
end
describe Friendship, "between two users" do
fixtures :users
before(:each) do
@quentin = users(:quentin)
@bob = users(:aaron)
@wtf = User.create!(:login => 'a_user', :password => 'password', :password_confirmation => 'password', :email => 'poop@poop.com')
end
it "should acknowledge there is a friendship between them" do
@bob.add_friend @quentin
@bob.add_friend @wtf
@quentin.add_friend @bob
@bob.reload
@bob.is_a_fan_of.should include(@wtf)
@bob.is_a_fan_of.should_not include(@quentin)
@bob.pending_mutual_friends.should include(@wtf)
@bob.pending_mutual_friends.should_not include(@quentin)
@wtf.mutual_friends.should be_empty
@wtf.fans_of_me.should include(@bob)
@quentin.reload
@quentin.mutual_friends.should include(@bob)
@quentin.mutual_friends.should_not include(@wtf)
@quentin.destroy_friendship_with @bob
@quentin.reload
@quentin.friends_by_me.should_not include(@bob)
end
end
Copyright© 2008 [Daniel Fischer] / http://www.danielfischer.com, released under the MIT license




