Get rid of error on aspect_memberships destroy if someone has noscript on or something

This commit is contained in:
Raphael Sofaer 2011-08-10 17:40:38 -07:00
parent 20523f99af
commit 90a5cd2254
2 changed files with 11 additions and 1 deletions

View file

@ -22,11 +22,11 @@ class AspectMembershipsController < ApplicationController
flash.now[:notice] = I18n.t 'aspect_memberships.destroy.success'
respond_with do |format|
format.all{ }
format.json{ render :json => {
:person_id => @person_id,
:aspect_ids => @contact.aspects.map{|a| a.id}
} }
format.html{ redirect_to :back }
end
else

View file

@ -93,6 +93,16 @@ describe AspectMembershipsController do
@aspect0.reload
@aspect0.contacts.include?(@contact).should be false
end
it 'does not 500 on an html request' do
alice.add_contact_to_aspect(@contact, @aspect1)
delete :destroy,
:id => 123,
:person_id => bob.person.id,
:aspect_id => @aspect0.id
response.should redirect_to :back
@aspect0.reload
@aspect0.contacts.include?(@contact).should be false
end
context 'aspect membership does not exist' do
it 'person does not exist' do