Rescue from duplicate key errors in AspectMembershipsController
This commit is contained in:
parent
7f5f696642
commit
69619f9ba2
2 changed files with 13 additions and 2 deletions
|
|
@ -76,4 +76,8 @@ class AspectMembershipsController < ApplicationController
|
|||
render :text => response_hash.to_json
|
||||
end
|
||||
|
||||
rescue_from ActiveRecord::RecordNotUnique do
|
||||
render :text => "Duplicate record rejected.", :status => 400
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -62,6 +62,13 @@ describe AspectMembershipsController do
|
|||
flash[:error].should_not be_empty
|
||||
end
|
||||
|
||||
it 'does not 500 on a duplicate key error' do
|
||||
params = {:format => 'js', :person_id => @person.id, :aspect_id => @aspect0.id}
|
||||
post :create, params
|
||||
post :create, params
|
||||
response.status.should == 400
|
||||
end
|
||||
|
||||
context 'json' do
|
||||
it 'returns a list of aspect ids for the person' do
|
||||
post :create,
|
||||
|
|
|
|||
Loading…
Reference in a new issue