##// END OF EJS Templates
Respond with errors and appropriate content type on /issues API calls with invalid query params (#8883)....
Jean-Philippe Lang -
r6189:fdd5367ebab2
parent child
Show More
@@ -96,8 +96,10 class IssuesController < ApplicationController
96 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
96 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
97 end
97 end
98 else
98 else
99 # Send html if the query is not valid
99 respond_to do |format|
100 render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
100 format.any(:html, :atom, :csv, :pdf) { render(:template => 'issues/index.rhtml', :layout => !request.xhr?) }
101 format.api { render_validation_errors(@query) }
102 end
101 end
103 end
102 rescue ActiveRecord::RecordNotFound
104 rescue ActiveRecord::RecordNotFound
103 render_404
105 render_404
@@ -101,6 +101,16 class ApiTest::IssuesTest < ActionController::IntegrationTest
101 }
101 }
102 end
102 end
103 end
103 end
104
105 context "with invalid query params" do
106 should "return errors" do
107 get '/issues.xml', {:f => ['start_date'], :op => {:start_date => '='}}
108
109 assert_response :unprocessable_entity
110 assert_equal 'application/xml', @response.content_type
111 assert_tag 'errors', :child => {:tag => 'error', :content => "Start date can't be blank"}
112 end
113 end
104 end
114 end
105
115
106 context "/index.json" do
116 context "/index.json" do
General Comments 0
You need to be logged in to leave comments. Login now