Fix some comment specs (still one failing). Remove warning from receive spec.
This commit is contained in:
parent
06e2b43516
commit
e414b1c553
2 changed files with 28 additions and 26 deletions
|
|
@ -10,18 +10,22 @@ describe Comment do
|
||||||
|
|
||||||
let(:user2) {Factory.create(:user)}
|
let(:user2) {Factory.create(:user)}
|
||||||
let(:aspect2) {user2.aspect(:name => "Lame-faces")}
|
let(:aspect2) {user2.aspect(:name => "Lame-faces")}
|
||||||
describe 'User#comment' do
|
|
||||||
let(:status) {user.post(:status_message, :message => "hello", :to => aspect)}
|
|
||||||
it "should be able to comment on his own status" do
|
|
||||||
status.comments.should == []
|
|
||||||
|
|
||||||
user.comment "Yeah, it was great", :on => status
|
describe 'User#comment' do
|
||||||
status.reload.comments.first.text.should == "Yeah, it was great"
|
before do
|
||||||
|
@status = user.post(:status_message, :message => "hello", :to => aspect.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be able to comment on his own status" do
|
||||||
|
@status.comments.should == []
|
||||||
|
|
||||||
|
user.comment "Yeah, it was great", :on => @status
|
||||||
|
@status.reload.comments.first.text.should == "Yeah, it was great"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to comment on a person's status" do
|
it "should be able to comment on a person's status" do
|
||||||
user2.comment "sup dog", :on => status
|
user2.comment "sup dog", :on => @status
|
||||||
status.reload.comments.first.text.should == "sup dog"
|
@status.reload.comments.first.text.should == "sup dog"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -42,34 +46,32 @@ describe Comment do
|
||||||
@person_status = Factory.build(:status_message, :person => @person)
|
@person_status = Factory.build(:status_message, :person => @person)
|
||||||
|
|
||||||
user.reload
|
user.reload
|
||||||
user_status = user.post :status_message, :message => "hi", :to => aspect.id
|
@user_status = user.post :status_message, :message => "hi", :to => aspect.id
|
||||||
|
|
||||||
aspect.reload
|
aspect.reload
|
||||||
user.reload
|
user.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should receive a comment from a person not on the pod' do
|
it 'should receive a comment from a person not on the pod' do
|
||||||
user3 = Factory.create :user
|
user3 = Factory.create(:user)
|
||||||
aspect3 = user3.aspect(:name => "blah")
|
aspect3 = user3.aspect(:name => "blah")
|
||||||
|
|
||||||
friend_users(user, aspect, user3, aspect3)
|
friend_users(user, aspect, user3, aspect3)
|
||||||
|
|
||||||
comment = Comment.new(:person_id => user3.person.id, :text => "hey", :post => user_status)
|
comment = Comment.new(:person_id => user3.person.id, :text => "hey", :post => @user_status)
|
||||||
comment.creator_signature = comment.sign_with_key(user3.encryption_key)
|
comment.creator_signature = comment.sign_with_key(user3.encryption_key)
|
||||||
|
|
||||||
|
|
||||||
comment.post_creator_signature = comment.sign_with_key(user.encryption_key)
|
comment.post_creator_signature = comment.sign_with_key(user.encryption_key)
|
||||||
xml = user.salmon(comment).xml_for(user2)
|
|
||||||
|
xml = user.salmon(comment).xml_for(user3)
|
||||||
|
|
||||||
user3.person.delete
|
user3.person.delete
|
||||||
user3.delete
|
user3.delete
|
||||||
|
|
||||||
|
@user_status.reload
|
||||||
user_status.reload
|
@user_status.comments.should == []
|
||||||
user_status.comments.should == []
|
|
||||||
user.receive_salmon(xml)
|
user.receive_salmon(xml)
|
||||||
user_status.reload
|
@user_status.reload
|
||||||
user_status.comments.include?(comment).should be true
|
@user_status.comments.include?(comment).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should send a user's comment on a person's post to that person" do
|
it "should send a user's comment on a person's post to that person" do
|
||||||
|
|
@ -80,17 +82,17 @@ describe Comment do
|
||||||
it 'should send a user comment on his own post to lots of people' do
|
it 'should send a user comment on his own post to lots of people' do
|
||||||
|
|
||||||
User::QUEUE.should_receive(:add_post_request).twice
|
User::QUEUE.should_receive(:add_post_request).twice
|
||||||
user.comment "yo", :on => user_status
|
user.comment "yo", :on => @user_status
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should send a comment a person made on your post to all people' do
|
it 'should send a comment a person made on your post to all people' do
|
||||||
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => user_status)
|
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status)
|
||||||
User::QUEUE.should_receive(:add_post_request).twice
|
User::QUEUE.should_receive(:add_post_request).twice
|
||||||
user.receive comment.to_diaspora_xml, @person
|
user.receive comment.to_diaspora_xml, @person
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should send a comment a user made on your post to all people' do
|
it 'should send a comment a user made on your post to all people' do
|
||||||
comment = user2.comment( "balls", :on => user_status)
|
comment = user2.comment( "balls", :on => @user_status)
|
||||||
User::QUEUE.should_receive(:add_post_request).twice
|
User::QUEUE.should_receive(:add_post_request).twice
|
||||||
user.receive comment.to_diaspora_xml, user2.person
|
user.receive comment.to_diaspora_xml, user2.person
|
||||||
end
|
end
|
||||||
|
|
@ -108,13 +110,13 @@ describe Comment do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not clear the aspect post array on receiving a comment' do
|
it 'should not clear the aspect post array on receiving a comment' do
|
||||||
aspect.post_ids.include?(user_status.id).should be true
|
aspect.post_ids.include?(@user_status.id).should be true
|
||||||
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => user_status)
|
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status)
|
||||||
|
|
||||||
user.receive comment.to_diaspora_xml, @person
|
user.receive comment.to_diaspora_xml, @person
|
||||||
|
|
||||||
aspect.reload
|
aspect.reload
|
||||||
aspect.post_ids.include?(user_status.id).should be true
|
aspect.post_ids.include?(@user_status.id).should be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
describe 'serialization' do
|
describe 'serialization' do
|
||||||
|
|
@ -27,7 +27,7 @@ describe User do
|
||||||
status_message.destroy
|
status_message.destroy
|
||||||
|
|
||||||
user
|
user
|
||||||
lambda {user.receive xml , user2.person}.should change (Post,:count).by(1)
|
lambda {user.receive xml , user2.person}.should change(Post,:count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not create new aspects on message receive' do
|
it 'should not create new aspects on message receive' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue