IZ MS; deleted move_friends removed
This commit is contained in:
parent
02f37c6156
commit
94a7a3c6ad
4 changed files with 33 additions and 25 deletions
|
|
@ -78,20 +78,6 @@ class AspectsController < ApplicationController
|
|||
respond_with @aspect
|
||||
end
|
||||
|
||||
def move_friends
|
||||
params[:moves].each{ |move|
|
||||
move = move[1]
|
||||
unless current_user.move_friend(move)
|
||||
flash[:error] = I18n.t 'aspects.move_friends.failure', :real_name => Person.find_by_id( move[:friend_id] ).real_name
|
||||
redirect_to aspects_manage_path
|
||||
return
|
||||
end
|
||||
}
|
||||
|
||||
flash[:notice] = I18n.t 'aspects.move_friends.success'
|
||||
redirect_to aspects_manage_path
|
||||
end
|
||||
|
||||
def move_friend
|
||||
unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
|
||||
flash[:error] = I18n.t 'aspects.move_friend.error',:inspect => params.inspect
|
||||
|
|
@ -105,11 +91,20 @@ class AspectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def add_to_aspect
|
||||
if current_user.add_person_to_aspect( params[:friend_id], params[:to_aspect_id])
|
||||
flash[:notice] = I18n.t 'aspects.add_to_aspect.success'
|
||||
render :nothing => true
|
||||
else
|
||||
flash[:notice] = I18n.t 'aspects.add_to_aspect.success'
|
||||
render :nothing => true, :status => 500
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def clean_hash(params)
|
||||
return {
|
||||
:name => params[:name]
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -104,12 +104,12 @@ en:
|
|||
success: "%{name} was successfully removed."
|
||||
update:
|
||||
success: "Your aspect, %{name}, has been successfully edited."
|
||||
move_friends:
|
||||
failure: "Aspect editing failed for friend %{real_name}."
|
||||
success: "Aspects edited successfully."
|
||||
move_friend:
|
||||
failure: "didn't work %{inspect}"
|
||||
success: "You are now showing your friend a different aspect of yourself."
|
||||
success: "Person moved to new aspect"
|
||||
add_to_aspect:
|
||||
failure: "Failed to add friend to aspect."
|
||||
success: "Successfully added friend to aspect."
|
||||
helper:
|
||||
remove: "remove"
|
||||
aspect_not_empty: "Aspect not empty"
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ Diaspora::Application.routes.draw do
|
|||
match 'users/export_photos', :to => 'users#export_photos'
|
||||
resources :users, :except => [:create, :new, :show]
|
||||
|
||||
match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends'
|
||||
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
|
||||
match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect'
|
||||
match 'aspects/manage', :to => 'aspects#manage'
|
||||
match 'aspects/public', :to => 'aspects#public'
|
||||
resources :aspects, :except => [:edit]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ describe AspectsController do
|
|||
before do
|
||||
@user = Factory.create(:user)
|
||||
@aspect = @user.aspect(:name => "lame-os")
|
||||
@person = Factory.create(:person)
|
||||
@aspect1 = @user.aspect(:name => "another aspect")
|
||||
@user2 = Factory.create(:user)
|
||||
@aspect2 = @user2.aspect(:name => "party people")
|
||||
friend_users(@user,@aspect, @user2, @aspect2)
|
||||
sign_in :user, @user
|
||||
end
|
||||
|
||||
|
|
@ -25,9 +28,9 @@ describe AspectsController do
|
|||
describe "#create" do
|
||||
describe "with valid params" do
|
||||
it "creates an aspect" do
|
||||
@user.aspects.count.should == 1
|
||||
@user.aspects.count.should == 2
|
||||
post :create, "aspect" => {"name" => "new aspect"}
|
||||
@user.reload.aspects.count.should == 2
|
||||
@user.reload.aspects.count.should == 3
|
||||
end
|
||||
it "redirects to the aspect page" do
|
||||
post :create, "aspect" => {"name" => "new aspect"}
|
||||
|
|
@ -36,9 +39,9 @@ describe AspectsController do
|
|||
end
|
||||
describe "with invalid params" do
|
||||
it "does not create an aspect" do
|
||||
@user.aspects.count.should == 1
|
||||
@user.aspects.count.should == 2
|
||||
post :create, "aspect" => {"name" => ""}
|
||||
@user.reload.aspects.count.should == 1
|
||||
@user.reload.aspects.count.should == 2
|
||||
end
|
||||
it "goes back to manage aspects" do
|
||||
post :create, "aspect" => {"name" => ""}
|
||||
|
|
@ -68,4 +71,14 @@ describe AspectsController do
|
|||
Aspect.find(@aspect.id).user_id.should == @user.id
|
||||
end
|
||||
end
|
||||
|
||||
describe "#add_to_aspect" do
|
||||
it 'adds the users to the aspect' do
|
||||
@aspect1.reload
|
||||
@aspect1.people.include?(@user2.person).should be false
|
||||
post 'add_to_aspect', {'friend_id' => @user2.person.id, 'to_aspect_id' => @aspect1.id }
|
||||
@aspect1.reload
|
||||
@aspect1.people.include?(@user2.person).should be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue