Commit Graph

7244 Commits

Author SHA1 Message Date
Jon Moss
2b4583f2a2 Move CHANGELOG.md entry from Active Support to Action Pack
Was looking through #28402, and realized the CHANGELOG.md entry is in the wrong
place. Sorry we didn't catch this during code review 😢

[ci skip]
2017-04-11 18:52:02 -04:00
Julian Nadeau
35fac87123
Add action_controller_api, action_controller_base on_load hook 2017-04-10 19:34:48 -04:00
Josh Pencheon
2144e70a86 Implement fetch_values for HashWithIndifferentAccess (#28316)
`fetch_values` was added to Hash in Ruby 2.3.0:
  https://bugs.ruby-lang.org/issues/10017

This patch adds an implemention for instances of HWAI, in line
with the existing definitions of `fetch` and `values_at`.
2017-04-10 10:20:13 +09:30
Matthew Draper
d928126725 delegate_missing_to should fall back to super 2017-04-09 20:07:12 +09:30
Matthew Draper
071882e8ef delegate_to_missing doesn't delegate private methods
So we shouldn't claim they're there, even when asked explicitly.
2017-04-09 20:00:12 +09:30
Dorian Marié
a5ce433f11
Mention and test for possible ArgumentError when parsing times 2017-04-08 16:16:27 -07:00
Ryuta Kamizono
49d02ac358 Fix warning: already initialized constant HashWithIndifferentAccessTest::HashWithIndifferentAccess
Caused since #28607.
2017-04-07 08:18:11 +09:00
bogdanvlviv
49a463717e Prevent aliases Array#append and Array#prepend
f57d515d69
2017-04-02 17:13:28 +03:00
Michael Stock
ec9fffd3e0 Move HashWithIndifferentAccess tests to separate file 2017-03-30 00:05:40 -05:00
Matt Casper
0117810cda Add aliases for reverse_merge to with_defaults
In the context of controller parameters, reverse_merge is commonly used
to provide defaults for user input. Having an alias to reverse_merge
called with_defaults feels more idiomatic for Rails.
2017-03-29 15:55:09 -05:00
Rafael Mendonça França
d046390c32
Use keyword arguments instead of hash 2017-03-28 18:02:00 -04:00
Rafael Mendonça França
0875256fe9
Merge pull request #28480 from mubashirhanif/add_keep_id_suffix_option_to_humanize_new
Add keep id suffix option to humanize new
2017-03-28 17:57:17 -04:00
Rafael Mendonça França
d55f7fee81
starts_with? is removed in Ruby 2.4 2017-03-28 16:01:35 -04:00
Rafael Mendonça França
8d50b45159
Merge pull request #1 from radiospiel/tickets/26955-listen-paths
No longer listens to dirs outside of the app directory.
2017-03-28 15:52:21 -04:00
Andrew White
d28c482435 Return unmapped timezones from country_zones
If a country doesn't exist in the MAPPINGS hash then create a new
`ActiveSupport::Timezone` instance using the supplied timezone id.

Fixes #28431.
2017-03-28 13:33:32 +01:00
Steven Bull
452f9ee0bc Add error logging to Active Job
Active Job logging instrumentation is changed to log errors (with
backtrace) when a job raises an exception in #perform. This improves
debugging during development and test with the default configuration.

Prior to Rails 5, the default development configuration ran jobs with
InlineAdapter, which would raise exceptions to the caller and be
shown in the development log. In Rails 5, the default adapter was
changed to AsyncAdapter, which would silently swallow exceptions
and log a "Performed SomeJob from Async..." info message. This could
be confusing to a developer, as it would seem that the job was
performed successfully.

This patch removes the "Performed..." info message from the log
and adds an error-level "Error performing SomeJob..." log message
which includes the exception backtrace for jobs that raise an
exception within the #perform method. It provides this behavior for
all adapters.
2017-03-27 17:10:24 -07:00
Yves Senn
40ba03adaa minor CHANGELOG formatting changes. [ci skip] 2017-03-26 12:14:11 +02:00
yuuji.yaginuma
af2e39f3d5 Fix doc format for duplicable? [ci skip] 2017-03-25 19:55:28 +09:00
Vipul A M
c07cc2986c
Remove unnecessary ruby version comments [ci skip] 2017-03-24 17:59:49 +05:30
Vipul A M
7045e03dee
Fix duplicable? for Ratiional and Complex on ruby master, since they are now duplicable 2017-03-23 17:34:30 +05:30
Rafael Mendonça França
25473baf40
No need to have an entry that was included in 5.1 in 5.2
[ci skip]
2017-03-22 19:28:01 -04:00
Dominic Cleal
f53a3005f5
Add AS::Deprecation::DeprecatedConstantAccessor
An alternative to DeprecatedConstantProxy which works more transparently
with exceptions because it returns the object that the new constant
refers to rather than a proxy. This is then compatible with
`rescue OldException`.
2017-03-22 16:21:40 +00:00
Matthew Draper
6c08d480f1 Start Rails 5.2 development 2017-03-22 10:11:39 +10:30
Mubashir Hanif
f0c8f1b085 Added options hash to titleize method and keep_id_suffix option to humanize
some documentation

remove extra whitespace.

Added id in the middle test case and corrected some testcases.

Some Coding standard guidelines corrections as suggested by codeclimate.

Some more corrections suggested by codeclimate.
2017-03-21 22:55:17 +01:00
Jon Moss
9bcc021286 Merge pull request #28446 from y-yagi/move_new_changelog_entry_to_the_top
Move new CHANGELOG entry to the top [ci skip]
2017-03-18 21:39:50 -04:00
Vipul A M
0a4d1c3cde Cleanup documentation fixes (#28460) 2017-03-17 17:33:35 +05:30
Vipul A M
d5c32f8711 Merge pull request #28445 from denniszelada/feature-documentation-with_options
Add documentation to use with_options anywhere in the same class [ci
2017-03-17 12:20:22 +05:30
Michael Hoy
202aadd4f4 number_to_human_converter: round before calculating exponent
fixes #25664
2017-03-16 16:36:47 -05:00
Michael Hoy
8bdc9e8d87 number_to_rounded_converter: extract rounding logic 2017-03-16 16:36:38 -05:00
Dennis Zelada
4ac5f90e92 Add documentation to use with_options in the same class [ci skip] 2017-03-16 18:15:36 +01:00
yuuji.yaginuma
41f8a9a03a Move new CHANGELOG entry to the top [ci skip] 2017-03-16 21:35:37 +09:00
Andrew White
b9c399de22 Fix test warnings 2017-03-16 09:16:20 +00:00
Andrew White
5055370828 Move to_time to DateTime compatibility.rb file
We are overriding it in `Time` and `ActiveSupport::TimeWithZone` so
there's no point in having it in the `DateAndTime::Compatibility`
module. Also add some docs for the `to_time` implementations.
2017-03-16 09:14:13 +00:00
Andrew White
ee33b9e93a Merge pull request #28147 from kmcphillips/master-time-freeze
Allow Time#to_time on frozen objects. Return frozen time rather than "RuntimeError: can't modify frozen Time"
2017-03-16 08:53:12 +00:00
Jon Moss
bd3f0e706c Tweak 28412
PR was merged before I could finished reviewing 😬

[ci skip]
2017-03-15 13:10:11 -04:00
Andrew White
8efbfba248 Merge pull request #28425 from rails/remove-duration-deprecation
Remove implicit coercion deprecation of durations
2017-03-15 15:46:55 +00:00
Rafael França
401d3ad56c Merge pull request #28412 from benoittgt/add_doc_for_message_encryptor_new
Add documentation about signature_key for MessageEncryptor.new [ci skip]
2017-03-15 11:32:23 -04:00
Andrew White
de5eb9ed98 Restore 5.minutes changed in #28204 2017-03-15 14:56:27 +00:00
Andrew White
a91ea1d510 Remove implicit coercion deprecation of durations
In #28204 we deprecated implicit conversion of durations to a
numeric which represented the number of seconds in the duration
because of unwanted side effects with calculations on durations
and dates. This unfortunately had the side effect of forcing a
explicit cast when configuring third-party libraries like
expiration in Redis, e.g:

    redis.expire("foo", 5.minutes)

To work around this we've removed the deprecation and added a
private class that wraps the numeric and can perform calculation
involving durations and ensure that they remain a duration
irrespective of the order of operations.
2017-03-15 14:56:27 +00:00
Benoit Tigeot
9a79201fd4 Add documentation about signature_key for MessageEncryptor.new [ci skip] 2017-03-15 08:56:44 +01:00
Jon Moss
0713efb509 Lint activesupport/CHANGELOG.md
[ci skip]
2017-03-13 19:45:35 -04:00
Vipul A M
5b0841ecea AS:Cache:MemoryStore doc fixes [ci skip] (#28389) 2017-03-12 14:35:43 +05:30
Vipul A M
254b831edd Merge pull request #27051 from devonestes/adding-cache-clear-docs
Add missing documentation for MemoryStore#clear [ci skip]
2017-03-12 14:20:06 +05:30
Ryuta Kamizono
2e752d18b3 Fix indentation and formatting in CHANGELOGs [ci skip] 2017-03-11 17:31:25 +09:00
Lin Jen-Shin
e63fb2407a Make sure local cache cleared even it's throwing:
We (GitLab) hit into an issue that somewhere in the middleware
chain was throwing `:warden`, which was caught in the wrapping
middleware, but `LocalCache::Middleware` was not aware of it.
It should look like:

``` ruby
result = catch(:warden) do
  @app.call(env)
end
```

Source: 090ed153db/lib/warden/manager.rb (L35-L37)

Using `ensure` could make sure that we would always do the cleanup,
and better yet, avoid `rescue Exception` which we all should know
that could cause some issues which could be very hard to debug.

Please check the discussion thread for more context:
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1402#note_25128108
2017-03-10 17:34:54 +00:00
Kevin McPhillips
92fc8ec663 Handle #to_time and memoization taking into account memoization, frozen state, and preserve_timezone flag. 2017-03-06 18:08:31 -05:00
yuuji.yaginuma
b9fa0fd2f1 Fix typo titlelize -> titleize [ci skip] 2017-03-07 08:08:19 +09:00
Andrew White
48b37f127f Update titlelize regex to allow apostrophes
In 4b685aa the regex in `titlelize` was updated to not match
apostrophes to better reflect the nature of the transformation.
Unfortunately this had the side effect of breaking capitalization
on the first word of a sub-string, e.g:

  >> "This was 'fake news'".titleize
  => "This Was 'fake News'"

This is fixed by extending the look-behind to also check for a
word character on the other side of the apostrophe.

Fixes #28312.
2017-03-06 17:51:03 +00:00
Erol Fornoles
e505bc8acd
Add CHANGELOG entry [skip ci] 2017-03-06 15:34:49 +08:00
Erol Fornoles
ee2979b905
Use method from Hash 2017-03-06 15:32:02 +08:00
Erol Fornoles
7b633857dd
Make the order of Hash#reverse_merge! consistent with HashWithIndifferentAccess 2017-03-06 15:32:01 +08:00
Andrew White
f0aeecda14 Add rfc3339 aliases to xmlschema
For naming consistency when using the RFC 3339 profile
of ISO 8601 in applications.
2017-03-03 21:53:13 +00:00
Andrew White
08e05d4a49 Add Time.rfc3339 parsing method
The `Time.xmlschema` and consequently its alias `iso8601` accepts
timestamps without a offset in contravention of the RFC 3339
standard. This method enforces that constraint and raises an
`ArgumentError` if it doesn't.
2017-03-03 21:53:13 +00:00
Andrew White
f61062c70f Add ActiveSupport::TimeZone.rfc3339 parsing method
Previously there was no way to get a RFC 3339 timestamp
into a specific timezone without either using `parse` or
chaining methods. The new method allows parsing directly
into the timezone, e.g:

    >> Time.zone = "Hawaii"
    => "Hawaii"
    >> Time.zone.rfc3339("1999-12-31T14:00:00Z")
    => Fri, 31 Dec 1999 14:00:00 HST -10:00

This new method has stricter semantics than the current
`parse` method and will raise an `ArgumentError`
instead of returning nil, e.g:

    >> Time.zone = "Hawaii"
    => "Hawaii"
    >> Time.zone.rfc3339("foobar")
    ArgumentError: invalid date
    >> Time.zone.parse("foobar")
    => nil

It will also raise an `ArgumentError` when either the
time or offset components are missing, e.g:

    >> Time.zone = "Hawaii"
    => "Hawaii"
    >> Time.zone.rfc3339("1999-12-31")
    ArgumentError: invalid date
    >> Time.zone.rfc3339("1999-12-31T14:00:00")
    ArgumentError: invalid date
2017-03-03 21:53:13 +00:00
Andrew White
4974b1a483 Add ActiveSupport::TimeZone.iso8601 parsing method
Previously there was no way to get a ISO 8601 timestamp into a specific
timezone without either using `parse` or chaining methods. The new method
allows parsing directly into the timezone, e.g:

    >> Time.zone = "Hawaii"
    => "Hawaii"
    >> Time.zone.iso8601("1999-12-31T14:00:00Z")
    => Fri, 31 Dec 1999 14:00:00 HST -10:00

If the timestamp is a ISO 8601 date (YYYY-MM-DD) then the time is set
to midnight, e.g:

    >> Time.zone = "Hawaii"
    => "Hawaii"
    >> Time.zone.iso8601("1999-12-31")
    => Fri, 31 Dec 1999 00:00:00 HST -10:00

This new method has stricter semantics than the current `parse` method
and will raise an `ArgumentError` instead of returning nil, e.g:

    >> Time.zone = "Hawaii"
    => "Hawaii"
    >> Time.zone.iso8601("foobar")
    ArgumentError: invalid date
    >> Time.zone.parse("foobar")
    => nil
2017-03-03 21:53:12 +00:00
Andrew White
fd8da71118 Fix typo in comment 2017-03-03 13:51:22 +00:00
Andrew White
75924c4517 Deprecate implicit coercion of ActiveSupport::Duration
Currently `ActiveSupport::Duration` implicitly converts to a seconds
value when used in a calculation except for the explicit examples of
addition and subtraction where the duration is the receiver, e.g:

    >> 2 * 1.day
    => 172800

This results in lots of confusion especially when using durations
with dates because adding/subtracting a value from a date treats
integers as a day and not a second, e.g:

    >> Date.today
    => Wed, 01 Mar 2017
    >> Date.today + 2 * 1.day
    => Mon, 10 Apr 2490

To fix this we're implementing `coerce` so that we can provide a
deprecation warning with the intent of removing the implicit coercion
in Rails 5.2, e.g:

    >> 2 * 1.day
    DEPRECATION WARNING: Implicit coercion of ActiveSupport::Duration
    to a Numeric is deprecated and will raise a TypeError in Rails 5.2.
    => 172800

In Rails 5.2 it will raise `TypeError`, e.g:

    >> 2 * 1.day
    TypeError: ActiveSupport::Duration can't be coerced into Integer

This is the same behavior as with other types in Ruby, e.g:

    >> 2 * "foo"
    TypeError: String can't be coerced into Integer
    >> "foo" * 2
    => "foofoo"

As part of this deprecation add `*` and `/` methods to `AS::Duration`
so that calculations that keep the duration as the receiver work
correctly whether the final receiver is a `Date` or `Time`, e.g:

    >> Date.today
    => Wed, 01 Mar 2017
    >> Date.today + 1.day * 2
    => Fri, 03 Mar 2017

Fixes #27457.
2017-03-02 08:00:22 +00:00
Andrew White
b5af751508 Update DateTime#change to support usec and nsec
Adding support for these options now allows us to update the
`DateTime#end_of` methods to match the equivalent `Time#end_of`
methods, e.g:

    datetime = DateTime.now.end_of_day
    datetime.nsec == 999999999 # => true

Fixes #21424.
2017-03-02 06:02:41 +00:00
Lukas Zapletal
4c484a69e2 Use DEFAULT_CIPHER constant in MessageEncryptor 2017-03-01 13:57:54 +01:00
Nick Johnstone
2d84a6bc74
Add Duration#before and #after as aliases for #ago and #since
It's common in test cases at my job to have code like this:

    let(:today) { customer_start_date + 2.weeks }
    let(:earlier_date) { today - 5.days }

With this change, we can instead write

    let(:today) { 2.weeks.after(customer_start_date) }
    let(:earlier_date) { 5.days.before(today) }

Closes #27721
2017-02-26 01:18:51 -07:00
Vipul A M
e842db501f
AS CHANGELOG Pass [ci skip] 2017-02-26 10:19:48 +05:30
Ryuta Kamizono
dd3adc5a04 Fix typo HashWithIndifferentAcces to HashWithIndifferentAccess [ci skip] 2017-02-25 11:17:01 +09:00
Matthew Draper
9099cf064f Merge pull request #28157 from robin850/hwia-soft-deprecation
Soft-deprecate the `HashWithIndifferentAccess` constant
2017-02-25 10:53:03 +10:30
Rafael Mendonça França
feea081199
Merge pull request #28006 from fareastside/master
Allow ActiveSupport::MarshalWithAutoloading#load to take a Proc
2017-02-24 19:17:01 -05:00
Rafael Mendonça França
ccb0095116
Fix CHANGELOG entry position [ci skip] 2017-02-24 19:01:42 -05:00
Robin Dupret
ac57a3ee0e Add few tests for the top level HashWithIndifferentAccess
This ensures that if we try to hard-deprecate it again in the future,
we won't break these behaviors.
2017-02-25 00:38:41 +01:00
Robin Dupret
e690a92b44 Soft-deprecate the top-level HashWithIndifferentAccess class
Since using a `ActiveSupport::Deprecation::DeprecatedConstantProxy`
would prevent people from inheriting this class and extending it
from the `ActiveSupport::HashWithIndifferentAccess` one would break
the ancestors chain, that's the best option we have here.
2017-02-25 00:29:43 +01:00
Dylan Thacker-Smith
29c02709cd Add missing gzip footer check in ActiveSupport::Gzip.decompress
A gzip file has a checksum and length for the decompressed data in its
footer which isn't checked by just calling Zlib::GzipReader#read.
Calling Zlib::GzipReader#close must be called after reading to the end
of the file causes this check to be done, which is done by
Zlib::GzipReader.wrap after its block is called.
2017-02-24 17:33:36 -05:00
Jeff Latz
a72498f776 add optional second argument to ActiveSupport core extension for Marshal#load so it can take a proc 2017-02-24 12:12:07 -05:00
Pavel Pravosud
b74c7e939a Make HWIA#compact not return nil when no nils 2017-02-23 15:24:22 -08:00
Rafael Mendonça França
f4acdd83ff
Preparing for 5.1.0.beta1 release 2017-02-23 14:53:21 -05:00
Godfrey Chan
135c5d5928 🙈 :nodoc: AS::Duration::ISO8601Serializer
This class should not be used directly, the public API is `AS::Duration#iso8601`.
2017-02-23 10:55:06 -08:00
Andrew White
a92bd65e37 Add more missing requires
Further missing requires for Timeout exposed due to Bundler 1.14.5
2017-02-22 14:05:37 +00:00
Andrew White
ac1862972c Add missing requires
Bundler 1.14.5 moved to lazily loading 'rubygems/spec_fetcher' which
revealed some missing requires from the JSON encoding test file.
2017-02-22 13:25:44 +00:00
Andrew White
240e32bbbf Add CHANGELOG entry for #28104 2017-02-22 08:29:58 +00:00
Adam Rice
6560448b46 Preload to_datetime before freezing a TimeWithZone instance 2017-02-22 14:16:59 +11:00
Kasper Timm Hansen
ff326e7456 Merge pull request #27941 from y-yagi/prevent_multiple_values_being_set_to_run_via
Prevent multiple values being set to `run_via`
2017-02-20 22:20:14 +01:00
Kasper Timm Hansen
507c9970ab Revert "Merge pull request #27925 from robin850/hwia-removal"
Pointed out by @matthewd that the HWIA subclass changes the
AS scoped class and top-level HWIA hierarchies out from under
existing classes.

This reverts commit 71da39097b67114329be6d8db7fe6911124531af, reversing
changes made to 41c33bd4b2ec3f4a482e6030b6fda15091d81e4a.
2017-02-20 22:15:31 +01:00
Matthew Draper
e9abbb700a Merge pull request #27863 from robin850/api-improvements
Some improvements to the API site's sidebar
2017-02-21 05:33:32 +10:30
Robin Dupret
e532531939 Deprecate the top-level HashWithIndifferentAccess contant
This constant was kept for the sake of backward compatibility; it
is still available under `ActiveSupport::HashWithIndifferentAccess`.

Furthermore, since Ruby 2.5 (https://bugs.ruby-lang.org/issues/11547)
won't support top level constant lookup, people would have to update
their code anyway.
2017-02-19 22:06:12 +01:00
yuuji.yaginuma
f38a660a60 Prevent multiple values being set to run_via
When executing the test via rake, since `rake` is set for `run_via`, `ruby` should not be set.
Related 2cb6c27310452da11b93d729c3b760ce988106e1
2017-02-18 09:49:57 +09:00
kenta-s
642880819b Fix doc in Multibyte::Chars [ci skip] 2017-02-17 08:07:37 +09:00
kenta-s
e07ebc13f4 Remove redundant namespaces from sample code of deprecated_method_warning [ci skip] 2017-02-15 19:31:33 +09:00
Mario Uher
3f79ee4862 Not ants were harmed! 🐜 2017-02-14 12:05:21 +01:00
kenta-s
6f032275c9 Fix the return of deprecate_methods in doc [ci skip] 2017-02-14 09:24:05 +09:00
Ryuta Kamizono
416d85b65e
Remove unused require
These files are not using `strip_heredoc`.

Closes #27976
2017-02-12 19:38:49 -07:00
Edouard CHIN
5b2b6282f5 Also not needed on this file, call to mattr_accessor got removed in 9e98f3f7e6 (diff-1ecd313ff0ab827af30014553cf8918dL76) 2017-02-12 20:00:54 -05:00
Andrew White
acdbe70a02 Merge pull request #27973 from kenta-s/add-missing-test-for-time-blank
Add Time#blank? to blank_test
2017-02-12 13:17:30 +00:00
Ryuta Kamizono
16ee3ccc9c Add Style/EmptyLinesAroundMethodBody in .rubocop.yml and remove extra empty lines 2017-02-12 20:44:15 +09:00
kenta-s
d632535df6 Add Time#blank? to blank_test 2017-02-12 11:02:50 +09:00
yuuji.yaginuma
4e63ce53fc deprecate halt_callback_chains_on_return_false instead of halt_and_display_warning_on_return_false
`halt_and_display_warning_on_return_false` is not a public API and
application is using `halt_callback_chains_on_return_false`.

https://github.com/rails/rails/blob/5-0-stable/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt#L29
https://github.com/rails/rails/blob/5-0-stable/activesupport/lib/active_support.rb#L86..L88

Therefore, deprecate messages should be issued for
`halt_callback_chains_on_return_false` instead of
`halt_and_display_warning_on_return_false`.
2017-02-08 17:18:55 +09:00
Rafael Mendonça França
6599e07674
Remove unused code now that the deprecated file was removed 2017-02-07 15:07:15 -03:00
Rafael Mendonça França
9e98f3f7e6
Deprecate halt_and_display_warning_on_return_false 2017-02-07 12:24:46 -03:00
Rafael Mendonça França
3a25cdca3e
Remove deprecated behavior that halts callbacks when the return is false 2017-02-07 12:19:37 -03:00
Robin Dupret
b7dbfe1b4d Avoid documenting private or external classes
There are a lot of monkey patches inside the code base but there's
no need to document external constants so let's remove them from
the documentation

Also, since there are monkey patches for some test cases classes,
there were sometimes both documented and sneaked under the wrong
section in the sidebar.

Finally, for future references, the `active_support/vendor`
folder has been originally ignored in https://git.io/vDqfA but
no longer exists.

[ci skip]
2017-02-07 16:16:38 +01:00
Rafael Mendonça França
64f4930afc
Document that string in if and unless option of callbacks are deprecated 2017-02-07 10:46:16 -03:00
Rafael Mendonça França
9b19861ec0
Improve the exception message to direct people to all the possible values 2017-02-07 10:41:44 -03:00
Rafael França
d7bbe075f9 Merge pull request #27608 from kamipo/remove_deprecated_passing_string_to_define_callback
Remove deprecated passing string to define callback
2017-02-07 10:33:28 -03:00
Arthur Nogueira Neves
e3afc83631 Merge pull request #27919 from bf4/correct_spelling
Correct spelling
2017-02-06 11:12:52 -05:00
kenta-s
9140720dcf Add tests for blank? 2017-02-06 23:27:50 +09:00
Benjamin Fleischer
c8b5d828e7 Correct spelling
```
go get -u github.com/client9/misspell/cmd/misspell
misspell  -w -error -source=text .
```
2017-02-05 19:00:18 -06:00
Ryuta Kamizono
09525527a5 Deprecate passing string to :if and :unless conditional options on set_callback and skip_callback 2017-02-04 20:48:29 +09:00
Ryuta Kamizono
f8d3fed167 Remove deprecated passing string to define callback
And raise `ArgumentError` when passing string to define callback.
2017-02-04 20:48:29 +09:00
Jared Beck
e014042bad Docs: Correction: Module::DelegationError
When the delegation target is nil and the allow_nil option is not
in use, a Module::DelegationError is raised.

    class C
      delegate :a, to: :b
        def b
          nil
        end
      end
    C.new.a
    # => Module::DelegationError: C#a delegated to b.a, but b is nil

[ci skip]
2017-02-03 17:27:04 -05:00
Arthur Nogueira Neves
c98e08df7a explicitly require listen in EventedFileUpdateCheckerTest (#27867)
Currently, executing the `test_initialize_raises_an_ArgumentError_if_no_block_given`
test alone will result in an error.

```
$ ./bin/test test/evented_file_update_checker_test.rb -n test_initialize_raises_an_ArgumentError_if_no_block_given
Run options: -n test_initialize_raises_an_ArgumentError_if_no_block_given --seed 6692

# Running:

E

Error:
EventedFileUpdateCheckerTest#test_initialize_raises_an_ArgumentError_if_no_block_given:
NameError: uninitialized constant EventedFileUpdateCheckerTest::Listen
    rails/activesupport/test/evented_file_update_checker_test.rb:21:in `teardown'
```

This is because if do not specify a file or directory for
`EventedFileUpdateChecker`, do not require `listen`, and using listen
method in teardown.
https://github.com/rails/rails/blob/master/activesupport/lib/active_support/evented_file_update_checker.rb#L53..L65

Therefore, added listen's require to avoid errors.
2017-02-01 13:45:56 -05:00
yuuji.yaginuma
725058fc09 explicitly require listen in EventedFileUpdateCheckerTest
Currently, executing the `test_initialize_raises_an_ArgumentError_if_no_block_given`
test alone will result in an error.

```
$ ./bin/test test/evented_file_update_checker_test.rb -n test_initialize_raises_an_ArgumentError_if_no_block_given
Run options: -n test_initialize_raises_an_ArgumentError_if_no_block_given --seed 6692

# Running:

E

Error:
EventedFileUpdateCheckerTest#test_initialize_raises_an_ArgumentError_if_no_block_given:
NameError: uninitialized constant EventedFileUpdateCheckerTest::Listen
    rails/activesupport/test/evented_file_update_checker_test.rb:21:in `teardown'
```

This is because if do not specify a file or directory for
`EventedFileUpdateChecker`, do not require `listen`, and using listen
method in teardown.
https://github.com/rails/rails/blob/master/activesupport/lib/active_support/evented_file_update_checker.rb#L53..L65

Therefore, added listen's require to avoid errors.
2017-02-01 08:43:39 +09:00
yuuji.yaginuma
11d994724e remove unused variable
This removes the following warnings.

```
activesupport/test/file_update_checker_shared_tests.rb:279: warning: assigned but unused variable - checker
```
2017-02-01 08:20:13 +09:00
Rafael Mendonça França
3f2b7d60a5
Remove deprecated callbacks from ActionDispatch middlewares 2017-01-31 15:52:12 -05:00
Eileen M. Uchitelle
3488f08ce1 Merge pull request #27857 from kenta-s/add-test-for-variable_size_secure_compare
Add test for `variable_size_secure_compare`
2017-01-31 08:33:48 -05:00
kenta-s
02bb4c55fd Add test for variable_size_secure_compare 2017-01-31 20:41:14 +09:00
kenta-s
20435f3547 Remove redundant right parentheses in number_helper [ci skip] 2017-01-31 20:13:03 +09:00
Rafael Mendonça França
44901ca903
Raise in the initialize not in the execute 2017-01-31 01:15:07 -05:00
Rafael França
6d8fdd136b Merge pull request #27824 from kenta-s/raise-an-error-if-no-block-given
Raise an error if FileUpdateChecker#execute is called with no block
2017-01-31 00:54:01 -05:00
Arthur Nogueira Neves
543f19626b Merge pull request #27797 from y-yagi/correctly_check_error_message
correctly check error message
2017-01-30 20:16:30 -05:00
Jeremy Daer
1fc995577f Merge pull request #27822 from mtsmfm/bump-unicode-version
Update Unicode Version to 9.0.0
2017-01-30 13:16:02 -07:00
Akira Matsuda
6b7bfece37 Ruby constant look-up no longer falls back to top-level since 2.5
This behavior used to warn until 2.4, and raises since 2.5.
The test here was intentinally named not to start with "test_" and so it used not to be executed because this never passes,
but now is should pass in trunk.

https://bugs.ruby-lang.org/issues/11547
44a2576f79

closes #19897
2017-01-30 16:52:54 +09:00
Akira Matsuda
17848036ad Missing require 'active_support/core_ext/hash/keys'
Without this, the test causes a "method redefined" warning because
* first it loads I18n and defines Hash#deep_symbolize_keys inside I18n's lib/i18n/core_ext/hash.rb
* then it loads AS/core_ext/hash/keys.rb afterwards
2017-01-29 08:41:06 +09:00
Fumiaki MATSUSHIMA
bdcfdef214 Update Unicode Version to 9.0.0
9.0.0 was released on June 21, 2016

http://blog.unicode.org/2016/06/announcing-unicode-standard-version-90.html

http://www.unicode.org/versions/Unicode9.0.0/

There are some changes about grapheme cluster in Unicode 9.0.0:

http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules

------------

I noticed that `unpack_graphemes` returns [Other] when the argument is Other ÷ Prepend
(it must be [Other, Prepend]).
But in [Unicode 8.0.0's Prepend has no characters](http://www.unicode.org/reports/tr29/tr29-27.html#Prepend)
so we don't have to backport following patch:

```diff
should_break =
+ if pos == eoc
+   true
```
2017-01-28 16:57:36 +09:00
kenta-s
3585155f1b Raise an error if FileUpdateChecker#execute is called with no block 2017-01-28 00:53:32 +09:00
kenta-s
221489a6e9 Fix broken sample code for EventedFileUpdateChecker [ci skip] 2017-01-28 00:23:14 +09:00
Akira Matsuda
442daca3c4 Uninterned Symbol can be duped since ruby 2.4.1
11e6bd5ac2

Leaving the 2.4.0 conditional for now, in order never to forget backporting r57407 to 2.4.1
2017-01-26 06:37:50 +09:00
kenta-s
19fc419925 Fix grammar 'an hyphen' -> 'a hyphen' [ci skip] 2017-01-25 23:50:20 +09:00
Akira Matsuda
ed7a3cde67 This seems to be working on JRuby 9K
% ruby -ve "p 'ほげ'.encode(Encoding::UTF_8_MAC)"
jruby 1.7.26 (1.9.3p551) 2016-08-26 69763b8 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 +jit [darwin-x86_64]
"\u307B\u3052"

% ruby -ve "p 'ほげ'.encode(Encoding::UTF_8_MAC)"
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]
"\u307B\u3051\u3099"

% ruby -ve "p 'ほげ'.encode(Encoding::UTF_8_MAC)"
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin14]
"\u307B\u3051\u3099"
2017-01-25 18:27:52 +09:00
Richard Schneeman
1107c85876 Merge pull request #27798 from yui-knk/give_message_to_test_duplicable
Give a message to `#test_duplicable` assertion
2017-01-25 02:53:49 -06:00
Jeremy Evans
7da8d76206
Change ActionView ERB Handler from Erubis to Erubi
Erubi offers the following advantages for Rails:

* Works with ruby's --enable-frozen-string-literal option
* Has 88% smaller memory footprint
* Does no freedom patching (Erubis adds a method to Kernel)
* Has simpler internals (1 file, <150 lines of code)
* Has an open development model (Erubis doesn't have a
  public source control repository or bug tracker)
* Is not dead (Erubis hasn't been updated since 2011)

Erubi is a simplified fork of Erubis that contains just the
parts that are generally needed (which includes the parts
that Rails uses).  The only intentional difference in
behavior is that it does not include support for <%=== tags
for debug output.  That could be added to the ActionView ERB
handler if it is desired.

The Erubis template handler remains in a deprecated state
so that code that accesses it directly does not break.  It
can be removed after Rails 5.1.
2017-01-25 01:41:27 -07:00
yui-knk
2aac4e4392 Give a message to #test_duplicable assertion
Giving a message helps us to know what happened
when we look at Travis CI.
2017-01-25 13:57:31 +09:00
yuuji.yaginuma
c42bd31977 correctly check error message
`assert_raise` does not check error message. However, in some tests,
it seems like expecting error message checking with `assert_raise`.
Instead of specifying an error message in `assert_raise`, modify to use
another assert to check the error message.
2017-01-25 09:58:15 +09:00
kenta-s
5db8d7308b Fix sample code for expand_cache_key usage [ci skip] 2017-01-24 20:28:20 +09:00
kenta-s
d1c546ff2a Add module name to BacktraceCleaner usage example [ci skip] 2017-01-22 19:19:13 +09:00
bogdanvlviv
ec3933e14c add missing comment out [ci skip] 2017-01-20 15:41:23 +02:00
yuuji.yaginuma
58156a803e add missing comment out [ci skip] 2017-01-20 16:39:03 +09:00
Jean Boussier
b9bda7fd89 Allocation free Integer#to_s 2017-01-19 15:24:41 +01:00
Akira Matsuda
044f8bdf62 Unused class for testing since 93559da4826546d07014f8cfa399b64b4a143127 2017-01-18 17:30:46 +09:00
Akira Matsuda
45d1b69140 rm rm_f that is not in use 2017-01-18 17:30:46 +09:00
Corey Ward
1d3ddac7b8 Adjust Module.parent_name to work when frozen; fixes #27637 2017-01-17 22:18:36 -06:00
Corey Ward
307065f959 Use appropriate assertion based on expectation
This resolves a stern Minitest “warning” about an upcoming
behavior change in MiniTest 6 that will result in the test failing.

https://github.com/seattlerb/minitest/issues/666
2017-01-17 14:25:41 -06:00
Akira Matsuda
146e928800 Don't pollute Object with rubinius_skip and jruby_skip
we call them only in the tests
2017-01-17 18:51:50 +09:00
Akira Matsuda
4ad1a52f5a All currently supported rubies already have LoadError#path 2017-01-17 18:16:21 +09:00
Akira Matsuda
8e2feedd31 else + if = elsif 2017-01-17 18:02:52 +09:00
Kevin McPhillips
5da6a9d684 CHANGELOG: Raise ArgumentError when calling transliterate on anything other than a string 2017-01-16 14:40:54 -05:00
Kevin McPhillips
f90a08c193 Raise ArgumentError if attempting to transliterate anything that is not a string 2017-01-16 14:40:41 -05:00
Akira Matsuda
88daf5dee4 Should do nothing here 2017-01-16 12:33:37 +09:00
Kasper Timm Hansen
7c3a99eeca Revert "Merge pull request #27686 from koic/friendly_bigdecimal_inspect"
The exact inspect output of a BigDecimal is out of scope for what we're trying
to communicate about `dup` and `duplicable?` here.

Adding two examples distracts is disctracting, so keep the docs from before
since our minimal version is Ruby 2.2.2.

[ Koichi ITO, Jon Moss, Kasper Timm Hansen ]

This reverts commit 2163874dedaf83e67599c2930c2686caa165fbad, reversing
changes made to 46fdbc5290335ed38fa9fe2b6b0ef8abe4eccb1b.
2017-01-15 19:49:34 +01:00
Koichi ITO
7b3d663b4d Several representation of BigDecimal has changed in Ruby 2.4.0+ [ci skip]
cf. https://github.com/ruby/bigdecimal/pull/42
2017-01-15 12:01:55 +09:00
Akira Matsuda
764bbb801e It would be safer not to totally undef core classes' respond_to_missing?
instead, rewrite them to no-op
2017-01-15 04:42:03 +09:00
Akira Matsuda
b99014bf44 AS::StringInquirer#respond_to_missing? should fallback to super
in case String or any other ancestor class' respond_to_missing? was defined.
2017-01-15 03:38:06 +09:00
Akira Matsuda
b89316fed3 This test wasn't actually an effective regression test 2017-01-15 03:31:24 +09:00
Akira Matsuda
a3afd05384 Unused &block parameter 2017-01-15 02:44:03 +09:00
Akira Matsuda
d5fbb04fab AS::ArrayInquirer#respond_to_missing? should fallback to super
in case Array or any other ancestor class' respond_to_missing? was defined.
2017-01-15 02:44:03 +09:00
Akira Matsuda
3d91649654 Constant look-up would no longer fall back to top-level constant since ruby 2.5
See: 44a2576f79
9df88e9cae
2017-01-13 16:38:30 +09:00
Akira Matsuda
9360b6be63 class Foo < Struct.new(:x) creates an extra unneeded anonymous class
because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
2017-01-13 15:13:47 +09:00
Andrew White
9ae511f550 Add duration constructors for use in Numeric extensions
The Numeric extensions like 1.day, 1.month, etc. shouldn't know
how the internals of ActiveSupport::Duration works.
2017-01-12 10:05:16 +00:00
Andrew White
2a5ae2b714 Add additional tests for #27610
Since 1.month no longer equals 30.days add some tests to ensure that
addition maintains the same day in the month or is the last day in
the month if the month has less days than the current day. Also add
a test for the behaviour of 12.months == 1.year.
2017-01-12 10:05:16 +00:00
Akira Matsuda
b70fc698e1 Reduce string objects by using \ instead of + or << for concatenating strings
(I personally prefer writing one string in one line no matter how long it is, though)
2017-01-12 17:45:37 +09:00
Andrew White
033f654027 Merge pull request #27610 from Envek/fix_and_speed_up_duration_parsing
Fix inconsistent parsing of Durations with both months and years
2017-01-12 07:20:28 +00:00
Akira Matsuda
c82fa18514 Use Encoding::UTF_8 constant for default_{internal,external} in the tests 2017-01-11 17:48:00 +09:00
Jonas Nicklas
3d78949c74 Make time travel work with subclasses of Time/Date/Datetime
Closes #27614

Previously when calling `now` on a subclass of e.g. `Time` it would return an instance of `Time` instead of returning an instance of the subclass. This way, we always return the correct class.
2017-01-10 11:43:26 +01:00
Andrey Novikov
cb9d0e4864
Fix inconsistent results when parsing large durations and constructing durations from code
ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true

Duration parsing made independent from any moment of time:
Fixed length in seconds is assigned to each duration part during parsing.

Changed duration of months and years in seconds to more accurate and logical:

 1. The value of 365.2425 days in Gregorian year is more accurate
    as it accounts for every 400th non-leap year.

 2. Month's length is bound to year's duration, which makes
    sensible comparisons like `12.months == 1.year` to be `true`
    and nonsensical ones like `30.days == 1.month` to be `false`.

Calculations on times and dates with durations shouldn't be affected as
duration's numeric value isn't used in calculations, only parts are used.

Methods on `Numeric` like `2.days` now use these predefined durations
to avoid duplicating of duration constants through the codebase and
eliminate creation of intermediate durations.
2017-01-09 23:04:48 +03:00
Sean Griffin
98c6e4e56c Merge pull request #27392 from y-yagi/use_same_class_on_compact
ensure `#compact` of HWIDA to return HWIDA
2017-01-06 06:23:24 -05:00
yuuji.yaginuma
d97ba34472 ensure #compact of HWIDA to return HWIDA
`Hash#compact` of Ruby native returns new hash.
Therefore, in order to return HWIDA as in the past version, need to
define own `#compact` to HWIDA.

Related: #26868
2017-01-06 17:49:18 +09:00
Akira Matsuda
5473e390d3 self. is not needed when calling its own instance method
Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
2017-01-05 19:58:52 +09:00
Rafael Mendonça França
209bfc0a5c
Fix style guide violations 2017-01-05 00:40:24 -05:00
Rafael Mendonça França
46bb76acad
Make sure we generate keys that can be used with the cipher
We use aes-256-cbc cipher by default and it only accepts keys with 32
bytes at max.

Closes #27576.

[ci skip]
2017-01-04 23:54:03 -05:00
Rafael França
d66789fa0e Merge pull request #26480 from tbrisker/fix-26461
Clarify that mattr_* creates public methods
2017-01-04 23:39:11 -05:00
Akira Matsuda
24bacb3e95 There's no such module 2017-01-05 01:37:36 +09:00
Jon Moss
bb8f57ec30 Remove unnecessary require statements
Should have been removed via 8e43fc5ace8039370f233570863b34821a3be46f.
2017-01-03 20:30:02 -05:00
Sean Griffin
a194ec88fe Merge pull request #27363 from amatsuda/refined_array_sum
Refining Array#sum monkey-patch using Refinements
2017-01-03 13:50:57 -05:00
Rafael França
3e8fa248b1 Merge pull request #27520 from prathamesh-sonpatki/merge-uncountable-tests-for-inflector
Make the tests for uncountability of ascii and non-ascii words uniform
2017-01-01 15:43:10 -05:00
Kasper Timm Hansen
c6c3b130e1 Fix Symbol#duplicable? for Ruby 2.4.0.
Ruby 2.4.0 has trouble duplicating certain symbols created from
strings via `to_sym`.

It didn't happen with `'symbol'.to_sym.dup` for some reason, but
works fine with the longer string sample.

Once a newer Ruby version with a fix is released we'll get have
a failing test case we can fix.

Ref: #27532
2017-01-01 13:41:24 +01:00
Jon Moss
37d956f45f Bump license years for 2017
Per https://www.timeanddate.com/counters/firstnewyear.html, it's already
2017 in a lot of places, so we should bump the Rails license years to
2017.

[ci skip]
2016-12-31 08:34:08 -05:00
Prathamesh Sonpatki
11b6f9e06a
Make the tests for uncountability of ascii and non-ascii words uniform 2016-12-31 09:51:43 +05:30
Matthew Draper
c3ff36815c Merge pull request #12509 from eitoball/pluralize_for_non_ascii_character_words
Fix ActiveSupport::Inflector.pluralize behavior for words that consist of non-ASCII characters

(test only; the original bug was fixed by 1bf50badd943e684a56a03392ef0ddafefca0ad7)
2016-12-31 11:47:24 +10:30
Matthew Draper
ee669ab36f Prefer Regexp#match? over Regexp#=== 2016-12-31 11:42:16 +10:30
Matthew Draper
afe057ebc2 Only add regexes for the new words 2016-12-31 11:42:16 +10:30
Rafael Mendonça França
010e246756
Fix Rubocop violations and fix documentation visibility
Some methods were added to public API in
5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of
the public API.
2016-12-28 21:53:51 -05:00
Akira Matsuda
a46b2f8911 assert_equal takes expectation first 2016-12-26 11:04:56 +09:00
Akira Matsuda
019cc5960d "Use assert_nil if expecting nil from ...:in `...'. This will fail in minitest 6." 2016-12-25 13:15:56 +09:00
Akira Matsuda
4ba9e61d99 Expectation first 2016-12-25 13:15:56 +09:00
Akira Matsuda
630cc857c9 "Use assert_nil if expecting nil from ...:in `...'. This will fail in MT6." 2016-12-25 09:59:16 +09:00
Akira Matsuda
e8ba0c0f21 "Use assert_nil if expecting nil. This will fail in minitest 6." 2016-12-25 02:29:52 +09:00
Akira Matsuda
a43e7706be Privatize unneededly protected methods in Active Support 2016-12-24 11:39:05 +09:00
Akira Matsuda
4db99eb87b No need to nodoc private methods 2016-12-24 11:36:51 +09:00
Akira Matsuda
3fe6a5d510 Privatize unneededly protected methods in Active Support tests 2016-12-24 00:22:29 +09:00
Akira Matsuda
21e5fd4a2a Describe what we are protecting 2016-12-23 23:48:54 +09:00
utilum
83d3b0dbf1 Fix Complex and Rational are duplicable?
See [this test](https://gist.github.com/utilum/78918f1b64f8b61ee732cb266db7c43a).
2016-12-21 17:50:14 +01:00
Akira Matsuda
3582f58a75 protected here doesn't protect anything
there aren't any instance method defined in this class
2016-12-19 17:50:29 +09:00
Matthew Draper
3b055d2ca4 Merge pull request #27366 from utilum/avoid_fixnum_warning
Fix Fixnum deprecated warning in Ruby 2.4+
2016-12-18 14:27:28 +10:30
Matthew Draper
a47efcfcae Merge pull request #27368 from matthewd/doubled-callbacks
Support double-yield inside an around callback
2016-12-16 23:14:46 +10:30
utilum
598f10c000 Fix Fixnum deprecated warning in Ruby 2.4+ 2016-12-16 10:57:19 +01:00
Matthew Draper
833ea903a9 Support double-yield inside an around callback
It's questionable whether this is a good thing -- it forces any later/
inner callback to handle multiple invocations, along with the actual
wrapped action. But it worked prior to 871ca21f6a1d65c0ec78cb5a9641411e2210460b,
so we shouldn't break it unintentionally.
2016-12-15 19:23:10 +10:30
Akira Matsuda
571f0f32c6 Refining Array#sum monkey-patch using Refinements
Because we don't want to see our ugly orig_sum method outside of this file
2016-12-15 05:48:23 +09:00
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