aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/lib/controller
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2012-02-03 11:47:47 -0500
committerPrem Sichanugrist <s@sikachu.com>2012-02-03 14:15:51 -0500
commit3def1c8edb9062a5ca473bf32f0967daab951654 (patch)
tree5d896f957681b58eb6f4ac10da53a74e7a106833 /actionpack/test/lib/controller
parentd709b124d1815340f4a2229b05362ea37298288f (diff)
downloadrails-3def1c8edb9062a5ca473bf32f0967daab951654.tar.gz
rails-3def1c8edb9062a5ca473bf32f0967daab951654.tar.bz2
rails-3def1c8edb9062a5ca473bf32f0967daab951654.zip
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
Diffstat (limited to 'actionpack/test/lib/controller')
-rw-r--r--actionpack/test/lib/controller/fake_models.rb10
1 files changed, 10 insertions, 0 deletions
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