Commit Graph

6898 Commits

Author SHA1 Message Date
Jean Boussier
11e05defec Fix constantize edge case involving prepend, autoloading and name conflicts
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.
2016-12-14 14:25:43 +01:00
yuuji.yaginuma
2f6105e494 fix new warning in ruby 2.4
This fixes the following warning.

```
test/caching_test.rb:986: warning: parentheses after method name is interpreted as
test/caching_test.rb:986: warning: an argument list, not a decomposed argument

test/cases/adapters/mysql2/reserved_word_test.rb:146: warning: parentheses after method name is interpreted as
test/cases/adapters/mysql2/reserved_word_test.rb:146: warning: an argument list, not a decomposed argument
```

Ref: 65e27c8b13
2016-12-14 08:58:39 +09:00
yuuji.yaginuma
2cb8558120 change return value of duplicable? with Ruby 2.4+
`NilClass`, `FalseClass`, `TrueClass`, `Symbol` and `Numeric` can dup
with Ruby 2.4+.

Ref: https://bugs.ruby-lang.org/issues/12979
2016-12-13 07:35:36 +09:00
Akira Matsuda
5d07e8a326 💅 2016-12-13 00:48:14 +09:00
Akira Matsuda
bd9e134b01 nil, true, 1, etc. don't raise on #dup since Ruby 2.4
https://bugs.ruby-lang.org/issues/12979
2016-12-13 00:43:56 +09:00
Akira Matsuda
b87619f945 Keep AS::XmlMini::PARSING["decimal"].call('') returning 0
BigDecimal('an invalid string') has changed its behavior to raise an ArgumentError since 1.3.0
https://bugs.ruby-lang.org/issues/10286
2016-12-13 00:06:08 +09:00
Toshimaru
d9ff835b99 split DELEGATION_RESERVED_METHOD_NAMES in half 2016-12-09 05:21:11 +09:00
yuuji.yaginuma
d71f289fb2 stop using removed render :text
Follow up to 79a5ea9eadb4d43b62afacedc0706cbe88c54496
2016-12-03 15:28:59 +09:00
Sean Griffin
4e73ffa9b4 Exclude singleton classes from subclasses and descendants
This behavior changed in Ruby starting with 2.3.0, as a result of
https://bugs.ruby-lang.org/issues/11360. This results in a change in
behavior of these methods which is likely undesirable.

Fixes #27238
2016-12-01 14:53:31 -05:00
Matthew Draper
f9592e1631 Merge pull request #27206 from kirs/fix-testing-isolation-2
Fix arguments passing in testing isolation
2016-12-01 05:57:18 +10:30
Kir Shatrov
4b3cd4b0fe Fix arguments passing in testing isolation
The issue affects MRI 2.2.5, MRI 2.3.3, JRuby 9.1.6.0. It can be reproduced by:

```
$ cd activemodel
$ NO_FORK=1 bundle exec rake test
```

If we wrap original arguments in quotes, it will be considered as a one big single argument.
Later, [`rake/rake_test_loader.rb`](https://github.com/ruby/rake/blob/7863b97/lib/rake/rake_test_loader.rb#L15)
will iterate over ARGS and try to require that huge single "argument" (which is a list of multiple .rb files).
This leads to an exception:

```
/Users/kir/Project
s/opensource/rails/vendor/bundle/gems/rake-11.3.0/lib/rake/rake_test_loader.rb:15:in `require': cannot load such file -- /Users/kir/Projects/opensource/rails/activemodel/test/cases/
attribute_assignment_test.rb [stripped] /Users/kir/Projects/opensource/rails/activemodel/test/cases/validations/with_validation_test.rb /Users/kir/Projects/opensource/rails/activemodel/test/cases/validations_test
.rb (LoadError)

        from /Users/kir/Projects/opensource/rails/vendor/bundle/gems/rake-11.3.0/lib/rake/rake_test_loader.rb:15:in `block in <main>'
        from /Users/kir/Projects/opensource/rails/vendor/bundle/gems/rake-11.3.0/lib/rake/rake_test_loader.rb:4:in `select'
        from /Users/kir/Projects/opensource/rails/vendor/bundle/gems/rake-11.3.0/lib/rake/rake_test_loader.rb:4:in `<main>'
```

Originally quotes were introduced in https://github.com/rails/rails/pull/19819 to fix MRI 2.2.2.

The fix solves issue on all affected platforms: MRI 2.2.5, MRI 2.3.3, JRuby 9.1.6.0.
2016-11-30 14:02:02 -05:00
Akira Matsuda
7e73145b39 Missing require 'active_support/notifications' 2016-11-30 11:28:34 +09:00
Sean Griffin
32f215c301 Treat combined durations as a single unit
Prior to this commit, `3.months - 3.months` would result in a duration
that has the "parts" of `[[:months, 3], [:months, -3]]`. This would mean
that it was subtly different than `2.months - 2.months`. When applied to
a time, the date might actually change if the resulting day doesn't
exist however many months in the future, even though in both cases we
just wanted to add `0`, which should always be an identity operation.

With this change, we now store the parts as a hash, so `3.months -
3.months` is simply stored as `{ months: 0 }`.
2016-11-29 13:02:14 -05:00
yuuji.yaginuma
32225387c1 use public Module#include instead of send :include
Follow up to #18767
2016-11-27 22:20:52 +09:00
Matthew Draper
f243e7f0d0 Merge pull request #26874 from tgxworld/fix_broadcast_logger
`Broadcast#silence` breaks custom loggers that do not include `Logg…
2016-11-25 15:57:50 +10:30
Ryuta Kamizono
d99b3848bb Fix require_dependency message format
`depend_on` message format is `"No such file to load -- %s.rb"`.
But `require_dependency` message is missing `.rb` suffix.

```
% git grep -n 'No such file to load'
actionview/test/actionpack/abstract/helper_test.rb:112:        assert_equal "No such file to load -- very_invalid_file_name.rb", e.message
activesupport/lib/active_support/dependencies.rb:245:      def require_dependency(file_name, message = "No such file to load -- %s.rb")
activesupport/lib/active_support/dependencies.rb:333:    def depend_on(file_name, message = "No such file to load -- %s.rb")
```
2016-11-25 06:56:05 +09:00
Yves Senn
2b4a9735d8 update bin/test scripts to prevent double runs.
The test runner was updated to make use of autorun. This caused the
`bin/test` scripts to run Minitest twice.
2016-11-21 17:25:12 +01:00
Kasper Timm Hansen
6d6249b1c1 ✂️ needless lines beneath private. 2016-11-20 17:58:36 +01:00
Jon Moss
8e3901b5e6 Move tests to a module, include in subclasses, style linting
This fixes an error where the test runner would try and run
XMLMiniEngineTest like a normal test class, except it's abstract. Now,
to circumvent this, we don't include any of the actual tests in
XMLMiniEngineTest; they are wrapped in a module that is included in
subclass when they inherit from XMLMiniEngineTest. Pretty neat, huh?
2016-11-20 10:46:16 -05:00
Jon Moss
0ab54f4a49 Create XMLMiniEngineTest; base class for all tests 2016-11-20 10:46:16 -05:00
Jon Moss
2bdc4ddc06 Code styling cleanup 2016-11-20 10:45:58 -05:00
Jon Moss
305e2922a4 Create CommonXMLMiniAdapterTest; common tests module
Created a new module (a la Action Cable subscription adapter's test
suite) to be included in all sub class test to ensure compatability and
reduce duplicated code.
2016-11-20 10:45:09 -05:00
Jon Moss
1d18b9b2fb Do not include ActiveSupport into test classes
Will help get rid of errors like the following:

```
  1) Error:
JDOMEngineTest#test_order=:
ArgumentError: wrong number of arguments (0 for 1)
    /Users/jon/code/rails/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb:106:in `test_order='
```
2016-11-19 10:30:57 -05:00
Rafael França
76c273868e Merge pull request #27070 from jonhyman/patch-raw-true
Removes 'raw: true' from MemCacheStore#read_multi
2016-11-17 18:18:34 -05:00
Sean Griffin
7a3be90dce Refactor the handling of fallback exception handlers 2016-11-17 15:03:57 -05:00
Sean Griffin
f48bb1b4ad Call fallback exception handlers with the right exception
The issue presented in #26246 showed a deeper underlying problem. When
we fell back to the exception handler for an exceptions cause, we were
calling that handler with the outer raised exception. This breaks the
calling code's expectations, especially if the exception has methods on
it behond those from `StandardError`.
2016-11-17 14:50:41 -05:00
Jonathan Hyman
226b845113 Removes 'raw: true' from MemCacheStore#read_multi, per https://github.com/rails/rails/issues/27066. 2016-11-16 15:42:31 -05:00
Kir Shatrov
3261470452 Fix testing isolation
AS::Testing::Isolation has two ways to isolate the process:
forking and subprocessing. The second way is used on JRuby and other
platforms that don't support forking.

