format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
end
else
- # Send html if the query is not valid
- render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
+ respond_to do |format|
+ format.any(:html, :atom, :csv, :pdf) { render(:template => 'issues/index.rhtml', :layout => !request.xhr?) }
+ format.api { render_validation_errors(@query) }
+ end
end
rescue ActiveRecord::RecordNotFound
render_404
}
end
end
+
+ context "with invalid query params" do
+ should "return errors" do
+ get '/issues.xml', {:f => ['start_date'], :op => {:start_date => '='}}
+
+ assert_response :unprocessable_entity
+ assert_equal 'application/xml', @response.content_type
+ assert_tag 'errors', :child => {:tag => 'error', :content => "Start date can't be blank"}
+ end
+ end
end
context "/index.json" do