From 567ac65b423c30c24aa6c0c0522858e3c240eb26 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 3 Feb 2012 11:47:47 -0500 Subject: Fix override API response bug in respond_with Default responder was only using the given respond block when user requested for HTML format, or JSON/XML format with valid resource. This fix the responder so that it will use the given block regardless of the validity of the resource. Note that in this case you'll have to check for object's validity by yourself in the controller. Fixes #4796 --- actionpack/test/lib/controller/fake_models.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/test/lib/controller/fake_models.rb') diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb index f2362714d7..bbb4cc5ef3 100644 --- a/actionpack/test/lib/controller/fake_models.rb +++ b/actionpack/test/lib/controller/fake_models.rb @@ -34,6 +34,16 @@ end class GoodCustomer < Customer end +class ValidatedCustomer < Customer + def errors + if name =~ /Sikachu/i + [] + else + [{:name => "is invalid"}] + end + end +end + module Quiz class Question < Struct.new(:name, :id) extend ActiveModel::Naming -- cgit v1.2.3