diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-11 00:08:18 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-11 00:08:43 +0200 |
commit | a87894ae57dcabbb299886959ec5646e356a7b56 (patch) | |
tree | 594d1808788c0a093970a54a5fd96dd32d28877d /actionpack/test | |
parent | 9a7dbe2c0570e11b9033df735c937d5f5416e0ca (diff) | |
download | rails-a87894ae57dcabbb299886959ec5646e356a7b56.tar.gz rails-a87894ae57dcabbb299886959ec5646e356a7b56.tar.bz2 rails-a87894ae57dcabbb299886959ec5646e356a7b56.zip |
Get around weird missing constant error caused by AS instead of simply raising NameError, closes #477.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/params_wrapper_test.rb | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb index 548cd02dc0..85464fc780 100644 --- a/actionpack/test/controller/params_wrapper_test.rb +++ b/actionpack/test/controller/params_wrapper_test.rb @@ -170,28 +170,36 @@ end class NamespacedParamsWrapperTest < ActionController::TestCase module Admin - class UsersController < ActionController::Base - class << self - attr_accessor :last_parameters - end - - def parse - self.class.last_parameters = request.params.except(:controller, :action) - head :ok + module Users + class UsersController < ActionController::Base; + class << self + attr_accessor :last_parameters + end + + def parse + self.class.last_parameters = request.params.except(:controller, :action) + head :ok + end end end end - class Sample + class SampleOne def self.column_names ["username"] end end - tests Admin::UsersController + class SampleTwo + def self.column_names + ["title"] + end + end + + tests Admin::Users::UsersController def teardown - Admin::UsersController.last_parameters = nil + Admin::Users::UsersController.last_parameters = nil end def test_derived_name_from_controller @@ -203,7 +211,7 @@ class NamespacedParamsWrapperTest < ActionController::TestCase end def test_namespace_lookup_from_model - Admin.const_set(:User, Class.new(Sample)) + Admin.const_set(:User, Class.new(SampleOne)) begin with_default_wrapper_options do @request.env['CONTENT_TYPE'] = 'application/json' @@ -216,20 +224,15 @@ class NamespacedParamsWrapperTest < ActionController::TestCase end def test_hierarchy_namespace_lookup_from_model - # Make sure that we cleanup ::Admin::User - admin_user_constant = ::Admin::User - ::Admin.send :remove_const, :User - - Object.const_set(:User, Class.new(Sample)) + Object.const_set(:User, Class.new(SampleTwo)) begin with_default_wrapper_options do @request.env['CONTENT_TYPE'] = 'application/json' post :parse, { 'username' => 'sikachu', 'title' => 'Developer' } - assert_parameters({ 'username' => 'sikachu', 'title' => 'Developer', 'user' => { 'username' => 'sikachu' }}) + assert_parameters({ 'username' => 'sikachu', 'title' => 'Developer', 'user' => { 'title' => 'Developer' }}) end ensure Object.send :remove_const, :User - ::Admin.const_set(:User, admin_user_constant) end end @@ -241,6 +244,6 @@ class NamespacedParamsWrapperTest < ActionController::TestCase end def assert_parameters(expected) - assert_equal expected, Admin::UsersController.last_parameters + assert_equal expected, Admin::Users::UsersController.last_parameters end -end +end
\ No newline at end of file |