Permalink
Browse files

Spec for represented. Fixes #19

  • Loading branch information...
1 parent f9b11d7 commit 24e4131ae5620903120bc319a31aeea51443497f @atd atd committed Jul 11, 2011
Showing with 48 additions and 12 deletions.
  1. +48 −12 spec/models/user_spec.rb
@@ -1,22 +1,58 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe User do
- it "should find by slug" do
- user = Factory(:user)
-
- assert user.should == User.find_by_slug(user.slug)
+ before do
+ @user = Factory(:user)
end
- it "should represent" do
- tie = Factory(:member)
- group = tie.sender_subject
- user = tie.receiver_subject
-
- assert user.represented.should include(group)
+ it "should find by slug" do
+ assert @user.should == User.find_by_slug(@user.slug)
+ end
- tie = Factory(:partner, :receiver => user.actor)
+ context "member of a group" do
+ before do
+ tie = Factory(:member, :contact => Factory(:group_contact, :receiver => @user.actor))
+ @group = tie.sender_subject
+ end
+
+ context "without accept the group" do
+ it "should not represent" do
+ @user.represented.should_not include(@group)
+ end
+ end
+
+ context "accepting the group" do
+ before do
+ Factory(:friend, :contact => @user.contact_to!(@group))
+ end
+
+ it "should represent" do
+ @user.represented.should include(@group)
+ end
+ end
+ end
- assert ! user.represented.include?(tie.sender_subject)
+ context "partner of a group" do
+ before do
+ tie = Factory(:partner, :contact => Factory(:group_contact, :receiver => @user.actor))
+ @group = tie.receiver_subject
+ end
+
+ context "without accept the group" do
+ it "should not represent" do
+ @user.represented.should_not include(@group)
+ end
+ end
+
+ context "accepting the group" do
+ before do
+ Factory(:friend, :contact => @user.contact_to!(@group))
+ end
+
+ it "should not represent" do
+ @user.represented.should_not include(@group)
+ end
+ end
end
it "should have activity object" do

0 comments on commit 24e4131

Please sign in to comment.