@@ -0,0 +1,5 | |||
|
1 | api.array :errors do | |
|
2 | @error_messages.each do |message| | |
|
3 | api.error message | |
|
4 | end | |
|
5 | end |
@@ -508,15 +508,8 class ApplicationController < ActionController::Base | |||
|
508 | 508 | |
|
509 | 509 | # Renders API response on validation failure |
|
510 | 510 | def render_validation_errors(object) |
|
511 | options = { :status => :unprocessable_entity, :layout => false } | |
|
512 | options.merge!(case params[:format] | |
|
513 | when 'xml'; { :xml => object.errors } | |
|
514 | when 'json'; { :json => {'errors' => object.errors} } # ActiveResource client compliance | |
|
515 | else | |
|
516 | raise "Unknown format #{params[:format]} in #render_validation_errors" | |
|
517 | end | |
|
518 | ) | |
|
519 | render options | |
|
511 | @error_messages = object.errors.full_messages | |
|
512 | render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => false | |
|
520 | 513 | end |
|
521 | 514 | |
|
522 | 515 | # Overrides #default_template so that the api template |
@@ -498,7 +498,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
498 | 498 | end |
|
499 | 499 | |
|
500 | 500 | json = ActiveSupport::JSON.decode(response.body) |
|
501 |
assert json['errors'].include?( |
|
|
501 | assert json['errors'].include?("Subject can't be blank") | |
|
502 | 502 | end |
|
503 | 503 | end |
|
504 | 504 | |
@@ -674,7 +674,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
674 | 674 | put '/issues/6.json', @parameters, credentials('jsmith') |
|
675 | 675 | |
|
676 | 676 | json = ActiveSupport::JSON.decode(response.body) |
|
677 |
assert json['errors'].include?( |
|
|
677 | assert json['errors'].include?("Subject can't be blank") | |
|
678 | 678 | end |
|
679 | 679 | end |
|
680 | 680 |
General Comments 0
You need to be logged in to leave comments.
Login now