aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
| * | Remove reference to TokaidoJonathan Roes2018-04-301-5/+3
|/ /
* | Merge pull request #32756 from houhoulis/fix_example_url_helper_in_testing_guideRyuta Kamizono2018-04-301-4/+4
|\ \ | | | | | | Fix url_helper examples in testing guide [ci skip]
| * | Fix url_helper examples in testing guide [ci skip]Chris Houhoulis2018-04-291-4/+4
|/ /
* | Avoid duplicating downloads from Google Cloud Storage in memoryGeorge Claghorn2018-04-291-2/+2
| | | | | | | | References #32703.
* | Improve the performance of `ActiveSupport::Inflector.ordinal`Ryuta Kamizono2018-04-291-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* | Stream blobs from disk in 5 MB chunksGeorge Claghorn2018-04-292-4/+4
| | | | | | | | Match other services, which all use a 5 MB chunk size.
* | Merge pull request #32751 from utilum/make_railties_2.6_ci_log_accessible_againRyuta Kamizono2018-04-292-1/+10
|\ \ | | | | | | Make Railties CI log for Ruby 2.6 accessible again
| * | Make Railties CI log for Ruby 2.6 accessible againutilum2018-04-292-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #32750 from utilum/assert_dir_before_assert_file_in_dirGeorge Claghorn2018-04-291-1/+1
|\ \ \ | |/ / |/| | Swap assertion order
| * | Swap assertion order for better reportingutilum2018-04-291-1/+1
|/ / | | | | | | `assert_directory("test/system")` may pass even if `assert_file("test/system/.keep")` fails.
* | We usually do not use GH#1234 style in the CHANGELOGs [ci skip]Ryuta Kamizono2018-04-291-1/+1
| |
* | Restore original merging order to enforce `if_exists: true`Ryuta Kamizono2018-04-291-2/+1
| | | | | | | | | | The merging order was accidentally changed at #32447. The original intention is force `drop_table ... if_exists: true`. #28070.
* | Fix `Associations::ClassMethods` doc [ci skip]Ryuta Kamizono2018-04-291-7/+7
| | | | | | | | | | * Singular associations don't define `#association.nil?` * Wrap with <tt> for each method, not the whole sentence
* | Merge pull request #32747 from printercu/improve_t_helperGeorge Claghorn2018-04-291-8/+2
|\ \ | | | | | | Don't allocate unnecessary array in translation helper
| * | Don't allocate unnecessary array in translation helperMax Melentiev2018-04-281-8/+2
| | |
* | | Merge pull request #32698 from zealot128/patch-1George Claghorn2018-04-281-0/+172
|\ \ \ | |/ / |/| | [ci skip] update ActiveStorage documentation
| * | [ci skip] update ActiveStorage documentationStefan Wienert2018-04-281-0/+172
| | | | | | | | | | | | | | | | | | | | | | | | - 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
* | | Merge pull request #32745 from pradyumna2905/patch-2Vipul A M2018-04-281-1/+1
|\ \ \ | | | | | | | | [ci skip] Fix a typo in testing.md
| * | | [ci skip] Fix typo in testing.mdPradyumna Shembekar2018-04-271-1/+1
|/ / /
* | | Merge pull request #30647 from droptheplot/render-partials-string-localsRafael França2018-04-272-1/+10
|\ \ \ | | | | | | | | Allow usage of strings as locals for partial renderer
| * | | Allow usage of strings as locals for partial rendererSergey Novikov2017-09-182-1/+10
| | | |
* | | | Merge pull request #32727 from utilum/assert_dont_expectsRafael França2018-04-2716-190/+333
|\ \ \ \ | | | | | | | | | | Use MethodCallAssertions instead of mocha expects
| * | | | assert_called_withutilum2018-04-265-89/+175
| | | | |
| * | | | assert_calledutilum2018-04-2612-66/+102
| | | | |
| * | | | assert_not_calledutilum2018-04-265-38/+59
| | | | |
* | | | | Merge pull request #32733 from Edouard-chin/ec-setupand-teardownRafael França2018-04-273-13/+11
|\ \ \ \ \ | | | | | | | | | | | | `SetupAndTeardown` has few caveats that breaks libraries
| * | | | | `SetupAndTeardown` has few caveats that breaks libraries:Edouard CHIN2018-04-273-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* | | | | | Merge pull request #31956 from fatkodima/has_attached-presence-validationEileen M. Uchitelle2018-04-272-0/+34
|\ \ \ \ \ \ | | | | | | | | | | | | | | has_(one/many)_attached presence validation
| * | | | | | has_(one/many)_attached presence validationfatkodima2018-02-112-0/+34
| | | | | | |
* | | | | | | Adding precision about which letter case to use for controller names … ↵simonjamain2018-04-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#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
* | | | | | | Ensure that `ids_reader` respects dirty target whether target is loaded or notRyuta Kamizono2018-04-272-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | | Merge pull request #32617 from tgturner/size-should-use-available-associationRyuta Kamizono2018-04-273-1/+82
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Loaded associations should not run a new query when size is called
| * | | | | | | Loaded associations should not run a new query when size is calledGraham Turner2018-04-263-1/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 (#32735)Jamie Dihiansan2018-04-261-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update 'rails_welcome.png' to reflect a more diverse population * Cleanup 'rails_welcome.png'
* | | | | | | | Add test case that assigning belongs_to on destroyed object raises frozen errorRyuta Kamizono2018-04-271-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to ensure that the behavior has not changed before and after #31575.
* | | | | | | | Address `Style/StringLiterals` offenceRyuta Kamizono2018-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Caused at 9276ea89d2b0be9fdd1ad6590857f8d45a38c267.
* | | | | | | | Don't dup Strings when jsonifyingAkira Matsuda2018-04-271-2/+6
| |_|/ / / / / |/| | | | | | | | | | | | | | | | | | | | This method would be called so many times and would create so many temporary garbage Strings
* | | | | | | Don't try to destoy the given string via method argumentAkira Matsuda2018-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | | | Reduce String allocations when building Action View tagsAkira Matsuda2018-04-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This method is called against each tag option for each tag, and creates an extra garbage String per each call
* | | | | | | Reduce extra object creations in TaggedLoggingAkira Matsuda2018-04-271-1/+3
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]}}
* | | | | | Merge pull request #32725 from nikolai-b/rm_count_math_mixinRyuta Kamizono2018-04-261-2/+0
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | Remove math module from count
| * | | | | Remove math module from countNikolai B2018-04-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | Not required after https://github.com/rails/arel/pull/449
* | | | | | Merge pull request #32728 from ricardotk002/prevent-duplication-active-storageGeorge Claghorn2018-04-253-10/+4
|\ \ \ \ \ \ | | | | | | | | | | | | | | Prevent code duplication in ActiveStorage analyzers tests
| * | | | | | Move #extract_metadata_from to ActiveStorage's TestHelperRicardo Díaz2018-04-253-10/+4
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | Simplify URL generation for partial downloads from GCSGeorge Claghorn2018-04-251-1/+2
| | | | | |
* | | | | | Merge pull request #32721 from javan/ast-unminify-jsJavan Makhmali2018-04-256-1386/+1093
|\ \ \ \ \ \ | |/ / / / / |/| | | | | Unminify activestorage.js
| * | | | | Unminify activestorage.jsJavan Makhmali2018-04-256-1386/+1093
|/ / / / /
* | | | | Merge pull request #32717 from tgturner/make-get-and-set-values-public-againRyuta Kamizono2018-04-253-4/+15
|\ \ \ \ \ | | | | | | | | | | | | Make get_value public again
| * | | | | `get_value` needs to be a public methodGraham Turner2018-04-253-4/+15
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | Adds test case for failing issue Moves set_value back to protected
* | | | | Merge pull request #32702 from bogdanvlviv/fix-description-for-31685Rafael França2018-04-251-2/+2
|\ \ \ \ \ | | | | | | | | | | | | Fix title for example of removing data from `session` [ci skip]