The way how subprocessing works is that we prepare a command to run a
new process:

```
/opt/rubies/2.3.0/bin/ruby -I{skipped_load_path} test/initializable_test.rb '' -nInitializableTests::Basic#test_Initializer_provides_context's_class_name
```

As you see, there's unescaped quote at the end of the line.
It leads to:

```
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
```

This fixes tests on MRI + NO_FORK variable and on JRuby 🎉
2016-11-15 15:56:32 -05:00
yuuji.yaginuma
7d1e104f66 remove duplicated changelog entry [ci skip] 2016-11-15 07:43:21 +09:00
Andrew White
e491b2c063 Merge pull request #27035 from rails/remove-active-support-deprecations
Remove Active Support deprecations
2016-11-14 19:59:43 +00:00
Rafael Mendonça França
7c1566b278
Revert "Merge pull request #25811 from oss92/to_sentence_fallback_string"
This reverts commit bad3a120f1690f393d8f6204b3ceee60f0ce707b, reversing
changes made to 2384317465ccb1dfca456a2b7798714b99f32711.

Reason: Adding a new option in the API for something that can be done
with a `#presence` check could do.
2016-11-14 13:16:00 -05:00
Andrew White
0d7bd2031b Remove deprecated class ActiveSupport::Concurrency::Latch 2016-11-14 12:44:19 +00:00
Andrew White
0189f4db6f Remove deprecated separator argument from parameterize 2016-11-14 12:14:23 +00:00
Andrew White
90520d2eee Remove deprecated method Numeric#to_formatted_s 2016-11-14 12:03:48 +00:00
Andrew White
7c848e6dd4 Remove deprecated method alias_method_chain 2016-11-14 11:57:30 +00:00
Andrew White
8e43fc5ace Remove deprecated constant MissingSourceFIle 2016-11-14 11:25:52 +00:00
Andrew White
b93a257186 Remove deprecated Module.qualified_const_get/set/defined? 2016-11-14 08:11:21 +00:00
Rafael França
f1c5b0bd0a Merge pull request #26222 from vipulnsward/26134-fix
Format and send logs to logger.fatal from DebugExceptions
2016-11-13 22:50:30 -05:00
Andrew White
213f0d63a5 Update CHANGELOG 2016-11-13 23:25:05 +00:00
Andrew White
dadba9ae57 Remove deprecated :prefix option 2016-11-13 23:09:03 +00:00
Andrew White
2ff2b98032 Remove deprecated new_from_hash_copying_default 2016-11-13 23:09:03 +00:00
Andrew White
0e8d297301 Remove deprecated time marshal core_ext file 2016-11-13 23:09:03 +00:00
Andrew White
73b18eccdf Remove deprecated struct core_ext file 2016-11-13 23:09:02 +00:00
Vipul A M
546ff50d82
Remove warning from access to Bignum class, 2**64 is already a known bignum value. See also http://patshaughnessy.net/2014/1/9/how-big-is-a-bignum for smallest bignum value 2016-11-13 18:08:57 -05:00
Andrew White
2ae41d24b9 Remove deprecated module method_transplanting file 2016-11-13 22:29:18 +00:00
Andrew White
c32ccd837e Remove deprecated local_constants 2016-11-13 22:28:18 +00:00
Andrew White
c9458c74e0 Remove deprecated kernel debugger file 2016-11-13 22:27:52 +00:00
Andrew White
3641cd3f3d Remove deprecated namespaced_key 2016-11-13 22:17:37 +00:00
Andrew White
8b646041be Remove deprecated set_cache_value 2016-11-13 22:16:54 +00:00
Andrew White
efdb785d7f Remove deprecated escape_key 2016-11-13 22:15:45 +00:00