Commit Graph

6704 Commits

Author SHA1 Message Date
Rafael França
3d716b9e66 Merge pull request #25736 from voxik/file-store-test-require-pathname
Pathname might not be always initialized.
2016-07-07 11:26:21 -03:00
Vít Ondruch
34e0eafb4b Pathname might not be always initialized.
Require 'pathname' explicitly
2016-07-07 12:27:01 +02:00
Kasper Timm Hansen
2dfb06a9b5 Merge pull request #24890 from vipulnsward/travel-to-raise
`travel/travel_to` travel time helpers, now raise on nested calls
2016-07-05 20:26:24 +02:00
Rafael França
1c7cbe8da6 Merge pull request #25678 from voxik/DRY-downloader
Dry downloader
2016-07-04 18:26:00 -03:00
Vít Ondruch
c245ca30f2 Skip the test if test data download fails. 2016-07-04 14:12:49 +02:00
Vít Ondruch
a69a5a4147 Pathname might not be always initialized.
Require 'pathname' explicitly
2016-07-04 14:08:27 +02:00
Vít Ondruch
7d7c2d13ba DRY Downloader. 2016-07-04 13:11:44 +02:00
Vipul A M
919e705362
travel/travel_to travel time helpers, now raise on nested calls,
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
2016-07-02 15:09:34 -07:00
Rafael França
14996a1490 Merge pull request #25625 from voxik/fix-rails-test-git-layout
Do not depend on Rails git repository layout in ActiveSupport tests.
2016-07-01 21:18:12 -03:00
Matthew Draper
ad95b6fc72 Merge pull request #25344 from matthewd/debug-locks
ActionDispatch::DebugLocks
2016-07-02 06:47:57 +09:30
Matthew Draper
f0c7e2b8c3 Merge pull request #24146 from matthewd/latch-as-proxy
Don't inherit from Concurrent::CountDownLatch
2016-07-02 06:47:38 +09:30
Vipul A M
d7a7a2561a Merge pull request #25600 from pan/constantize-docfix
fix ActiveSupport::Infector.constantize usage API doc [ci skip]
2016-07-01 13:20:02 -07:00
Vít Ondruch
6119a9524b Do not depend on Rails git repository layout in ActiveSupport tests. 2016-07-01 15:29:54 +02:00
Matthew Draper
ea7fee03f7 Partially revert #25192
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.
2016-07-01 01:01:45 +09:30
Pan GaoYong
37232f6d43 fix ActiveSupport::Infector.constantize usage API doc [ci skip] 2016-06-30 22:37:49 +08:00
Vipul A M
8ee269cf51
We default to using aes-256-cbc as our verification/signing cipher. It can 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 ce635262f5 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
2016-06-27 17:43:55 -07:00
Godfrey Chan
ffded19faf Clearify CHANGELOG for #23011 [ci skip] 2016-06-27 08:37:06 -07:00
Ryunosuke Sato
abbf00e583 Define Pathname#as_json
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"}
```
2016-06-25 21:50:16 +09:00
Ryunosuke Sato
236e616688 Define URI::Generic#as_json
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)"}}}
```
2016-06-25 16:43:58 +09:00
Godfrey Chan
3a9428df91 Merge pull request #23011 from arnvald/bugfix/correctly_parse_date
Use correct timezone when parsing date in json
2016-06-25 12:02:07 +08:00
Alex Kitchens
64cabcd77a [ci skip] Add link to method referenced in ActiveSupport::PerThreadRegistry 2016-06-24 15:14:50 -05:00
Kevin McPhillips
b081633efa Update changelog for #25341 2016-06-22 20:42:54 -04:00
aarongray
b30805bd46 Create times in rails timezone not system timezone [ci skip]
Time.new is a Ruby method that uses system timezone. Traveling in time
using it is a recipe for confusion. Instead, Time.zone.local should
be used since it uses the Rails timezone.
2016-06-21 17:22:56 -06:00
Sean Griffin
30dd8b2cb0 Merge pull request #25302 from schneems/schneems/evented-file-boot-at-check-time-master
EventedFileUpdateChecker boots once per process
2016-06-17 10:19:56 -04:00
Alex Kitchens
9bcaa2c154 Change AS::Callback to ActiveSupport::Callbacks in doc [ci skip] 2016-06-14 14:08:33 -05:00
Rafael Mendonça França
6e5b0a184d
Fix missing requires for object/blank 2016-06-13 13:01:32 -04:00
Rafael Mendonça França
4a7cd700b4
Remove deprecated arguments in assert_nothing_raised 2016-06-13 12:05:33 -04:00
schneems
844af9fa7c Lock the whole boot step, get rid of unneeded hash 2016-06-13 09:29:57 -05:00
Genadi Samokovarov
3d8b238dd8 Remove an unused require in ActiveSupport::TestCase
We used to have `assert_blank` and `assert_presence`. [ci skip]
2016-06-13 10:50:48 +03:00
Jon Moss
02a6452e2c
Remove _run_class_setup
Should have been removed by 3073c531983de243219fb55be93fbcebfdd9c44e.
2016-06-10 21:14:33 -04:00
Rafael Mendonça França
1de3db9046
Make sure the yielded variable is the logger 2016-06-10 13:30:50 -04:00
Rafael França
1f452f9a3d Merge pull request #25341 from kmcphillips/master
Broadcast #silence on ActiveSupport::Logger
2016-06-10 13:06:44 -04:00
Rafael França
7fd477c0f5 Merge pull request #25352 from Shopify/optimized-delegate
Replace Kernel#caller by the faster Kernel#caller_locations
2016-06-10 13:04:50 -04:00
Jean Boussier
e8148a5cf4 Replace Kernel#caller by the faster Kernel#caller_locations 2016-06-10 11:34:18 -04:00
Edouard CHIN
3da701dd3c [ci skip] define_model_callbacks only exist in active model:
- Also added a note when calling multiple time `define_callbacks`
2016-06-10 11:31:11 -04:00
Matthew Draper
04b4a0666b Provide a middleware to debug misbehaving locks
Only intended to be enabled when in use; by necessity, it sits above any
reasonable access control.
2016-06-10 19:33:38 +09:30
Kevin McPhillips
83f9cdb02a Be explicit about what Logger class is expected 2016-06-09 22:11:07 -04:00
Kevin McPhillips
99bd118eec Broadcast #silence on logger. Rewrite tests. 2016-06-09 22:10:47 -04:00
Abhishek Jain
24d496cef5 existant => existent 2016-06-09 09:29:02 +05:30
schneems
7d733b9f0f Test how evented file checker handles forks
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.
2016-06-08 15:52:02 -05:00
Kasper Timm Hansen
26cb88577a Merge pull request #25265 from opti/improve/hash_compact
Improve Hash#compact! documentation and tests
2016-06-07 19:46:30 +02:00
schneems
a8f29f6455 Listen earlier in EventedFileUpdateChecker
Some files like routes.rb may be very large and vary between the initialization of the app and the first request. In these scenarios if we are using a forked process we cannot rely on the files to be unchanged between when the code is booted and the listener is started. 

For that reason we start a listener on the main process immediately, when we detect that a process does not have a listener started we force the updated state to be true, so we are guaranteed to catch any changes made between the code initialization and the fork.
2016-06-06 15:24:56 -05:00
schneems
bd38e92b41 [ci skip] document EventedFileUpdateChecker 2016-06-06 11:34:39 -05:00
schneems
7bd4199448 EventedFileUpdateChecker boots once per process
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]
2016-06-06 11:34:32 -05:00
Dimitris Zorbas
f484bb068b Change doc for race_condition_ttl option of ActiveSupport::Cache::Store#fetch [ci skip]
The related option of this method, `expires_in` is documented
as expecting an `ActiveSupport::Duration` value. To minimize any sort of
ambiguity between duration options, this change also documents
`race_condition_ttl` accepting `ActiveSupport::Duration`.
2016-06-06 09:25:18 +03:00
Eileen M. Uchitelle
755f6bf3d3 Merge pull request #25263 from abhishekjain16/doc_accessor_thread
[skip ci] Fix grammar
2016-06-03 10:21:49 -04:00
Abhishek Jain
f7b850ec9f [skip ci] Fix grammar 2016-06-03 19:48:26 +05:30
Vijay Dev
4e85538ddd Merge branch 'master' of github.com:rails/docrails
Conflicts:
	guides/source/action_cable_overview.md
2016-06-03 14:00:47 +00:00
Igor Pstyga
0dd23446a3
Improve Hash#compact! documentation and tests
Make it clear what should be returned when no changes were made to the
hash.

  { c: true }.compact! # => nil
2016-06-03 04:54:34 -07:00
Sean Griffin
2c5a8ba6f6 Don't blank pad day of the month when formatting dates
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.
2016-06-02 11:47:22 -04:00