Fix failure, decode in receiver
This commit is contained in:
parent
656640ee94
commit
930ea6c425
4 changed files with 15 additions and 6 deletions
|
|
@ -3,6 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
require 'typhoeus'
|
||||
require 'active_support/base64'
|
||||
|
||||
class HydraWrapper
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ class HydraWrapper
|
|||
|
||||
# @return [Salmon]
|
||||
def salmon
|
||||
@salmon ||= @dispatcher_class.salmon(@user, @encoded_object_xml)
|
||||
@salmon ||= @dispatcher_class.salmon(@user, Base64.decode64(@encoded_object_xml))
|
||||
end
|
||||
|
||||
# Group people on their receiving_urls
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ module Salmon
|
|||
|
||||
delegate :sig, :data_type, :to => :magic_sig
|
||||
|
||||
# @param user [User]
|
||||
# @param activity [String] A decoded string
|
||||
# @return [Slap]
|
||||
def self.create_by_user_and_activity(user, activity)
|
||||
salmon = self.new
|
||||
salmon.author = user.person
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ require 'hydra_wrapper'
|
|||
|
||||
describe HydraWrapper do
|
||||
before do
|
||||
@wrapper = HydraWrapper.new(stub, [stub, stub, stub], stub, stub)
|
||||
@wrapper = HydraWrapper.new(stub, [stub, stub, stub], "<encoded_xml>", stub)
|
||||
end
|
||||
|
||||
describe 'initialize' do
|
||||
|
|
@ -33,7 +33,9 @@ describe HydraWrapper do
|
|||
|
||||
describe '#salmon' do
|
||||
it 'calls the salmon method on the dispatcher class (and memoizes)' do
|
||||
@wrapper.dispatcher_class.should_receive(:salmon).once.and_return(true)
|
||||
Base64.stub(:decode64).and_return(@wrapper.encoded_object_xml + 'decoded')
|
||||
decoded = Base64.decode64(@wrapper.encoded_object_xml)
|
||||
@wrapper.dispatcher_class.should_receive(:salmon).with(@wrapper.user, decoded).once.and_return(true)
|
||||
@wrapper.salmon
|
||||
@wrapper.salmon
|
||||
end
|
||||
|
|
@ -55,6 +57,7 @@ describe HydraWrapper do
|
|||
end
|
||||
|
||||
it 'inserts a job for every group of people' do
|
||||
Base64.stub(:decode64)
|
||||
@wrapper.dispatcher_class = stub(:salmon => stub(:xml_for => "<XML>"))
|
||||
@wrapper.stub(:grouped_people).and_return({'https://foo.com' => @wrapper.people})
|
||||
@wrapper.people.should_receive(:first).once
|
||||
|
|
@ -63,6 +66,7 @@ describe HydraWrapper do
|
|||
end
|
||||
|
||||
it 'does not insert a job for a person whos xml returns false' do
|
||||
Base64.stub(:decode64)
|
||||
@wrapper.stub(:grouped_people).and_return({'https://foo.com' => [stub]})
|
||||
@wrapper.dispatcher_class = stub(:salmon => stub(:xml_for => false))
|
||||
@wrapper.should_not_receive(:insert_job)
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ describe Job::ReceiveSalmon do
|
|||
}
|
||||
end
|
||||
it 'calls receive_salmon' do
|
||||
salmon_mock = mock()
|
||||
zord = mock
|
||||
|
||||
zord.should_receive(:perform)
|
||||
Postzord::Receiver::Private.should_receive(:new).with(@user, hash_including(:salmon_xml => @xml)).and_return(zord)
|
||||
|
||||
salmon_mock.should_receive(:perform)
|
||||
Postzord::Receiver.should_receive(:new).and_return(salmon_mock)
|
||||
Job::ReceiveSalmon.perform(@user.id, @xml)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue