aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge pull request #24890 from vipulnsward/travel-to-raiseKasper Timm Hansen2016-07-051-0/+43
|\ \ | | | | | | `travel/travel_to` travel time helpers, now raise on nested calls
| * | `travel/travel_to` travel time helpers, now raise on nested calls,Vipul A M2016-07-021-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as this can lead to confusing time stubbing. Instead of: travel_to 2.days.from_now do # 2 days from today travel_to 3.days.from_now do # 5 days from today end end preferred way to achieve above is: travel_to 2.days.from_now # 2 days from today travel_back travel_to 5.days.from_now # 5 days from today Closes #24690 Fixes #24689
* | | Merge pull request #25678 from voxik/DRY-downloaderRafael França2016-07-044-65/+36
|\ \ \ | | | | | | | | Dry downloader
| * | | Skip the test if test data download fails.Vít Ondruch2016-07-044-12/+16
| | | |
| * | | DRY Downloader.Vít Ondruch2016-07-044-53/+20
| | |/ | |/|
* / | Pathname might not be always initialized.Vít Ondruch2016-07-041-0/+2
|/ / | | | | | | Require 'pathname' explicitly
* / Do not depend on Rails git repository layout in ActiveSupport tests.Vít Ondruch2016-07-011-2/+2
|/
* Partially revert #25192Matthew Draper2016-07-011-1/+16
| | | | | | KeyGenerator is used in other contexts, and we cannot change its output... even if it does accidentally default to generating excess key material for our primary internal usage.
* We default to using aes-256-cbc as our verification/signing cipher. It can ↵Vipul A M2016-06-272-3/+3
| | | | | | | | | | accept key lengths of 128, 192 or 256-bit, whereas currently we were providing twice the acceptable value. ruby < 2.4 allowed accepting these values, as extra key bits were ignored. Since https://github.com/ruby/ruby/commit/ce635262f53b760284d56bb1027baebaaec175d1 this now has a strict checking on key length. Default to key length 32 bytes, to match the compatible length for aes-256-cbc Fixes #25185
* Define `Pathname#as_json`Ryunosuke Sato2016-06-251-0/+2
| | | | | | | | | | | | | | | | | When the Pathname object is converted as JSON, it should be a string that means itself. Expected: ``` >> Pathname.new('/path/to/somewhere.txt').as_json "/path/to/somewhere.txt" ``` Actual: ``` >> Pathname.new('/path/to/somewhere.txt').as_json {"path"=>"/path/to/somewhere.txt"} ```
* Define `URI::Generic#as_json`Ryunosuke Sato2016-06-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the URI object is converted as JSON, it is expected that it is a string that means its URI. Expected: ``` >> URI.parse('http://example.com').as_json "http://example.com" ``` Actual: ``` >> URI.parse('http://example.com').as_json {"scheme"=>"http", "user"=>nil, "password"=>nil, "host"=>"example.com", "port"=>80, "path"=>"", "query"=>nil, "opaque"=>nil, "fragment"=>nil, "parser"=> {"regexp"=> {"SCHEME"=>"(?-mix:\\A[A-Za-z][A-Za-z0-9+\\-.]*\\z)", "USERINFO"=>"(?-mix:\\A(?:%\\h\\h|[!$&-.0-;=A-Z_a-z~])*\\z)", "HOST"=> "(?-mix:\\A(?:(?<IP-literal>\\[(?:(?<IPv6address>(?:\\h{1,4}:){6}(?<ls32>\\h{1,4}:\\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5]|\\d)\\.\\g<dec-octet>\\.\\g<dec-octet>\\.\\g<dec-octet>))|::(?:\\h{1,4}:){5}\\g<ls32>|\\h{,4}::(?:\\h{1,4}:){4}\\g<ls32>|(?:(?:\\h{1,4}:)?\\h{1,4})?::(?:\\h{1,4}:){3}\\g<ls32>|(?:(?:\\h{1,4}:){,2}\\h{1,4})?::(?:\\h{1,4}:){2}\\g<ls32>|(?:(?:\\h{1,4}:){,3}\\h{1,4})?::\\h{1,4}:\\g<ls32>|(?:(?:\\h{1,4}:){,4}\\h{1,4})?::\\g<ls32>|(?:(?:\\h{1,4}:){,5}\\h{1,4})?::\\h{1,4}|(?:(?:\\h{1,4}:){,6}\\h{1,4})?::)|(?<IPvFuture>v\\h+\\.[!$&-.0-;=A-Z_a-z~]+))\\])|\\g<IPv4address>|(?<reg-name>(?:%\\h\\h|[!$&-.0-9;=A-Z_a-z~])*))\\z)", "ABS_PATH"=> "(?-mix:\\A\\/(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])*(?:\\/(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])*)*\\z)", "REL_PATH"=> "(?-mix:\\A(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])+(?:\\/(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])*)*\\z)", "QUERY"=>"(?-mix:\\A(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~\\/?])*\\z)", "FRAGMENT"=>"(?-mix:\\A(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~\\/?])*\\z)", "OPAQUE"=>"(?-mix:\\A(?:[^\\/].*)?\\z)", "PORT"=> "(?-mix:\\A[\\x09\\x0a\\x0c\\x0d ]*\\d*[\\x09\\x0a\\x0c\\x0d ]*\\z)"}}} ```
* Merge pull request #23011 from arnvald/bugfix/correctly_parse_dateGodfrey Chan2016-06-251-5/+11
|\ | | | | | | Use correct timezone when parsing date in json
| * Use correct timezone when parsing date in jsonGrzegorz Witek2016-01-221-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes https://github.com/rails/rails/issues/22171 Time specified in ISO 8601 format without `Z` should be considered as local time, yet until now it was treated as UTC. This commit fixes problem by parsing time using timezone specified in application config. The downside of this solution is performance hit (`Time.zone.parse` is ~ 1.6x slower than `Time.parse`), so maybe there's a better solution.
* | Merge pull request #25302 from ↵Sean Griffin2016-06-171-1/+43
|\ \ | | | | | | | | | | | | schneems/schneems/evented-file-boot-at-check-time-master EventedFileUpdateChecker boots once per process
| * | Test how evented file checker handles forksschneems2016-06-081-1/+42
| | | | | | | | | | | | | | | | | | | | | Pretty proud of this. We are testing distributed processes synchronized via pipes which makes it deterministic. Pretty cool. We boot a listener in the parent process we then fork. Before we touch the file we verify the fork is booted using pipes. Then the parent process will touch the file while the fork waits on a pipe. Once the parent process signals that the file has been touched we continue inside of the fork.
| * | EventedFileUpdateChecker boots once per processschneems2016-06-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need one file checker booted per process as talked about in #24990. Before we do a check to see if any updates have been registered by the listener we first check to make sure that the current process has booted a listener. We are intentionally not starting a listener when the checker is created. This way we can avoid #25259 in which puma warns of multiple threads created before fork. As written the listener for each process will be invoked by the `ActionDispatch::Executor` middleware when the `updated?` method is called. This is the first middleware on the stack and will be invoked before application code is read into memory. The downside of this approach is that the API is a little less obvious. I.e. that you have to call `updated?` to get the listener to start is not intuitive. We could make `boot!` not private if we want to make the API a little nicer. Alternatively we could boot when the checker is initialized however this reintroduces the puma threads warning, and also means that in cases of `rails server` or when using `preload!` that we have extra threads notifying of changes on a process that we don't care about. [close #24990] [close #25259]
* | | Fix missing requires for object/blankRafael Mendonça França2016-06-131-1/+1
| | |
* | | Make sure the yielded variable is the loggerRafael Mendonça França2016-06-101-2/+4
| | |
* | | Be explicit about what Logger class is expectedKevin McPhillips2016-06-091-3/+3
| | |
* | | Broadcast #silence on logger. Rewrite tests.Kevin McPhillips2016-06-091-31/+103
| | |
* | | existant => existentAbhishek Jain2016-06-091-1/+1
| | |
* | | Improve Hash#compact! documentation and testsIgor Pstyga2016-06-031-0/+8
|/ / | | | | | | | | | | | | Make it clear what should be returned when no changes were made to the hash. { c: true }.compact! # => nil
* | Don't blank pad day of the month when formatting datesSean Griffin2016-06-021-0/+11
| | | | | | | | | | | | | | | | | | | | | | We are currently using `%e` which adds a space before the result if the digit is a single number. This leads to strings like `February 2, 2016` which is undesireable. I've opted to replace with 0 padding instead of removing the padding entirely, to preserve compatibility for those relying on the fact that the width is constant, and to be consistent with time formatting. Fixes #25251.
* | Add test for `delegate_missing_to` where method doesn't existJon Moss2016-05-261-0/+8
| |
* | Add tests for keyword arg to: for Module#delegateYosuke Kabuto2016-05-251-0/+15
| |
* | Don't delegate to private methods of the targerRafael Mendonça França2016-05-241-0/+14
| | | | | | | | And make sure that it doesn't even try to call the method in the target.
* | Merge pull request #23930 from gsamokovarov/module-delegate-missing-toRafael Mendonça França2016-05-241-0/+22
|\ \ | | | | | | | | | Introduce Module#delegate_missing_to
| * | Introduce Module#delegate_missing_toGenadi Samokovarov2016-02-271-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building decorators, a common pattern may emerge: class Partition def initialize(first_event) @events = [ first_event ] end def people if @events.first.detail.people.any? @events.collect { |e| Array(e.detail.people) }.flatten.uniq else @events.collect(&:creator).uniq end end private def respond_to_missing?(name, include_private = false) @events.respond_to?(name, include_private) end def method_missing(method, *args, &block) @events.send(method, *args, &block) end end With `Module#delegate_missing_to`, the above is condensed to: class Partition delegate_missing_to :@events def initialize(first_event) @events = [ first_event ] end def people if @events.first.detail.people.any? @events.collect { |e| Array(e.detail.people) }.flatten.uniq else @events.collect(&:creator).uniq end end end David suggested it in #23824.
* | | Revert "Add default exceptions affected by suppress (#25099)"Rafael Mendonça França2016-05-231-9/+0
| | | | | | | | | | | | | | | | | | | | | This reverts commit 28492204ee59a5aca2f3bc7b161d45724552686d. Reason: `suppress` without an argument doesn't actually tell what is supressing. Also, it can be confused with ActiveRecord::Base#suppress.
* | | Add default exceptions affected by suppress (#25099)Alexey Zapparov2016-05-231-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add default exceptions affected by suppress suppress { do_something_that_might_fail } # instead of begin do_something_that_might_fail rescue end # or do_something_that_might_fail rescue nil * Do not add default exceptions list constant [Rafael Mendonça França + Alexey Zapparov]
* | | Fix Hash#from_xml with frozen strings (#24718)Marek Kirejczyk2016-05-211-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Hash#from_xml works with frozen strings Fixes #24647 * Fix rexml engine test [Marek Kirejczyk + Rafael Mendonça França]
* | | Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-187-42/+36
| | | | | | | | | | | | | | | | | | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* | | Merge pull request #19428 from bdmac/fix_safe_buffer_titleizeRafael Mendonça França2016-05-181-1/+2
|\ \ \ | | | | | | | | | | | | Fixes Inflector#titleize to work with SafeBuffer
| * | | Fixes Inflector#titleize to work with SafeBufferBrian McManus2015-03-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way Inflector#titleize was implemented did not work properly when called on a SafeBuffer object. Using the global `$&` variable in the gsub resulted in calling capitalize on a nil object for reasons I still do not fully understand. Removing the UNSAFE_STRING_METHODS override for the gsub method in SafeBuffer "fixed" the bug but is obviously unacceptable. An example of this is very easy to see in rails console: ActiveSupport::SafeBuffer.new("my test").titleize > NoMethodError: undefined method `capitalize' for nil:NilClass Using the non global version of gsub with a |match| arg passed to the block fixes the problem. Again I do not quite understand why. I noticed that other parts of Inflector were already using the standard block arg version of gsub so I don't think it should be a problem to convert this method to using it as well.
* | | | Merge pull request #24930 from henrik/date-all-daySean Griffin2016-05-161-0/+17
|\ \ \ \ | | | | | | | | | | Introduce Date#all_day
| * | | | Introduce Date#all_dayHenrik Nyh2016-05-111-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Useful for queries like: Item.where(created_at: Date.current.all_day) There was already a Time#all_day with the same behaviour, but for queries like the above, Date is more convenient.
* | | | | Action Mailer: Declarative exception handling with `rescue_from`.Jeremy Daer2016-05-151-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follows the same pattern as controllers and jobs. Exceptions raised in delivery jobs (enqueued by `#deliver_later`) are also delegated to the mailer's rescue_from handlers, so you can handle the DeserializationError raised by delivery jobs: ```ruby class MyMailer < ApplicationMailer rescue_from ActiveJob::DeserializationError do … end ``` ActiveSupport::Rescuable polish: * Add the `rescue_with_handler` class method so exceptions may be handled at the class level without requiring an instance. * Rationalize `exception.cause` handling. If no handler matches the exception, fall back to the handler that matches its cause. * Handle exceptions raised elsewhere. Pass `object: …` to execute the `rescue_from` handler (e.g. a method call or a block to instance_exec) against a different object. Defaults to `self`.
* | | | | Add some assertions for BigDecimal#to_sYosuke Kabuto2016-05-151-0/+2
| | | | |
* | | | | Bump the deprecation horizonRafael Mendonça França2016-05-101-1/+1
|/ / / /
* | | | Run Active Support tests when preserving timezonesAndrew White2016-05-051-0/+3
| | | | | | | | | | | | | | | | | | | | Add to the matrix of Travis tests an entry that runs the Active Support tests when `ActiveSupport.to_time_preserves_timezone = true`.
* | | | Fix tests when preserving timezonesAndrew White2016-05-052-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | These two tests are explicitly testing that to_time is returning times with the sytem timezone's UTC offset, therefore they will fail when running them with `ActiveSupport.to_time_preserves_timezone = true`.
* | | | Fix to_yaml test when run individuallyAndrew White2016-05-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The to_yaml method is undefined when running the test as: $ ruby -I lib:test test/core_ext/string_ext_test.rb Doesn't fail when running rake test:isolated presumably because something else has required 'yaml' already.
* | | | Fix some typos in comments.Joe Rafaniello2016-05-041-1/+1
| | | | | | | | | | | | | | | | [ci skip]
* | | | Fix initial value effects for sum along to ruby 2.4Kenta Murata2016-04-301-0/+78
| | | | | | | | | | | | | | | | Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* | | | Change 1.week to create 1 week durations instead of 7 days durations.Andrey Novikov2016-04-281-2/+12
| | | | | | | | | | | | | | | | This is just to remove astonishment from getting `3600 seconds` from typing `1.hour`.
* | | | Revert "Change 1.week to create 1 week durations instead of 7 days durations."Jeremy Daer2016-04-271-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | Regression: adding minutes/hours to a time would change its time zone This reverts commit 1bf9fe75a6473cb7501cae544cab772713e68cef.
* | | | Merge pull request #24723 from lvl0nax/array_split_fixJeremy Daer2016-04-261-0/+8
|\ \ \ \ | | | | | | | | | | | | | | | Little perfomance fix for Array#split.
| * | | | Little perfomance fix for Array#split.lvl0nax2016-04-261-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calculating ------------------------------------- before 40.770k i/100ms after 58.464k i/100ms ------------------------------------------------- before 629.568k (± 5.0%) i/s - 3.180M after 1.159M (± 4.5%) i/s - 5.788M
* | | | | Do not cache ActiveSupport::TimeZone#utc_offsetAlexey Shein2016-04-251-0/+11
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can be an issue when TZInfo::TimeZone#current_period is refreshed due to timezone period transition, but it's not reflected in ActiveSupport::TimeZone object. For example, on Sun, 26 Oct 2014 22:00 UTC, Moscow changed its TZ from MSK +04:00 to MSK +03:00 (-1 hour). If ActiveSupport::TimeZone['Moscow'] happens to be initialized just before the timezone transition, it will cache its stale utc_offset even after the timezone transition. This commit removes cache and fixes this issue. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* | | | Make getlocal and getutc always return instances of TimeAndrew White2016-04-233-1/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously these methods could return either a DateTime or a Time depending on how the ActiveSupport::TimeWithZone instance had been constructed. Changing to always return an instance of Time eliminates a possible stack level too deep error in to_time where it was wrapping a DateTime instance. As a consequence of this the internal time value is now always an instance of Time in the UTC timezone, whether that's as the UTC time directly or a representation of the local time in the timezone. There should be no consequences of this internal change and if there are it's a bug due to leaky abstractions.