WIP pending contacts
This commit is contained in:
parent
251cdec2ec
commit
06b7b1c99a
4 changed files with 71 additions and 41 deletions
|
|
@ -148,14 +148,18 @@ class AspectsController < ApplicationController
|
||||||
:person_id => @person_id}),
|
:person_id => @person_id}),
|
||||||
:aspect_id => @aspect_id
|
:aspect_id => @aspect_id
|
||||||
}}
|
}}
|
||||||
format.html{ redirect_to aspect_path(@aspect_id)}
|
format.html{
|
||||||
|
redirect_to :back
|
||||||
|
}
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
flash.now[:error] = I18n.t 'aspects.remove_from_aspect.failure'
|
flash.now[:error] = I18n.t 'aspects.remove_from_aspect.failure'
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js { render :text => e, :status => 403 }
|
format.js { render :text => e, :status => 403 }
|
||||||
format.html{ redirect_to aspect_path(@aspect_id)}
|
format.html{
|
||||||
|
redirect_to :back
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -221,10 +221,16 @@ describe AspectsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#add_to_aspect" do
|
describe "#add_to_aspect" do
|
||||||
|
context 'with a non-contact' do
|
||||||
|
it 'creates a pending contact' do
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
end
|
||||||
it 'adds the users to the aspect' do
|
it 'adds the users to the aspect' do
|
||||||
@aspect1.reload
|
@aspect1.reload
|
||||||
@aspect1.contacts.include?(@contact).should be_false
|
@aspect1.contacts.include?(@contact).should be_false
|
||||||
post 'add_to_aspect', {:person_id => @user2.person.id, :aspect_id => @aspect1.id}
|
post 'add_to_aspect', :format => 'js', :person_id => @user2.person.id, :aspect_id => @aspect1.id
|
||||||
|
response.should be_success
|
||||||
@aspect1.reload
|
@aspect1.reload
|
||||||
@aspect1.contacts.include?(@contact).should be_true
|
@aspect1.contacts.include?(@contact).should be_true
|
||||||
end
|
end
|
||||||
|
|
@ -232,13 +238,13 @@ describe AspectsController do
|
||||||
|
|
||||||
describe "#remove_from_aspect" do
|
describe "#remove_from_aspect" do
|
||||||
it 'removes contacts from an aspect' do
|
it 'removes contacts from an aspect' do
|
||||||
pending 'this needs to test with another aspect present'
|
@user.add_person_to_aspect( @user2.person.id, @aspect1.id)
|
||||||
|
|
||||||
@aspect.reload
|
@aspect.reload
|
||||||
@aspect.contacts.include?(@contact).should be true
|
@aspect.contacts.include?(@contact).should be true
|
||||||
post 'remove_from_aspect', {:person_id => @user2.person.id, :aspect_id => @aspect1.id}
|
post 'remove_from_aspect', :format => 'js', :person_id => @user2.person.id, :aspect_id => @aspect.id
|
||||||
@aspect1.reload
|
response.should be_success
|
||||||
@aspect1.contacts.include?(@contact).should be false
|
@aspect.reload
|
||||||
|
@aspect.contacts.include?(@contact).should be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,34 @@ describe RequestsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
|
context 'valid new request' do
|
||||||
|
before do
|
||||||
|
@params = {:request => {:to => @other_user.diaspora_handle,
|
||||||
|
:into => @user.aspects[0].id}}
|
||||||
|
end
|
||||||
|
it 'creates a contact' do
|
||||||
|
@user.contact_for(@other_user).should be_nil
|
||||||
|
lambda {
|
||||||
|
post :create, @params
|
||||||
|
}.should change(Contact,:count).by(1)
|
||||||
|
new_contact = @user.reload.contact_for(@other_user)
|
||||||
|
new_contact.should_not be_nil
|
||||||
|
new_contact.should be_pending
|
||||||
|
end
|
||||||
|
it 'does not persist a Request' do
|
||||||
|
lambda {
|
||||||
|
post :create, @params
|
||||||
|
}.should_not change(Request,:count)
|
||||||
|
end
|
||||||
|
end
|
||||||
it 'autoaccepts and when sending a request to someone who sent me a request' do
|
it 'autoaccepts and when sending a request to someone who sent me a request' do
|
||||||
#pending "When a user sends a request to person who requested them the request should be auto accepted"
|
|
||||||
@other_user.send_contact_request_to(@user.person, @other_user.aspects[0])
|
@other_user.send_contact_request_to(@user.person, @other_user.aspects[0])
|
||||||
@user.reload.pending_requests.count.should == 1
|
@user.reload.pending_requests.count.should == 1
|
||||||
@user.contact_for(@other_user.person).should be_nil
|
@user.contact_for(@other_user.person).should be_nil
|
||||||
|
|
||||||
post(:create, :request => {
|
post(:create, :request => {
|
||||||
:to => @other_user.diaspora_handle,
|
:to => @other_user.diaspora_handle,
|
||||||
:into => @user.aspects[0].id
|
:into => @user.aspects[0].id}
|
||||||
}
|
|
||||||
)
|
)
|
||||||
@user.reload.pending_requests.count.should == 0
|
@user.reload.pending_requests.count.should == 0
|
||||||
@user.contact_for(@other_user.person).should_not be_nil
|
@user.contact_for(@other_user.person).should_not be_nil
|
||||||
|
|
@ -68,6 +86,7 @@ describe RequestsController do
|
||||||
:into => @user.aspects[0].id
|
:into => @user.aspects[0].id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
flash[:error].should_not be_blank
|
||||||
response.should redirect_to :back
|
response.should redirect_to :back
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -81,7 +100,7 @@ describe RequestsController do
|
||||||
response.should redirect_to :back
|
response.should redirect_to :back
|
||||||
end
|
end
|
||||||
|
|
||||||
it "flashes and redirects when requesting an invalid identity with a port number" do
|
it "accepts no port numbers" do
|
||||||
post(:create, :request => {
|
post(:create, :request => {
|
||||||
:to => "johndoe@email.com:3000",
|
:to => "johndoe@email.com:3000",
|
||||||
:into => @user.aspects[0].id
|
:into => @user.aspects[0].id
|
||||||
|
|
@ -97,6 +116,7 @@ describe RequestsController do
|
||||||
:into => @user.aspects[0].id
|
:into => @user.aspects[0].id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
flash[:error].should_not be_blank
|
||||||
response.should redirect_to :back
|
response.should redirect_to :back
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue