la pirata quizas no esta en la barca closes #13

This commit is contained in:
f 2020-02-26 21:05:59 -03:00
parent ce699c1344
commit 9018c30e90
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
2 changed files with 9 additions and 1 deletions

View file

@ -117,7 +117,7 @@ class BarcasController < ApplicationController
def abandonar
find_barca
if @barca.tripulaciones.find_by(pirata: current_pirata).destroy
if @barca.tripulaciones.find_by(pirata: current_pirata).try :destroy
notify(subject: :abandonar, urgency: :'very-low', ttl: 1.day)
render status: :no_content
else

View file

@ -94,6 +94,14 @@ class BarcasControllerTest < ActionDispatch::IntegrationTest
assert_not barca.reload.piratas.include?(@pirata)
end
test 'no se pueden abandonar si no estan abordadas' do
barca = create :barca
delete barca_abandonar_url(barca), as: :json, headers: @auth
assert_response :unprocessable_entity
end
test 'se pueden abordar' do
barca = create :barca