AspectsController#manage now works if you have pending friend requests.
This commit is contained in:
parent
c113ee2b7c
commit
a39bd2badb
2 changed files with 56 additions and 18 deletions
|
|
@ -20,12 +20,12 @@
|
||||||
%li=t('.no_requests')
|
%li=t('.no_requests')
|
||||||
- else
|
- else
|
||||||
- for request in @remote_requests
|
- for request in @remote_requests
|
||||||
%li.person.request{:data=>{:guid=>request.id, :person_id=>request.person.id}}
|
%li.person.request{:data=>{:guid=>request.id, :person_id=>request.from.id}}
|
||||||
.delete
|
.delete
|
||||||
.x
|
.x
|
||||||
X
|
X
|
||||||
.circle
|
.circle
|
||||||
= person_image_tag(request.person)
|
= person_image_tag(request.from)
|
||||||
|
|
||||||
= render 'shared/invitations', :invites => @invites
|
= render 'shared/invitations', :invites => @invites
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@ describe AspectsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = make_user
|
@user = make_user
|
||||||
@aspect = @user.aspects.create(:name => "lame-os")
|
@aspect = @user.aspects.create(:name => "lame-os")
|
||||||
@aspect1 = @user.aspects.create(:name => "another aspect")
|
@aspect1 = @user.aspects.create(:name => "another aspect")
|
||||||
@user2 = make_user
|
@user2 = make_user
|
||||||
@aspect2 = @user2.aspects.create(:name => "party people")
|
@aspect2 = @user2.aspects.create(:name => "party people")
|
||||||
friend_users(@user,@aspect, @user2, @aspect2)
|
friend_users(@user, @aspect, @user2, @aspect2)
|
||||||
@contact = @user.contact_for(@user2.person)
|
@contact = @user.contact_for(@user2.person)
|
||||||
sign_in :user, @user
|
sign_in :user, @user
|
||||||
request.env["HTTP_REFERER"] = 'http://' + request.host
|
request.env["HTTP_REFERER"] = 'http://' + request.host
|
||||||
end
|
end
|
||||||
|
|
@ -52,12 +52,50 @@ describe AspectsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#manage" do
|
||||||
|
it "succeeds" do
|
||||||
|
get :manage
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
it "assigns aspect to manage" do
|
||||||
|
get :manage
|
||||||
|
assigns(:aspect).should == :manage
|
||||||
|
end
|
||||||
|
it "assigns remote_requests" do
|
||||||
|
get :manage
|
||||||
|
assigns(:remote_requests).should be_empty
|
||||||
|
end
|
||||||
|
context "when the user has pending requests" do
|
||||||
|
before do
|
||||||
|
requestor = make_user
|
||||||
|
requestor_aspect = requestor.aspects.create(:name => "Meh")
|
||||||
|
requestor.send_friend_request_to(@user.person, requestor_aspect)
|
||||||
|
|
||||||
|
requestor.reload
|
||||||
|
requestor_aspect.reload
|
||||||
|
@user.reload
|
||||||
|
end
|
||||||
|
it "succeeds" do
|
||||||
|
get :manage
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
it "assigns aspect to manage" do
|
||||||
|
get :manage
|
||||||
|
assigns(:aspect).should == :manage
|
||||||
|
end
|
||||||
|
it "assigns remote_requests" do
|
||||||
|
get :manage
|
||||||
|
assigns(:remote_requests).count.should == 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#move_friend" do
|
describe "#move_friend" do
|
||||||
let(:opts) { {:friend_id => "person_id", :from => "from_aspect_id", :to => {:to => "to_aspect_id"}}}
|
let(:opts) { {:friend_id => "person_id", :from => "from_aspect_id", :to => {:to => "to_aspect_id"}} }
|
||||||
it 'calls the move_friend_method' do
|
it 'calls the move_friend_method' do
|
||||||
pending "need to figure out what is the deal with remote requests"
|
pending "need to figure out what is the deal with remote requests"
|
||||||
@controller.stub!(:current_user).and_return(@user)
|
@controller.stub!(:current_user).and_return(@user)
|
||||||
@user.should_receive(:move_friend).with( :friend_id => "person_id", :from => "from_aspect_id", :to => "to_aspect_id")
|
@user.should_receive(:move_friend).with(:friend_id => "person_id", :from => "from_aspect_id", :to => "to_aspect_id")
|
||||||
post :move_friend, opts
|
post :move_friend, opts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -67,8 +105,8 @@ describe AspectsController do
|
||||||
@aspect = @user.aspects.create(:name => "Bruisers")
|
@aspect = @user.aspects.create(:name => "Bruisers")
|
||||||
end
|
end
|
||||||
it "doesn't overwrite random attributes" do
|
it "doesn't overwrite random attributes" do
|
||||||
new_user = Factory.create :user
|
new_user = Factory.create :user
|
||||||
params = {"name" => "Bruisers"}
|
params = {"name" => "Bruisers"}
|
||||||
params[:user_id] = new_user.id
|
params[:user_id] = new_user.id
|
||||||
put('update', :id => @aspect.id, "aspect" => params)
|
put('update', :id => @aspect.id, "aspect" => params)
|
||||||
Aspect.find(@aspect.id).user_id.should == @user.id
|
Aspect.find(@aspect.id).user_id.should == @user.id
|
||||||
|
|
@ -79,17 +117,17 @@ describe AspectsController do
|
||||||
it 'adds the users to the aspect' do
|
it 'adds the users to the aspect' do
|
||||||
@aspect1.reload
|
@aspect1.reload
|
||||||
@aspect1.people.include?(@contact).should be false
|
@aspect1.people.include?(@contact).should be false
|
||||||
post 'add_to_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id }
|
post 'add_to_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id}
|
||||||
@aspect1.reload
|
@aspect1.reload
|
||||||
@aspect1.people.include?(@contact).should be true
|
@aspect1.people.include?(@contact).should be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#remove_from_aspect" do
|
describe "#remove_from_aspect" do
|
||||||
it 'adds the users to the aspect' do
|
it 'adds the users to the aspect' do
|
||||||
@aspect.reload
|
@aspect.reload
|
||||||
@aspect.people.include?(@contact).should be true
|
@aspect.people.include?(@contact).should be true
|
||||||
post 'remove_from_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id }
|
post 'remove_from_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id}
|
||||||
@aspect1.reload
|
@aspect1.reload
|
||||||
@aspect1.people.include?(@contact).should be false
|
@aspect1.people.include?(@contact).should be false
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue