diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml index f0091d9fad4cd2e42e9f553ce5e7f9a0bc303370..b1f5e0a80e847b4c61fa3ee5bd7aa8b66a74d9c1 100644 --- a/app/views/aspects/manage.html.haml +++ b/app/views/aspects/manage.html.haml @@ -20,12 +20,12 @@ %li=t('.no_requests') - else - 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 .x X .circle - = person_image_tag(request.person) + = person_image_tag(request.from) = render 'shared/invitations', :invites => @invites diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 7c3c0dda9c65c1567b5826c74d6cd284a18164d2..607410fcac82f67baf989a773d1b442ef7f6ca72 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -8,13 +8,13 @@ describe AspectsController do render_views before do - @user = make_user - @aspect = @user.aspects.create(:name => "lame-os") - @aspect1 = @user.aspects.create(:name => "another aspect") - @user2 = make_user - @aspect2 = @user2.aspects.create(:name => "party people") - friend_users(@user,@aspect, @user2, @aspect2) - @contact = @user.contact_for(@user2.person) + @user = make_user + @aspect = @user.aspects.create(:name => "lame-os") + @aspect1 = @user.aspects.create(:name => "another aspect") + @user2 = make_user + @aspect2 = @user2.aspects.create(:name => "party people") + friend_users(@user, @aspect, @user2, @aspect2) + @contact = @user.contact_for(@user2.person) sign_in :user, @user request.env["HTTP_REFERER"] = 'http://' + request.host end @@ -52,12 +52,50 @@ describe AspectsController do 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 - 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 - 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) - @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 end end @@ -67,8 +105,8 @@ describe AspectsController do @aspect = @user.aspects.create(:name => "Bruisers") end it "doesn't overwrite random attributes" do - new_user = Factory.create :user - params = {"name" => "Bruisers"} + new_user = Factory.create :user + params = {"name" => "Bruisers"} params[:user_id] = new_user.id put('update', :id => @aspect.id, "aspect" => params) Aspect.find(@aspect.id).user_id.should == @user.id @@ -79,17 +117,17 @@ describe AspectsController do it 'adds the users to the aspect' do @aspect1.reload @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.people.include?(@contact).should be true end - end - + end + describe "#remove_from_aspect" do it 'adds the users to the aspect' do @aspect.reload @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.people.include?(@contact).should be false end