From 5f993e4bd360f8f864245069d37a01125db824c2 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Mon, 4 May 2015 01:01:37 +0000 Subject: [PATCH] Return errors in API playlists/create --- app/controllers/api/playlists_controller.rb | 2 +- spec/integration/api/playlists_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/playlists_controller.rb b/app/controllers/api/playlists_controller.rb index fc4e367..5bb721e 100644 --- a/app/controllers/api/playlists_controller.rb +++ b/app/controllers/api/playlists_controller.rb @@ -14,7 +14,7 @@ module API if @playlist.save render :show, status: :created else - render json: :nothing, status: :unprocessable_entity + render json: @playlist.errors, status: :unprocessable_entity end end diff --git a/spec/integration/api/playlists_spec.rb b/spec/integration/api/playlists_spec.rb index 65d1914..992b09d 100644 --- a/spec/integration/api/playlists_spec.rb +++ b/spec/integration/api/playlists_spec.rb @@ -47,6 +47,12 @@ describe 'API playlists' do it 'responds with unprocessable entity status' do expect(response).to have_http_status 422 end + + it 'returns errors' do + expect(json 422).to match( + name: [an_instance_of(String)] + ) + end end end