Skip to content
Extraits de code Groupes Projets
Valider 0ce37bbf rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Remove some extra receives in tests

parent cc92f615
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -80,14 +80,11 @@ describe StatusMessagesController do
end
it 'will not let you destroy posts visible to you' do
user.receive message2.to_diaspora_xml, user2.person
user.visible_posts.include?(message2).should be true
delete :destroy, :id => message2.id
StatusMessage.find_by_id(message2.id).should_not be_nil
end
it 'will not let you destory posts you do not own' do
user.visible_posts.include?(message2).should be false
delete :destroy, :id => message2.id
StatusMessage.find_by_id(message2.id).should_not be_nil
end
......
......@@ -9,8 +9,7 @@ describe Diaspora::Parser do
let(:aspect) { user.aspects.create(:name => 'spies') }
let(:user2) { make_user }
let(:aspect2) { user2.aspects.create(:name => "pandas") }
let(:user3) { make_user }
let(:person) { user3.person }
let(:person) { Factory.create(:person)}
describe "parsing compliant XML object" do
it 'should be able to correctly parse comment fields' do
......@@ -52,21 +51,13 @@ describe Diaspora::Parser do
end
it "should activate the Person if I initiated a request to that url" do
request = user.send_friend_request_to(user3.person, aspect)
user.reload
reversed = request.reverse_for user3
xml = user3.salmon(reversed).xml_for(user.person)
user3.delete
user.receive_salmon(xml)
new_person = Person.find_by_url(user3.person.url)
new_person.nil?.should be false
user.send_friend_request_to(user2.person, aspect)
request = user2.reload.pending_requests.find_by_destination_url!(user2.receive_url)
user2.accept_and_respond(request.id, aspect2.id)
user.reload
aspect.reload
new_contact = user.contact_for(new_person)
new_contact = user.contact_for(user2.person)
aspect.people.include?(new_contact).should be true
user.friends.include?(new_contact).should be true
end
......
......@@ -120,8 +120,6 @@ describe Aspect do
message = user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
user.receive message.to_diaspora_xml, user2.person
aspect.reload
aspect.posts.include?(message).should be true
user.visible_posts(:by_members_of => aspect).include?(message).should be true
......@@ -134,14 +132,9 @@ describe Aspect do
message = user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
user.receive message.to_diaspora_xml, user2.person
aspect.reload
aspect.post_ids.include?(message.id).should be true
aspect.reload.post_ids.include?(message.id).should be true
retraction = user2.retract(message)
user.receive retraction.to_diaspora_xml, user2.person
aspect.reload
aspect.post_ids.include?(message.id).should be false
......@@ -195,11 +188,9 @@ describe Aspect do
context 'moving and removing posts' do
let(:message) { user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)}
let(:message2){user3.post(:status_message, :message => "other post", :to => aspect3.id)}
before do
user.receive message.to_diaspora_xml, user2.person
@message = user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
aspect.reload
@post_count = aspect.posts.count
@post_count1 = aspect1.posts.count
......@@ -208,9 +199,9 @@ describe Aspect do
end
it 'moves the persons posts into the new aspect' do
user.add_person_to_aspect(user2.person.id, aspect1.id, :posts => [message] )
user.add_person_to_aspect(user2.person.id, aspect1.id, :posts => [@message] )
aspect1.reload
aspect1.posts.should == [message]
aspect1.posts.should == [@message]
end
......@@ -222,10 +213,9 @@ describe Aspect do
it 'should not delete other peoples posts' do
friend_users(user, aspect, user3, aspect3)
user.receive message2.to_diaspora_xml, user3.person
user.delete_person_from_aspect(user2.person.id, aspect.id)
user.delete_person_from_aspect(user3.person.id, aspect.id)
aspect.reload
aspect.posts.should == [message2]
aspect.posts.should == [@message]
end
describe '#move_friend' do
......
......@@ -5,9 +5,9 @@
require 'spec_helper'
describe Request do
let(:user) { make_user }
let(:user2) { make_user}
let(:person) {Factory :person}
let(:user) { make_user }
let(:user2) { make_user }
let(:person) { Factory :person }
let(:aspect) { user.aspects.create(:name => "dudes") }
let(:request){ user.send_friend_request_to user2.person, aspect }
......@@ -30,22 +30,19 @@ describe Request do
describe '#request_from_me' do
it 'recognizes requests from me' do
request
user.reload
user.request_from_me?(request).should be true
user.request_from_me?(request).should be_true
end
it 'recognized when a request is not from me' do
user2.receive_salmon(user.salmon(request).xml_for(user2.person))
user2.reload
user2.request_from_me?(request).should == false
user2.request_from_me?(request).should be_false
end
end
context 'quering request through user' do
it 'finds requests for that user' do
len = user2.requests_for_me.size
user2.receive_salmon(user.salmon(request).xml_for(user2.person))
user2.reload.requests_for_me.size.should == len + 1
request
user2.reload
user2.requests_for_me.detect{|r| r.callback_url == user.receive_url}.should_not be_nil
end
end
......
......@@ -15,8 +15,6 @@ describe User do
let(:user3) { make_user }
let(:aspect3) { user3.aspects.create(:name => 'heroes') }
let!(:status) {user.post(:status_message, :message => "Original", :to => aspect.id)}
let(:photo) {user.post(:photo, :user_file => uploaded_photo, :caption => "Original", :to => aspect.id)}
before do
friend_users(user, aspect, user2, aspect2)
......@@ -43,11 +41,9 @@ describe User do
it 'should not create new aspects on message receive' do
num_aspects = user.aspects.size
(0..5).each{ |n|
2.times do |n|
status_message = user2.post :status_message, :message => "store this #{n}!", :to => aspect2.id
xml = status_message.to_diaspora_xml
user.receive xml, user2.person
}
end
user.aspects.size.should == num_aspects
end
......@@ -56,33 +52,28 @@ describe User do
it 'should handle the case where the webfinger fails' do
Person.should_receive(:by_account_identifier).and_return("not a person")
proc{user2.receive_salmon(user.salmon(status).xml_for(user2.person))}.should_not raise_error
proc{
user2.post :status_message, :message => "store this!", :to => aspect2.id
}.should_not raise_error
end
end
context 'update posts' do
it 'does not update posts not marked as mutable' do
user2.receive_salmon(user.salmon(status).xml_for(user2.person))
status = user.post :status_message, :message => "store this!", :to => aspect.id
status.message = 'foo'
xml = user.salmon(status).xml_for(user2.person)
status.reload.message.should == 'Original'
user2.receive_salmon(xml)
xml = status.to_diaspora_xml
user2.receive(xml, user.person)
status.reload.message.should == 'Original'
status.reload.message.should == 'store this!'
end
it 'updates posts marked as mutable' do
user2.receive_salmon(user.salmon(photo).xml_for(user2.person))
photo = user.post(:photo, :user_file => uploaded_photo, :caption => "Original", :to => aspect.id)
photo.caption = 'foo'
xml = user.salmon(photo).xml_for(user2.person)
photo.reload.caption.should match(/Original/)
user2.receive_salmon(xml)
xml = photo.to_diaspora_xml
user2.reload.receive(xml, user.person)
photo.reload.caption.should match(/foo/)
end
......@@ -103,7 +94,7 @@ describe User do
it 'should be removed on unfriending' do
user.unfriend(user2.person)
user.reload
user.raw_visible_posts.count.should == 1
user.raw_visible_posts.should_not include @status_message
end
it 'should be remove a post if the noone links to it' do
......@@ -145,7 +136,7 @@ describe User do
@comment = user3.comment('tada',:on => @post)
@comment.post_creator_signature = @comment.sign_with_key(user.encryption_key)
@xml = user.salmon(@comment).xml_for(user2.person)
@xml = @comment.to_diaspora_xml
@comment.delete
end
......@@ -155,7 +146,7 @@ describe User do
user2.reload.raw_visible_posts.size.should == 1
post_in_db = user2.raw_visible_posts.first
post_in_db.comments.should == []
user2.receive_salmon(@xml)
user2.receive(@xml, user.person)
post_in_db.reload
post_in_db.comments.include?(@comment).should be true
......@@ -168,14 +159,14 @@ describe User do
user3.delete
#stubs async webfinger
Person.should_receive(:by_account_identifier).twice.and_return{ |handle| if handle == user.person.diaspora_handle; user.person.save
Person.should_receive(:by_account_identifier).and_return{ |handle| if handle == user.person.diaspora_handle; user.person.save
user.person; else; remote_person.save; remote_person; end }
user2.reload.raw_visible_posts.size.should == 1
post_in_db = user2.raw_visible_posts.first
post_in_db.comments.should == []
user2.receive_salmon(@xml)
user2.receive(@xml, user.person)
post_in_db.reload
post_in_db.comments.include?(@comment).should be true
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter