Skip to content
Extraits de code Groupes Projets
Valider f9cecd9d rédigé par ilya's avatar ilya
Parcourir les fichiers

specs are green

parent 304e4ad3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
module Diaspora module Diaspora
module UserModules module UserModules
module Receiving module Receiving
def receive_salmon ciphertext def receive_salmon salmon_xml
cleartext = decrypt( ciphertext) salmon = Salmon::SalmonSlap.parse salmon_xml, self
salmon = Salmon::SalmonSlap.parse cleartext, self
if salmon.verified_for_key?(salmon.author.public_key) if salmon.verified_for_key?(salmon.author.public_key)
Rails.logger.info("data in salmon: #{salmon.parsed_data}") Rails.logger.info("data in salmon: #{salmon.parsed_data}")
self.receive(salmon.parsed_data) self.receive(salmon.parsed_data)
......
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
require 'spec_helper' require 'spec_helper'
describe PublicsController do describe PublicsController do
render_views render_views
let(:user) {Factory.create :user}
before do before do
@user = Factory.create(:user) sign_in :user, user
sign_in :user, @user
end end
describe 'receive endpoint' do describe 'receive endpoint' do
it 'should have a and endpoint and return a 200 on successful receipt of a request' do it 'should have a and endpoint and return a 200 on successful receipt of a request' do
post :receive, :id =>@user.person.id post :receive, :id =>user.person.id
response.code.should == '200' response.code.should == '200'
end end
...@@ -22,14 +22,15 @@ describe PublicsController do ...@@ -22,14 +22,15 @@ describe PublicsController do
user2 = Factory.create(:user) user2 = Factory.create(:user)
message = user2.build_post(:status_message, :message => "hi") message = user2.build_post(:status_message, :message => "hi")
@user.reload user.reload
@user.visible_post_ids.include?(message.id).should be false user.visible_post_ids.include?(message.id).should be false
xml = @user.person.encrypt(user2.salmon(message, :to => @user.person).to_xml)
xml = user2.salmon(message).xml_for(user.person)
post :receive, :id => @user.person.id, :xml => xml post :receive, :id => user.person.id, :xml => xml
@user.reload user.reload
@user.visible_post_ids.include?(message.id).should be true user.visible_post_ids.include?(message.id).should be true
end end
end end
...@@ -47,9 +48,9 @@ describe PublicsController do ...@@ -47,9 +48,9 @@ describe PublicsController do
@user3 = Factory.create(:user) @user3 = Factory.create(:user)
req = @user2.send_friend_request_to(@user.person, aspect) req = @user2.send_friend_request_to(user.person, aspect)
@xml = @user.person.encrypt(@user2.salmon(req, :to => @user.person).to_xml) @xml = @user2.salmon(req).xml_for(user.person)
req.delete req.delete
@user2.reload @user2.reload
...@@ -58,18 +59,18 @@ describe PublicsController do ...@@ -58,18 +59,18 @@ describe PublicsController do
it 'should add the pending request to the right user if the target person exists locally' do it 'should add the pending request to the right user if the target person exists locally' do
@user2.delete @user2.delete
post :receive, :id => @user.person.id, :xml => @xml post :receive, :id => user.person.id, :xml => @xml
assigns(:user).should eq(@user) assigns(:user).should eq(user)
end end
it 'should add the pending request to the right user if the target person does not exist locally' do it 'should add the pending request to the right user if the target person does not exist locally' do
Person.should_receive(:by_webfinger).with(@user2.person.diaspora_handle).and_return(@user2.person) Person.should_receive(:by_webfinger).with(@user2.person.diaspora_handle).and_return(@user2.person)
@user2.person.delete @user2.person.delete
@user2.delete @user2.delete
post :receive, :id => @user.person.id, :xml => @xml post :receive, :id => user.person.id, :xml => @xml
assigns(:user).should eq(@user) assigns(:user).should eq(user)
end end
end end
end end
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