-
-
Save derekbrameyer/a2ff14712cd74ad8c402 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# user_follow_spec.rb | |
require 'spec_helper' | |
describe User do | |
it "follows users appropriately" do | |
user1 = User.create(:name => "User One", :alternate_id => "123456", :birthday => Date.civil(1988, 4, 18)) | |
user2 = User.create(:name => "User Two", :alternate_id => "234567", :birthday => Date.civil(1988, 4, 19)) | |
user1.follow(user2) | |
user1.im_following?(user2).should be_true | |
user2.followed_by?(user1).should be_true | |
end | |
it "should create the appropriate relationship types for a following" do | |
user1 = User.create(:name => "User One", :alternate_id => "123456", :birthday => Date.civil(1988, 4, 18)) | |
user2 = User.create(:name => "User Two", :alternate_id => "234567", :birthday => Date.civil(1988, 4, 19)) | |
user1.follow(user2) | |
r1 = user1.relationships.where(:user => user2) | |
r2 = user2.relationships.where(:user => user1) | |
r1.rel_type.should == "following" | |
r2.rel_type.should == "followed_by" | |
end | |
it "creates a friendship appropriately" do | |
user1 = User.create(:name => "User One", :alternate_id => "123456", :birthday => Date.civil(1988, 4, 18)) | |
user2 = User.create(:name => "User Two", :alternate_id => "234567", :birthday => Date.civil(1988, 4, 19)) | |
user1.follow(user2) | |
user2.follow(user1) | |
user1.im_following?(user2).should be_true | |
user2.im_following?(user1).should be_true | |
user1.followed_by?(user2).should be_true | |
user2.followed_by?(user1).should be_true | |
user1.friends_with?(user2).should be_true | |
user2.friends_with?(user1).should be_true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment