aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorlest <just.lest@gmail.com>2011-12-05 19:05:03 +0300
committerlest <just.lest@gmail.com>2011-12-05 19:15:36 +0300
commit1f0e21ce3037b03a125229810d584db77c0c6ed4 (patch)
treefdea4439e2d7270f9b5ee60ef11999a8b71e5e4b /actionpack/test/controller
parentd4964b338667fb14d7755cd90af88bb267238958 (diff)
downloadrails-1f0e21ce3037b03a125229810d584db77c0c6ed4.tar.gz
rails-1f0e21ce3037b03a125229810d584db77c0c6ed4.tar.bz2
rails-1f0e21ce3037b03a125229810d584db77c0c6ed4.zip
use classify in ParamsWrapper to derive model name from controller name
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/params_wrapper_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb
index 7bef1e8d5d..0102f66dfe 100644
--- a/actionpack/test/controller/params_wrapper_test.rb
+++ b/actionpack/test/controller/params_wrapper_test.rb
@@ -285,3 +285,38 @@ class AnonymousControllerParamsWrapperTest < ActionController::TestCase
end
end
end
+
+class IrregularInflectionParamsWrapperTest < ActionController::TestCase
+ include ParamsWrapperTestHelp
+
+ class ParamswrappernewsItem
+ def self.attribute_names
+ ['test_attr']
+ end
+ end
+
+ class ParamswrappernewsController < ActionController::Base
+ class << self
+ attr_accessor :last_parameters
+ end
+
+ def parse
+ self.class.last_parameters = request.params.except(:controller, :action)
+ head :ok
+ end
+ end
+
+ tests ParamswrappernewsController
+
+ def test_uses_model_attribute_names_with_irregular_inflection
+ ActiveSupport::Inflector.inflections do |inflect|
+ inflect.irregular 'paramswrappernews_item', 'paramswrappernews'
+ end
+
+ with_default_wrapper_options do
+ @request.env['CONTENT_TYPE'] = 'application/json'
+ post :parse, { 'username' => 'sikachu', 'test_attr' => 'test_value' }
+ assert_parameters({ 'username' => 'sikachu', 'test_attr' => 'test_value', 'paramswrappernews_item' => { 'test_attr' => 'test_value' }})
+ end
+ end
+end