DG MS; renamed Salmon jobs; CGI::unescape() incoming xml in public receive route
This commit is contained in:
parent
ba8e50e34c
commit
60cb9e43a7
5 changed files with 10 additions and 10 deletions
|
|
@ -50,7 +50,7 @@ class PublicsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive_public
|
def receive_public
|
||||||
Resque.enqueue(Jobs::ReceivePublicSalmon, params[:xml])
|
Resque.enqueue(Jobs::ReceiveUnencryptedSalmon, CGI::unescape(params[:xml]))
|
||||||
render :nothing => true, :status => :ok
|
render :nothing => true, :status => :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ class PublicsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
@user = person.owner
|
@user = person.owner
|
||||||
Resque.enqueue(Jobs::ReceiveSalmon, @user.id, CGI::unescape(params[:xml]))
|
Resque.enqueue(Jobs::ReceiveEncryptedSalmon, @user.id, CGI::unescape(params[:xml]))
|
||||||
|
|
||||||
render :nothing => true, :status => 202
|
render :nothing => true, :status => 202
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
require File.join(Rails.root, 'lib/postzord/receiver/private')
|
require File.join(Rails.root, 'lib/postzord/receiver/private')
|
||||||
module Jobs
|
module Jobs
|
||||||
class ReceiveSalmon < Base
|
class ReceiveEncryptedSalmon < Base
|
||||||
@queue = :receive_salmon
|
@queue = :receive_salmon
|
||||||
|
|
||||||
def self.perform(user_id, xml)
|
def self.perform(user_id, xml)
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
require File.join(Rails.root, 'lib/postzord/receiver/private')
|
require File.join(Rails.root, 'lib/postzord/receiver/private')
|
||||||
|
|
||||||
module Jobs
|
module Jobs
|
||||||
class ReceivePublicSalmon < Base
|
class ReceiveUnencryptedSalmon < Base
|
||||||
|
|
||||||
@queue = :receive
|
@queue = :receive
|
||||||
|
|
||||||
|
|
@ -31,9 +31,9 @@ describe PublicsController do
|
||||||
response.code.should == '422'
|
response.code.should == '422'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'enqueues a ReceivePublicSalmon job' do
|
it 'enqueues a ReceiveUnencryptedSalmon job' do
|
||||||
xml = "stuff"
|
xml = "stuff"
|
||||||
Resque.should_receive(:enqueue).with(Jobs::ReceivePublicSalmon, xml)
|
Resque.should_receive(:enqueue).with(Jobs::ReceiveUnencryptedSalmon, xml)
|
||||||
post :receive_public, :xml => xml
|
post :receive_public, :xml => xml
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -47,7 +47,7 @@ describe PublicsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'enqueues a receive job' do
|
it 'enqueues a receive job' do
|
||||||
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, @user.id, xml).once
|
Resque.should_receive(:enqueue).with(Jobs::ReceiveEncryptedSalmon, @user.id, xml).once
|
||||||
post :receive, "guid" => @user.person.guid.to_s, "xml" => xml
|
post :receive, "guid" => @user.person.guid.to_s, "xml" => xml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ describe PublicsController do
|
||||||
salmon_factory = Salmon::EncryptedSlap.create_by_user_and_activity(@user, xml2)
|
salmon_factory = Salmon::EncryptedSlap.create_by_user_and_activity(@user, xml2)
|
||||||
enc_xml = salmon_factory.xml_for(user2.person)
|
enc_xml = salmon_factory.xml_for(user2.person)
|
||||||
|
|
||||||
Resque.should_receive(:enqueue).with(Jobs::ReceiveSalmon, @user.id, enc_xml).once
|
Resque.should_receive(:enqueue).with(Jobs::ReceiveEncryptedSalmon, @user.id, enc_xml).once
|
||||||
post :receive, "guid" => @user.person.guid.to_s, "xml" => CGI::escape(enc_xml)
|
post :receive, "guid" => @user.person.guid.to_s, "xml" => CGI::escape(enc_xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Jobs::ReceiveSalmon do
|
describe Jobs::ReceiveEncryptedSalmon do
|
||||||
before do
|
before do
|
||||||
@user = alice
|
@user = alice
|
||||||
@xml = '<xml></xml>'
|
@xml = '<xml></xml>'
|
||||||
|
|
@ -18,6 +18,6 @@ describe Jobs::ReceiveSalmon do
|
||||||
zord.should_receive(:perform)
|
zord.should_receive(:perform)
|
||||||
Postzord::Receiver::Private.should_receive(:new).with(@user, hash_including(:salmon_xml => @xml)).and_return(zord)
|
Postzord::Receiver::Private.should_receive(:new).with(@user, hash_including(:salmon_xml => @xml)).and_return(zord)
|
||||||
|
|
||||||
Jobs::ReceiveSalmon.perform(@user.id, @xml)
|
Jobs::ReceiveEncryptedSalmon.perform(@user.id, @xml)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue