remove unused method and controller action (move_contact)
This commit is contained in:
parent
e4f4f06404
commit
aed413b463
5 changed files with 5 additions and 66 deletions
|
|
@ -54,29 +54,7 @@ class AspectMembershipsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@person = Person.find(params[:person_id])
|
||||
@from_aspect = current_user.aspects.where(:id => params[:aspect_id]).first
|
||||
@to_aspect = current_user.aspects.where(:id => params[:to]).first
|
||||
|
||||
response_hash = { }
|
||||
|
||||
unless current_user.move_contact( @person, @to_aspect, @from_aspect)
|
||||
flash[:error] = I18n.t 'aspects.move_contact.error',:inspect => params.inspect
|
||||
end
|
||||
if aspect = current_user.aspects.where(:id => params[:to]).first
|
||||
response_hash[:notice] = I18n.t 'aspects.move_contact.success'
|
||||
response_hash[:success] = true
|
||||
else
|
||||
response_hash[:notice] = I18n.t 'aspects.move_contact.failure'
|
||||
response_hash[:success] = false
|
||||
end
|
||||
|
||||
render :text => response_hash.to_json
|
||||
end
|
||||
|
||||
rescue_from ActiveRecord::StatementInvalid do
|
||||
render :text => "Duplicate record rejected.", :status => 400
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -172,17 +172,6 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
######### Aspects ######################
|
||||
|
||||
def move_contact(person, to_aspect, from_aspect)
|
||||
return true if to_aspect == from_aspect
|
||||
contact = contact_for(person)
|
||||
|
||||
add_contact_to_aspect(contact, to_aspect)
|
||||
|
||||
membership = contact ? AspectMembership.where(:contact_id => contact.id, :aspect_id => from_aspect.id).first : nil
|
||||
return(membership && membership.destroy)
|
||||
end
|
||||
|
||||
def add_contact_to_aspect(contact, aspect)
|
||||
return true if AspectMembership.exists?(:contact_id => contact.id, :aspect_id => aspect.id)
|
||||
contact.aspect_memberships.create!(:aspect => aspect)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ Diaspora::Application.routes.draw do
|
|||
resources :contacts, :except => [:update, :create] do
|
||||
get :sharing, :on => :collection
|
||||
end
|
||||
resources :aspect_memberships, :only => [:destroy, :create, :update]
|
||||
resources :aspect_memberships, :only => [:destroy, :create]
|
||||
resources :share_visibilities, :only => [:update]
|
||||
resources :blocks, :only => [:create, :destroy]
|
||||
|
||||
|
|
|
|||
|
|
@ -198,9 +198,9 @@ describe User do
|
|||
Factory(:status_message, :public => true)
|
||||
bob.visible_shareables(Post).count.should == 0
|
||||
end
|
||||
|
||||
context 'with many posts' do
|
||||
before do
|
||||
bob.move_contact(eve.person, @bobs_aspect, bob.aspects.create(:name => 'new aspect'))
|
||||
time_interval = 1000
|
||||
time_past = 1000000
|
||||
(1..25).each do |n|
|
||||
|
|
|
|||
|
|
@ -708,34 +708,6 @@ describe User do
|
|||
alice.add_contact_to_aspect(@contact, @original_aspect).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'moving and removing posts' do
|
||||
describe 'User#move_contact' do
|
||||
it 'should be able to move a contact from one of users existing aspects to another' do
|
||||
alice.move_contact(bob.person, @new_aspect, @original_aspect)
|
||||
|
||||
@original_aspect.contacts(true).include?(@contact).should be_false
|
||||
@new_aspect.contacts(true).include?(@contact).should be_true
|
||||
end
|
||||
|
||||
it "should not move a person who is not a contact" do
|
||||
non_contact = eve.person
|
||||
|
||||
expect {
|
||||
alice.move_contact(non_contact, @new_aspect, @original_aspect)
|
||||
}.to raise_error
|
||||
|
||||
@original_aspect.contacts.where(:person_id => non_contact.id).should be_empty
|
||||
@new_aspect.contacts.where(:person_id => non_contact.id).should be_empty
|
||||
end
|
||||
|
||||
it 'does not try to delete if add person did not go through' do
|
||||
alice.should_receive(:add_contact_to_aspect).and_return(false)
|
||||
alice.should_not_receive(:delete_person_from_aspect)
|
||||
alice.move_contact(bob.person, @new_aspect, @original_aspect)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'likes' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue