im in ur test stubbin ur mailers
This commit is contained in:
parent
6620f33ae2
commit
7e4529f2bd
2 changed files with 56 additions and 45 deletions
|
|
@ -6,10 +6,10 @@ require 'spec_helper'
|
|||
|
||||
describe PublicsController do
|
||||
render_views
|
||||
let(:user) {Factory.create :user}
|
||||
let(:user2){Factory.create :user}
|
||||
let(:aspect1){user.aspect(:name => "foo")}
|
||||
let(:aspect2){user2.aspect(:name => "far")}
|
||||
let(:user) { Factory.create :user }
|
||||
let(:user2) { Factory.create :user }
|
||||
let(:aspect1) { user.aspect(:name => "foo") }
|
||||
let(:aspect2) { user2.aspect(:name => "far") }
|
||||
before do
|
||||
sign_in :user, user
|
||||
end
|
||||
|
|
@ -77,10 +77,13 @@ describe PublicsController do
|
|||
end
|
||||
|
||||
describe 'friend requests' do
|
||||
let(:aspect2) {user2.aspect(:name => 'disciples')}
|
||||
let!(:req) {user2.send_friend_request_to(user.person, aspect2)}
|
||||
let!(:xml) {user2.salmon(req).xml_for(user.person)}
|
||||
let(:aspect2) { user2.aspect(:name => 'disciples') }
|
||||
let!(:req) { user2.send_friend_request_to(user.person, aspect2) }
|
||||
let!(:xml) { user2.salmon(req).xml_for(user.person) }
|
||||
before do
|
||||
deliverable = Object.new
|
||||
deliverable.stub!(:deliver)
|
||||
Notifier.stub!(:new_request).and_return(deliverable)
|
||||
req.delete
|
||||
user2.reload
|
||||
user2.pending_requests.count.should be 1
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Diaspora::Parser do
|
||||
let(:user) {Factory.create(:user)}
|
||||
let(:aspect) {user.aspect(:name => 'spies')}
|
||||
let(:user2) {Factory.create(:user)}
|
||||
let(:aspect2){user2.aspect(:name => "pandas")}
|
||||
let(:user3) {Factory.create :user}
|
||||
let(:person) {user3.person}
|
||||
let(:user) { Factory.create(:user) }
|
||||
let(:aspect) { user.aspect(:name => 'spies') }
|
||||
let(:user2) { Factory.create(:user) }
|
||||
let(:aspect2) { user2.aspect(:name => "pandas") }
|
||||
let(:user3) { Factory.create :user }
|
||||
let(:person) { user3.person }
|
||||
|
||||
describe "parsing compliant XML object" do
|
||||
it 'should be able to correctly handle comments with person in db' do
|
||||
it 'should be able to correctly handle comments with person in db' do
|
||||
post = user.post :status_message, :message => "hello", :to => aspect.id
|
||||
comment = Factory.build(:comment, :post => post, :person => @person, :text => "Freedom!")
|
||||
xml = comment.to_diaspora_xml
|
||||
|
|
@ -45,37 +45,45 @@ describe Diaspora::Parser do
|
|||
retraction = Retraction.for(message)
|
||||
xml = retraction.to_diaspora_xml
|
||||
|
||||
proc {user.receive xml, user2.person}.should change(StatusMessage, :count).by(-1)
|
||||
proc { user.receive xml, user2.person }.should change(StatusMessage, :count).by(-1)
|
||||
end
|
||||
|
||||
it "should create a new person upon getting a person request" do
|
||||
request = Request.instantiate(:to =>"http://www.google.com/", :from => person)
|
||||
context "friending" do
|
||||
before do
|
||||
deliverable = Object.new
|
||||
deliverable.stub!(:deliver)
|
||||
Notifier.stub!(:new_request).and_return(deliverable)
|
||||
end
|
||||
|
||||
xml = request.to_diaspora_xml
|
||||
it "should create a new person upon getting a person request" do
|
||||
request = Request.instantiate(:to =>"http://www.google.com/", :from => person)
|
||||
|
||||
user3.destroy
|
||||
person.destroy
|
||||
user
|
||||
lambda {user.receive xml, person}.should change(Person, :count).by(1)
|
||||
end
|
||||
xml = request.to_diaspora_xml
|
||||
|
||||
it "should not create a new person if the person is already here" do
|
||||
request = Request.instantiate(:to =>"http://www.google.com/", :from => user2.person)
|
||||
original_person_id = user2.person.id
|
||||
xml = request.to_diaspora_xml
|
||||
user
|
||||
lambda {user.receive xml, user2.person}.should_not change(Person, :count)
|
||||
user3.destroy
|
||||
person.destroy
|
||||
user
|
||||
lambda { user.receive xml, person }.should change(Person, :count).by(1)
|
||||
end
|
||||
|
||||
user2.reload
|
||||
user2.person.reload
|
||||
user2.serialized_private_key.include?("PRIVATE").should be true
|
||||
it "should not create a new person if the person is already here" do
|
||||
request = Request.instantiate(:to =>"http://www.google.com/", :from => user2.person)
|
||||
original_person_id = user2.person.id
|
||||
xml = request.to_diaspora_xml
|
||||
user
|
||||
lambda { user.receive xml, user2.person }.should_not change(Person, :count)
|
||||
|
||||
url = "http://" + request.callback_url.split("/")[2] + "/"
|
||||
Person.where(:url => url).first.id.should == original_person_id
|
||||
user2.reload
|
||||
user2.person.reload
|
||||
user2.serialized_private_key.include?("PRIVATE").should be true
|
||||
|
||||
url = "http://" + request.callback_url.split("/")[2] + "/"
|
||||
Person.where(:url => url).first.id.should == original_person_id
|
||||
end
|
||||
end
|
||||
|
||||
it "should activate the Person if I initiated a request to that url" do
|
||||
request = user.send_friend_request_to( user3.person, aspect)
|
||||
request = user.send_friend_request_to(user3.person, aspect)
|
||||
user.reload
|
||||
request.reverse_for user3
|
||||
|
||||
|
|
@ -99,8 +107,8 @@ describe Diaspora::Parser do
|
|||
retraction = Retraction.for(user2)
|
||||
retraction_xml = retraction.to_diaspora_xml
|
||||
|
||||
lambda {user.receive retraction_xml, user2.person}.should change{
|
||||
aspect.reload.people.size}.by(-1)
|
||||
lambda { user.receive retraction_xml, user2.person }.should change {
|
||||
aspect.reload.people.size }.by(-1)
|
||||
end
|
||||
|
||||
it 'should marshal a profile for a person' do
|
||||
|
|
@ -132,9 +140,9 @@ describe Diaspora::Parser do
|
|||
person = Person.first(:id => person.id)
|
||||
person.profile.should_not be nil
|
||||
person.profile.first_name.should == old_profile.first_name
|
||||
person.profile.last_name.should == old_profile.last_name
|
||||
person.profile.image_url.should == old_profile.image_url
|
||||
end
|
||||
person.profile.last_name.should == old_profile.last_name
|
||||
person.profile.image_url.should == old_profile.image_url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue