MS RS Get the fake queue working when it's nested, and push local dispatch onto the queues
This commit is contained in:
parent
4c4f5c6aa4
commit
9e575ea765
7 changed files with 101 additions and 89 deletions
|
|
@ -23,9 +23,11 @@ module HelperMethods
|
|||
end
|
||||
|
||||
def fantasy_resque
|
||||
former_value = $process_queue
|
||||
$process_queue = true
|
||||
yield
|
||||
$process_queue = false
|
||||
result = yield
|
||||
$process_queue = former_value
|
||||
result
|
||||
end
|
||||
|
||||
def connect_users(user1, aspect1, user2, aspect2)
|
||||
|
|
|
|||
|
|
@ -7,57 +7,63 @@ require File.join(Rails.root, 'lib/diaspora/exporter')
|
|||
|
||||
describe Diaspora::Exporter do
|
||||
|
||||
let!(:user1) { make_user }
|
||||
let!(:user2) { make_user }
|
||||
let!(:user3) { make_user }
|
||||
before do
|
||||
@user1 = make_user
|
||||
@user2 = make_user
|
||||
@user3 = make_user
|
||||
|
||||
let!(:aspect) { user1.aspects.create(:name => "Old Work") }
|
||||
let(:aspect1) { user1.aspects.create(:name => "Work") }
|
||||
let(:aspect2) { user2.aspects.create(:name => "Family") }
|
||||
let(:aspect3) { user3.aspects.create(:name => "Pivots") }
|
||||
@aspect = @user1.aspects.create(:name => "Old Work")
|
||||
@aspect1 = @user1.aspects.create(:name => "Work")
|
||||
@aspect2 = @user2.aspects.create(:name => "Family")
|
||||
@aspect3 = @user3.aspects.create(:name => "Pivots")
|
||||
|
||||
let!(:status_message1) { user1.post(:status_message, :message => "One", :public => true, :to => aspect1.id) }
|
||||
let!(:status_message2) { user1.post(:status_message, :message => "Two", :public => true, :to => aspect1.id) }
|
||||
let!(:status_message3) { user2.post(:status_message, :message => "Three", :public => false, :to => aspect2.id) }
|
||||
@status_message1 = @user1.post(:status_message, :message => "One", :public => true, :to => @aspect1.id)
|
||||
@status_message2 = @user1.post(:status_message, :message => "Two", :public => true, :to => @aspect1.id)
|
||||
@status_message3 = @user2.post(:status_message, :message => "Three", :public => false, :to => @aspect2.id)
|
||||
|
||||
let(:exported) { Nokogiri::XML(Diaspora::Exporter.new(Diaspora::Exporters::XML).execute(user1)) }
|
||||
@user1.reload
|
||||
@user2.reload
|
||||
end
|
||||
|
||||
def exported
|
||||
Nokogiri::XML(Diaspora::Exporter.new(Diaspora::Exporters::XML).execute(@user1))
|
||||
end
|
||||
|
||||
context '<user/>' do
|
||||
let(:user_xml) {exported.xpath('//user').to_s}
|
||||
before do
|
||||
@user_xml = exported.xpath('//user').to_s
|
||||
end
|
||||
it 'should include a users private key' do
|
||||
user_xml.to_s.should include user1.serialized_private_key
|
||||
@user_xml.to_s.should include @user1.serialized_private_key
|
||||
end
|
||||
end
|
||||
|
||||
context '<aspects/>' do
|
||||
let(:aspects_xml) {exported.xpath('//aspects').to_s}
|
||||
it 'should include the aspect name' do
|
||||
|
||||
end
|
||||
|
||||
it 'should include the post_ids' do
|
||||
aspects_xml.should include status_message1.id.to_s
|
||||
aspects_xml.should include status_message2.id.to_s
|
||||
aspects_xml = exported.xpath('//aspects').to_s
|
||||
aspects_xml.should include @status_message1.id.to_s
|
||||
aspects_xml.should include @status_message2.id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
context '<contacts/>' do
|
||||
|
||||
before do
|
||||
connect_users(user1, aspect1, user3, aspect3)
|
||||
user1.add_person_to_aspect(user3.person.id, aspect.id)
|
||||
user1.reload
|
||||
connect_users(@user1, @aspect1, @user3, @aspect3)
|
||||
@user1.add_person_to_aspect(@user3.person.id, @aspect.id)
|
||||
@user1.reload
|
||||
end
|
||||
|
||||
let(:contacts_xml) {exported.xpath('//contacts').to_s}
|
||||
it 'should include a person id' do
|
||||
contacts_xml.should include user3.person.id.to_s
|
||||
contacts_xml.should include @user3.person.id.to_s
|
||||
end
|
||||
|
||||
it 'should include an aspects names of all aspects they are in' do
|
||||
#contact specific xml needs to be tested
|
||||
user1.contacts.find_by_person_id(user3.person.id).aspects.count.should > 0
|
||||
user1.contacts.find_by_person_id(user3.person.id).aspects.each { |aspect|
|
||||
@user1.contacts.find_by_person_id(@user3.person.id).aspects.count.should > 0
|
||||
@user1.contacts.find_by_person_id(@user3.person.id).aspects.each { |aspect|
|
||||
contacts_xml.should include aspect.name
|
||||
}
|
||||
end
|
||||
|
|
@ -66,38 +72,38 @@ describe Diaspora::Exporter do
|
|||
context '<people/>' do
|
||||
let(:people_xml) {exported.xpath('//people').to_s}
|
||||
before do
|
||||
connect_users(user1, aspect1, user3, aspect3)
|
||||
user1.reload
|
||||
connect_users(@user1, @aspect1, @user3, @aspect3)
|
||||
@user1.reload
|
||||
end
|
||||
it 'should include persons id' do
|
||||
people_xml.should include user3.person.id.to_s
|
||||
people_xml.should include @user3.person.id.to_s
|
||||
end
|
||||
|
||||
it 'should include their profile' do
|
||||
people_xml.should include user3.person.profile.first_name
|
||||
people_xml.should include user3.person.profile.last_name
|
||||
people_xml.should include @user3.person.profile.first_name
|
||||
people_xml.should include @user3.person.profile.last_name
|
||||
end
|
||||
|
||||
it 'should include their public key' do
|
||||
people_xml.should include user3.person.exported_key
|
||||
people_xml.should include @user3.person.exported_key
|
||||
end
|
||||
|
||||
it 'should include their diaspora handle' do
|
||||
people_xml.should include user3.person.diaspora_handle
|
||||
people_xml.should include @user3.person.diaspora_handle
|
||||
end
|
||||
end
|
||||
|
||||
context '<posts>' do
|
||||
let(:posts_xml) {exported.xpath('//posts').to_s}
|
||||
it 'should include many posts xml' do
|
||||
posts_xml.should include status_message1.message
|
||||
posts_xml.should include status_message2.message
|
||||
posts_xml.should_not include status_message3.message
|
||||
posts_xml.should include @status_message1.message
|
||||
posts_xml.should include @status_message2.message
|
||||
posts_xml.should_not include @status_message3.message
|
||||
end
|
||||
|
||||
it 'should include post created at time' do
|
||||
doc = Nokogiri::XML::parse(posts_xml)
|
||||
Time.parse(doc.xpath('//posts/status_message/created_at').first.text).should == status_message1.created_at
|
||||
Time.parse(doc.xpath('//posts/status_message/created_at').first.text).should == @status_message1.created_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -60,8 +60,9 @@ describe Diaspora::Parser do
|
|||
it "should activate the Person if I initiated a request to that url" do
|
||||
user.send_contact_request_to(user2.person, aspect)
|
||||
request = user2.reload.pending_requests.find_by_to_id!(user2.person.id)
|
||||
fantasy_resque do
|
||||
user2.accept_and_respond(request.id, aspect2.id)
|
||||
|
||||
end
|
||||
user.reload
|
||||
aspect.reload
|
||||
new_contact = user.contact_for(user2.person)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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}
|
||||
|
|
@ -41,16 +41,18 @@ end
|
|||
|
||||
module Resque
|
||||
def enqueue(klass, *args)
|
||||
#if $process_queue
|
||||
if $process_queue
|
||||
klass.send(:perform, *args)
|
||||
#else
|
||||
# true
|
||||
#end
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ImageUploader.enable_processing = false
|
||||
class User
|
||||
def send_contact_request_to(desired_contact, aspect)
|
||||
def send_contact_request_to(desired_contact, aspect)
|
||||
fantasy_resque do
|
||||
request = Request.instantiate(:to => desired_contact,
|
||||
:from => self.person,
|
||||
:into => aspect)
|
||||
|
|
@ -59,12 +61,10 @@ def send_contact_request_to(desired_contact, aspect)
|
|||
end
|
||||
request
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ImageUploader.enable_processing = false
|
||||
|
||||
class User
|
||||
def post(class_name, opts = {})
|
||||
fantasy_resque do
|
||||
p = build_post(class_name, opts)
|
||||
if p.save!
|
||||
raise 'MongoMapper failed to catch a failed save' unless p.id
|
||||
|
|
@ -76,8 +76,10 @@ class User
|
|||
end
|
||||
p
|
||||
end
|
||||
end
|
||||
|
||||
def comment(text, options = {})
|
||||
fantasy_resque do
|
||||
c = build_comment(text, options)
|
||||
if c.save!
|
||||
raise 'MongoMapper failed to catch a failed save' unless c.id
|
||||
|
|
@ -85,6 +87,7 @@ class User
|
|||
end
|
||||
c
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue