| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|/ / |
|
|\ \
| | |
| | | |
Fix url_helper examples in testing guide [ci skip]
|
|/ / |
|
| |
| |
| |
| | |
References #32703.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This improves the performance for the most ordinalized numbers (1st,
2nd, 3rd, etc).
```
require "benchmark/ips"
def o1(number)
abs_number = number.to_i.abs
if (11..13).include?(abs_number % 100)
"th"
else
case abs_number % 10
when 1; "st"
when 2; "nd"
when 3; "rd"
else "th"
end
end
end
def o3(number)
case number
when 1; "st"
when 2; "nd"
when 3; "rd"
when 4, 5, 6, 7, 8, 9, 10, 11, 12, 13; "th"
else
num_modulo = number.to_i.abs % 100
if 11 <= num_modulo && num_modulo <= 13
"th"
else
case num_modulo % 10
when 1; "st"
when 2; "nd"
when 3; "rd"
else "th"
end
end
end
end
def o4(number)
case number
when 1; "st"
when 2; "nd"
when 3; "rd"
when 4, 5, 6, 7, 8, 9, 10, 11, 12, 13; "th"
else
num_modulo = number.to_i.abs % 100
num_modulo %= 10 if num_modulo > 13
case num_modulo
when 1; "st"
when 2; "nd"
when 3; "rd"
else "th"
end
end
end
puts RUBY_DESCRIPTION
Benchmark.ips do |x|
x.report("orig") { o1(1); o1(2); o1(3); o1(4); o1(11); o1(111); o1(1523) }
x.report("ord3") { o3(1); o3(2); o3(3); o3(4); o3(11); o3(111); o3(1523) }
x.report("ord4") { o4(1); o4(2); o4(3); o4(4); o4(11); o4(111); o4(1523) }
x.compare!
end
```
```
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin15]
Warming up --------------------------------------
orig 25.305k i/100ms
ord3 121.146k i/100ms
ord4 124.944k i/100ms
Calculating -------------------------------------
orig 275.496k (± 2.4%) i/s - 1.392M in 5.054720s
ord3 1.649M (± 5.0%) i/s - 8.238M in 5.009801s
ord4 1.700M (± 7.0%) i/s - 8.496M in 5.031646s
Comparison:
ord4: 1700059.6 i/s
ord3: 1649154.9 i/s - same-ish: difference falls within error
orig: 275496.3 i/s - 6.17x slower
```
Closes #25020.
[lvl0nax, Jeremy Daer, Ryuta Kamizono]
|
| |
| |
| |
| | |
Match other services, which all use a 5 MB chunk size.
|
|\ \
| | |
| | | |
Make Railties CI log for Ruby 2.6 accessible again
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Pending the next release of Thor which [fixes](https://github.com/erikhuda/thor/commit/006832ea32480618791f89bb7d9e67b22fc814b9) calls to `ERB.new`, Railties CI log for Ruby 2.6 is flooded with so many warnings it is too long for Travis to handle:
```
/home/travis/.rvm/gems/ruby-head/gems/thor-0.20.0/lib/thor/actions/file_manipulation.rb:120: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
/home/travis/.rvm/gems/ruby-head/gems/thor-0.20.0/lib/thor/actions/file_manipulation.rb:120: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.
/home/travis/.rvm/gems/ruby-head/gems/thor-0.20.0/lib/thor/actions/file_manipulation.rb:120: warning: Passing eoutvar with the 4th argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead.
The log length has exceeded the limit of 4 MB (this usually means that the test suite is raising the same exception over and over).
The job has been terminated
```
https://travis-ci.org/rails/rails/jobs/372623604#L10000
https://api.travis-ci.org/v3/job/372623604/log.txt
This patch forces installation of fixed Thor, and enables us to look at the the log.
|
|\ \ \
| |/ /
|/| | |
Swap assertion order
|
|/ /
| |
| |
| | |
`assert_directory("test/system")` may pass even if `assert_file("test/system/.keep")` fails.
|
| | |
|
| |
| |
| |
| |
| | |
The merging order was accidentally changed at #32447. The original
intention is force `drop_table ... if_exists: true`. #28070.
|
| |
| |
| |
| |
| | |
* Singular associations don't define `#association.nil?`
* Wrap with <tt> for each method, not the whole sentence
|
|\ \
| | |
| | | |
Don't allocate unnecessary array in translation helper
|
| | | |
|
|\ \ \
| |/ /
|/| | |
[ci skip] update ActiveStorage documentation
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
- added documentation on how to download files, with example of
ActiveStorage::Downloading
- documentation about linking files outside of controller/view
- added section about DirectUpload JavaScript integration into
libraries/frameworks, as well as usage in combination with Drag and Drop
|
|\ \ \
| | | |
| | | | |
[ci skip] Fix a typo in testing.md
|
|/ / / |
|
|\ \ \
| | | |
| | | | |
Allow usage of strings as locals for partial renderer
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Use MethodCallAssertions instead of mocha expects
|
| | | | | |
|
| | | | | |
|
| | | | | |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
`SetupAndTeardown` has few caveats that breaks libraries
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
- In #32472 I introduced a fix in order for all `after_teardown` method provided by libraries and Rails to run, even if the application's `teardown` method raised an error (That's the default minitest behavior). However this change wasn't enough and doesn't take in consideration the ancestors chain.
If a library's module containing an `after_teardown` method get included after the `SetupAndTeardown` module (one example is the [ActiveRecord::TestFixtures module](https://github.com/rails/rails/blob/7d2400ab61c8e3ed95e14d03ba3844e8ba2e36e4/activerecord/lib/active_record/fixtures.rb#L855-L856), then the ancestors of the test class would look something like
```ruby
class MyTest < ActiveSupport::TestCase
end
puts MyTest.ancestors # [MyTest, ActiveSupport::TestCase, ActiveRecord::TestFixtures, ActiveSupport::Testing::SetupAndTeardown]
```
Any class/module in the ancestors chain that are **before** the `ActiveSupport::Testing::SetupAndTeardown` will behave incorrectly:
- Their `before_setup` method will get called **after** all regular setup method
- Their `after_teardown` method won't even get called in case an exception is raised inside a regular's test `teardown`
A simple reproduction script of the problem here https://gist.github.com/Edouard-chin/70705542a59a8593f619b02e1c0a188c
- One solution to this problem is to have the `AS::SetupAndTeardown` module be the very first in the ancestors chain. By doing that we ensure that no `before_setup` / `after_teardown` get executed prior to running the teardown callbacks
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
has_(one/many)_attached presence validation
|
| | | | | | | |
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
(#32740)
* Adding precision about which letter case to use for controller names in routing
Many people (including myself) encounter an error when having multiple words controller names and trying to put camelCase in their routes
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
Currently `ids_reader` doesn't respect dirty target when the target is
not loaded yet unlike `collection.size`. I believe the inconsistency is
a bug, fixes the `ids_reader` to behave consistently regardless of
whether target is loaded or not.
|
|\ \ \ \ \ \ \
| | | | | | | |
| | | | | | | | |
Loaded associations should not run a new query when size is called
|
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | |
Already loaded associations were running an extra query when `size` was called on the association.
This fix ensures that an extra query is no longer run.
Update tests to use proper methods
|
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | |
* Update 'rails_welcome.png' to reflect a more diverse population
* Cleanup 'rails_welcome.png'
|
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | |
This is to ensure that the behavior has not changed before and after
#31575.
|
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | |
Caused at 9276ea89d2b0be9fdd1ad6590857f8d45a38c267.
|
| |_|/ / / / /
|/| | | | | |
| | | | | | |
| | | | | | | |
This method would be called so many times and would create so many temporary garbage Strings
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
Or it would raise if the argument was frozen.
And even with this change, it would still reduce String allocations together with 9276ea89d2b0be9fdd1ad6590857f8d45a38c267
because `escape` should be `true` in most cases
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
This method is called against each tag option for each tag,
and creates an extra garbage String per each call
|
|/ / / / / /
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
tags_text method creates 3 Ruby objects per each logger call when no custom tags are given
(which is the default setting, and so presumably the majority use case).
This patch reduces two temporary object creations in this case.
require 'allocation_tracer'
ObjectSpace::AllocationTracer.setup(%i{type})
tags = ['a']
pp before: ObjectSpace::AllocationTracer.trace {
tags.collect { |tag| "[#{tag}] " }.join
}
pp after: ObjectSpace::AllocationTracer.trace {
"[#{tags[0]}] "
}
{:before=>{[:T_ARRAY]=>[1, 0, 0, 0, 0, 0], [:T_STRING]=>[2, 0, 0, 0, 0, 0]}}
{:after=>{[:T_STRING]=>[1, 0, 0, 0, 0, 0]}}
|
|\ \ \ \ \ \
| |_|/ / / /
|/| | | | | |
Remove math module from count
|
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Not required after https://github.com/rails/arel/pull/449
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
Prevent code duplication in ActiveStorage analyzers tests
|
|/ / / / / /
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
ImageAnalyzerTest and VideoAnalyzerTest are defining the same helper,
since both use `#create_file_blob` that is defined in TestHelper, it
makes sense to move `#extract_metadata_from` to that side.
|
| | | | | | |
|
|\ \ \ \ \ \
| |/ / / / /
|/| | | | | |
Unminify activestorage.js
|
|/ / / / / |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Make get_value public again
|
|/ / / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Adds test case for failing issue
Moves set_value back to protected
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Fix title for example of removing data from `session` [ci skip]
|