Commit aed413b4 authored by danielgrippi's avatar danielgrippi

remove unused method and controller action (move_contact)

parent e4f4f064
......@@ -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]
......
......@@ -182,7 +182,7 @@ describe User do
time = Time.now
Time.stub(:now).and_return(time)
alice.send(:prep_opts, Post, {}).should == {
:type => Stream::Base::TYPES_OF_POST_IN_STREAM,
:type => Stream::Base::TYPES_OF_POST_IN_STREAM,
:order => 'created_at DESC',
:limit => 15,
:hidden => false,
......@@ -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|
......@@ -229,7 +229,7 @@ describe User do
# It should respect the order option
opts = {:order => 'updated_at DESC'}
bob.visible_shareables(Post, opts).first.updated_at.should > bob.visible_shareables(Post, opts).last.updated_at
# It should respect the limit option
opts = {:limit => 40}
bob.visible_shareables(Post, opts).length.should == 40
......
......@@ -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
......@@ -1000,7 +972,7 @@ describe User do
user.should_not_receive(:generate_reset_password_token)
user.send_reset_password_instructions
end
it "queues up a job to send the reset password instructions" do
user = Factory :user
Resque.should_receive(:enqueue).with(Jobs::ResetPassword, user.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment