aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/constantize_test_cases.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix safe_constantize to not raise a LoadError.Keenan Brock2019-01-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary There was an issues when using `safe_constantize` on a string that has the wrong case. File `em.rb` defines `EM`. `"Em".safe_constantize` causes a little confusion with the autoloader. The autoloader finds file "em.rb", expecting it to define `Em`, but `Em` is not defined. The autoloader raises a `LoadError`, which is good, But `safe_constantize` is defined to return `nil` when a class is not found. ### Before ``` "Em".safe_constantize LoadError: Unable to autoload constant Em, \ expected rails/activesupport/test/autoloading_fixtures/em.rb to define it ``` ### After ``` "Em".safe_constantize # => nil ```
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Fix constantize edge case involving prepend, autoloading and name conflictsJean Boussier2016-12-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | In the following situation: ```ruby class Bar end module Baz end class Foo prepend Baz end class Foo::Bar end ``` Running `Inflector.constantize('Foo::Bar')` would blow up with a NameError. What is happening is that `constatize` was written before the introduction of prepend, and wrongly assume that `klass.ancestors.first == klass`. So it uses `klass.ancestors.inject` without arguments, as a result a prepended module is used in place of the actual class.
* applies new string literal convention in activesupport/testXavier Noria2016-08-061-5/+5
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Merge pull request #21250 from ronakjangir47/safe_constYves Senn2015-09-071-0/+4
|\ | | | | | | safe_constantize - Added Object scoped missing test cases
| * safe_constantize - Added Object scoped missing test casesRonak Jangir2015-09-061-0/+2
|/
* Use `safe_constantize`.Guo Xiang Tan2014-09-021-0/+30
| | | | Fixes https://github.com/rails/rails/issues/9933.
* Add Missing Test Cases for the constantizeAditya Kapoor2014-06-071-0/+11
|
* Fix #10932. Treat "" and "::" as invalid on constantizeNikolay Shebanov2013-06-141-4/+4
|
* cleaning up constantize testsAaron Patterson2012-11-071-44/+44
|
* Handle case where ancestor is not the end of the chainAndrew White2012-05-191-0/+2
|
* Fix constantize so top level constants are looked up properly.Marc-Andre Lafortune2012-05-191-0/+18
|
* Make constantize look down the ancestor chain (excluding Object)Marc-Andre Lafortune2012-05-191-0/+17
|
* safe_constantize should handle wrong constant name NameErrors Fixes #4710Alex Tambellini2012-01-261-2/+3
|
* Ensure that constantize just rescues NameError that applies to the constant ↵José Valim2011-09-231-0/+6
| | | | being currently loaded.
* Added ActiveSupport::Inflector.safe_constantize and String#safe_constantize; ↵Ryan Oblak2011-09-231-0/+31
refactored common constantize tests into ConstantizeTestCases