ref: refs/heads/master
commit bbee09a1146f75d3487a2016f9703c684d36345d
Author: Josef Reidinger
Date: Mon Sep 21 11:22:07 2009 +0200
fix tests to expect 422 on bad arguments
---
.../app/controllers/application_controller.rb | 6 ++++--
webservice/lib/exceptions.rb | 2 +-
webservice/test/plugin_basic_tests.rb | 6 ++----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/webservice/app/controllers/application_controller.rb b/webservice/app/controllers/application_controller.rb
index 108cade..5374069 100644
--- a/webservice/app/controllers/application_controller.rb
+++ b/webservice/app/controllers/application_controller.rb
@@ -1,12 +1,14 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
+require 'exceptions'
+
class ApplicationController < ActionController::Base
- rescue_from :BackendException do |exception|
+ rescue_from 'BackendException' do |exception|
render :xml => exception, :status => 503
end
- rescue_from :InvalidParameters do |exception|
+ rescue_from 'InvalidParameters' do |exception|
render :xml => exception, :status => 422 #422-resource invalid
end
diff --git a/webservice/lib/exceptions.rb b/webservice/lib/exceptions.rb
index 1f2abc1..6dca0f4 100644
--- a/webservice/lib/exceptions.rb
+++ b/webservice/lib/exceptions.rb
@@ -43,7 +43,7 @@ class InvalidParameters < ArgumentError
# Creates standartized xml for ActiveResource validation - http://railsbrain.com/api/rails-2.3.2/doc/index.html?a=C00000626&name=Base
# error is reported in format '<humanized argument name> --- <error identificator>
- def to_xml()
+ def to_xml(options={})
xml = Builder::XmlMarkup.new(options)
xml.instruct! unless options[:skip_instruct]
diff --git a/webservice/test/plugin_basic_tests.rb b/webservice/test/plugin_basic_tests.rb
index 11907cd..03c69f5 100644
--- a/webservice/test/plugin_basic_tests.rb
+++ b/webservice/test/plugin_basic_tests.rb
@@ -65,10 +65,8 @@ module PluginBasicTests
def test_update_noparams
@model_class.stubs(:save)
- put :update
- # FIXME: it is not 404, but 422 unprocessable entity,
- # see "Validation errors" in http://api.rubyonrails.org/classes/ActiveResource/Base.html
- assert_response :missing
+ put :update
+ assert_response 422
end
def test_update_noperm
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org