Skip to content
Extraits de code Groupes Projets
Valider a39bd2ba rédigé par Sarah Mei's avatar Sarah Mei
Parcourir les fichiers

AspectsController#manage now works if you have pending friend requests.

parent c113ee2b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter