Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
8f2cad776b
10 changed files with 51 additions and 21 deletions
|
|
@ -56,7 +56,7 @@ class PublicsController < ApplicationController
|
|||
end
|
||||
|
||||
@user = person.owner
|
||||
Resque.enqueue(Jobs::ReceiveSalmon, @user.id, params[:xml])
|
||||
Resque.enqueue(Jobs::ReceiveSalmon, @user.id, CGI::unescape(params[:xml]))
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
|
|
|||
|
|
@ -76,6 +76,15 @@ namespace :fixtures do
|
|||
user3.reload
|
||||
user4.receive(remote_photo.to_diaspora_xml, remote_person)
|
||||
user3.reload
|
||||
|
||||
|
||||
facebook = Services::Facebook.new(:access_token => "yeah")
|
||||
user3.services << facebook
|
||||
facebook.save!
|
||||
|
||||
twitter = Services::Twitter.new(:access_token => "yeah", :access_secret => "foobar")
|
||||
user2.services << twitter
|
||||
twitter.save!
|
||||
end
|
||||
puts "Done generating fixtures, you can now export"
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,20 @@ describe PublicsController do
|
|||
post :receive, "id" => user.person.id.to_s, "xml" => xml
|
||||
end
|
||||
|
||||
it 'unescapes the xml before sending it to receive_salmon' do
|
||||
aspect = user.aspects.create(:name => 'foo')
|
||||
post1 = user.post(:status_message, :message => 'moms', :to => [aspect.id])
|
||||
xml2 = post1.to_diaspora_xml
|
||||
user2 = make_user
|
||||
|
||||
salmon_factory = Salmon::SalmonSlap.create(user, xml2)
|
||||
enc_xml = salmon_factory.xml_for(user2.person)
|
||||
|
||||
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, user.id, enc_xml).once
|
||||
|
||||
post :receive, "id" => user.person.id.to_s, "xml" => CGI::escape(enc_xml)
|
||||
end
|
||||
|
||||
it 'returns a 422 if no xml is passed' do
|
||||
post :receive, "id" => person.id.to_s
|
||||
response.code.should == '422'
|
||||
|
|
|
|||
|
|
@ -8,14 +8,6 @@ module HelperMethods
|
|||
Mocha::Mockery.instance.stubba.unstub_all
|
||||
end
|
||||
|
||||
def fantasy_resque
|
||||
former_value = $process_queue
|
||||
$process_queue = true
|
||||
result = yield
|
||||
$process_queue = former_value
|
||||
result
|
||||
end
|
||||
|
||||
def connect_users(user1, aspect1, user2, aspect2)
|
||||
Contact.create!(:user => user1,
|
||||
:person => user2.person,
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PubSubHubbub do
|
||||
before :all do
|
||||
before do
|
||||
RestClient.unstub!(:post)
|
||||
end
|
||||
|
||||
after :all do
|
||||
after do
|
||||
RestClient.stub!(:post).and_return(FakeHttpRequest.new(:success))
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,4 +13,3 @@ describe Jobs::PostToService do
|
|||
Jobs::PostToService.perform("123", post.id.to_s, url)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
|||
describe Jobs::ReceiveSalmon do
|
||||
before do
|
||||
@user = make_user
|
||||
@user2 = make_user
|
||||
@xml = '<xml></xml>'
|
||||
User.stub(:find){ |id|
|
||||
if id == @user.id
|
||||
|
|
@ -16,4 +17,7 @@ describe Jobs::ReceiveSalmon do
|
|||
@user.should_receive(:receive_salmon).with(@xml).once
|
||||
Jobs::ReceiveSalmon.perform(@user.id, @xml)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,14 +49,16 @@ describe User do
|
|||
end
|
||||
|
||||
describe '#receive_salmon' do
|
||||
it 'should handle the case where the webfinger fails' do
|
||||
pending "Write this to test #receive_salmon"
|
||||
Webfinger.stub!(:fetch).and_return(nil)
|
||||
it 'should handle the case where the webfinger fails' do
|
||||
pending "Write this to test #receive_salmon"
|
||||
Webfinger.stub!(:fetch).and_return(nil)
|
||||
|
||||
proc{
|
||||
user2.post :status_message, :message => "store this!", :to => aspect2.id
|
||||
}.should_not raise_error
|
||||
end
|
||||
|
||||
|
||||
proc{
|
||||
user2.post :status_message, :message => "store this!", :to => aspect2.id
|
||||
}.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context 'update posts' do
|
||||
|
|
@ -182,7 +184,7 @@ describe User do
|
|||
let(:salmon){user.salmon( post )}
|
||||
|
||||
it 'should receive a salmon for a post' do
|
||||
user2.receive_salmon( salmon.xml_for user2.person )
|
||||
user2.receive_salmon( salmon.xml_for(user2.person) )
|
||||
user2.visible_post_ids.include?(post.id).should be true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ require 'webmock/rspec'
|
|||
|
||||
include Devise::TestHelpers
|
||||
include WebMock::API
|
||||
include HelperMethods
|
||||
#
|
||||
# Requires supporting files with custom matchers and macros, etc,
|
||||
# in ./support/ and its subdirectories.
|
||||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
||||
include HelperMethods
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.mock_with :mocha
|
||||
|
|
|
|||
|
|
@ -7,3 +7,13 @@ module Resque
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
module HelperMethods
|
||||
def fantasy_resque
|
||||
former_value = $process_queue
|
||||
$process_queue = true
|
||||
result = yield
|
||||
$process_queue = former_value
|
||||
result
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue