aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Enable Lint/UriEscapeUnescape cop not to allow using obsolete methods in the ↵Ryuta Kamizono2018-08-161-0/+3
| | | | | | future Follow up #33627.
* Merge pull request #33627 from vbrazo/fixtures/fix-obsolete-methodsRyuta Kamizono2018-08-161-1/+1
|\ | | | | Fix obsoleted method URI.unescape in activesupport/test
| * Fix obsoleted method URI.unescape in activesupport/testVitor Oliveira2018-08-151-1/+1
| |
* | Merge pull request #33626 from kddeisz/perform-enqueued-jobs-no-blockGuillermo Iguaran2018-08-153-8/+45
|\ \ | | | | | | Allow `perform_enqueued_jobs` to be called without a block.
| * | Allow `perform_enqueued_jobs` to be called without a block.Kevin Deisz2018-08-153-8/+45
| |/ | | | | | | Performs all of the jobs that have been enqueued up to this point in the test.
* / Do not show deprecate task in the task listyuuji.yaginuma2018-08-161-1/+0
|/
* Merge pull request #33499 from lsylvester/caller-ignore-pathsKasper Timm Hansen2018-08-157-37/+73
|\ | | | | use BacktraceCleaner for ActiveRecord verbose logging
| * Use backtrace cleaner to clean up backtrace for verbose query logsLachlan Sylvester2018-08-147-37/+73
| |
* | Merge pull request #33559 from anniecodes/dev-taskKasper Timm Hansen2018-08-155-17/+115
|\ \ | | | | | | Move `dev:cache` rake task to use Rails::Command
| * | Have `bin:rake dev:cache` use the Dev Rails Command under the hoodAnnie-Claude Côté2018-08-132-17/+32
| | | | | | | | | | | | | | | * Call the Rails::Command::DevCommand in the rake task for dev:cache * Add deprecation for using `bin/rake` in favor of `bin/rails`
| * | Adds Rails:Command for `dev:cache` that has the same behaviour as the rake taskAnnie-Claude Côté2018-08-132-0/+79
| | |
| * | Update Changelog to add deprecation to `rake dev:cache`Annie-Claude Côté2018-08-131-0/+4
| | |
* | | Merge pull request #33605 from assain/purpose-metadata-changelog-and-testsKasper Timm Hansen2018-08-152-8/+20
|\ \ \ | | | | | | | | Changelog and improved tests for purpose metadata added to cookies
| * | | Changelog for the new purpose metadata and improved testsAssain2018-08-132-8/+20
| |/ /
* | | Fix broken list formatting [ci skip]yuuji.yaginuma2018-08-151-4/+4
| | |
* | | Merge pull request #33620 from bogdanvlviv/fix-rubocop-offensesRyuta Kamizono2018-08-152-2/+2
|\ \ \ | | | | | | | | Fix rubocop offenses
| * | | Fix rubocop offensesbogdanvlviv2018-08-152-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Layout/TrailingWhitespace ``` actionpack/lib/action_controller/metal/request_forgery_protection.rb:49:4: C: Layout/TrailingWhitespace: Trailing whitespace detected. # ^ ``` Related to c3787494eda - Performance/StartWith ``` tasks/release.rb:108:44: C: Performance/StartWith: Use String#start_with? instead of a regex match anchored to the beginning of the string. header += "* No changes.\n\n\n" if current_contents =~ /\A##/ ```
* | | | Merge pull request #33612 from bogdanvlviv/test-assert_calledRyuta Kamizono2018-08-151-0/+10
|\ \ \ \ | | | | | | | | | | Test `assert_called` and `assert_called_with`
| * | | | Test `assert_called` and `assert_called_with`bogdanvlviv2018-08-141-0/+10
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | - ActiveSupport::Testing::MethodCallAssertions#assert_called - Ensure that the method stubbed by `assert_called` returns correct value after - ActiveSupport::Testing::MethodCallAssertions#assert_called_with - Ensure that `#assert_called_with` stubs the method to return a specific value - Ensure that the method stubbed by `assert_called_with` returns correct value after
* | | | Merge pull request #33618 from yskkin/bulk_change_table_commentRyuta Kamizono2018-08-152-3/+16
|\ \ \ \ | |_|/ / |/| | | Fix bulk change table ignores comment option on PostgreSQL.
| * | | Fix bulk change table ignores comment option on PostgreSQL.Yoshiyuki Kinjo2018-08-152-3/+16
|/ / /
* | | Merge pull request #33617 from bogdanvlviv/follow-up-33530George Claghorn2018-08-143-7/+16
|\ \ \ | | | | | | | | Follow up #33530
| * | | Follow up #33530bogdanvlviv2018-08-153-7/+16
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | - Move changelog entry of #33530 up in order to preserve the chronology since we always add new entries on the top of a changelog file. - Clarify the changelog entry - Clarify the docs of remove_foreign_key - Ensure reversible of `remove_foreign_key` with `:primary_key` and `:to_table` options.
* | | Merge pull request #33530 from jychen7/33515-invert-remove-foreign-keyRichard Schneeman2018-08-144-4/+36
|\ \ \ | | | | | | | | 33515 invert remove foreign key support "to_table"
| * | | Allow `to_table` in `invert_remove_foreign_key`Rich2018-08-144-4/+36
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove_foreign_key supports - remove_foreign_key :accounts, :branches - remove_foreign_key :accounts, to_table: :branches but the second one is not reversible. This branch is to fix and allow second one to be reversible. [Nikolay Epifanov, Rich Chen]
* | | Merge pull request #33137 from bogdanvlviv/add-array-extract-methodMatthew Draper2018-08-159-11/+107
|\ \ \ | |/ / |/| | Add `Array#extract!`
| * | Refactor `Array#extract!`bogdanvlviv2018-08-141-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid allocating the second array by using `Array#reject!` instead of `Enumerable#partition` in `Array#extract!`. There are benchmarks in order to ensure that the changes speed up the method: ``` begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end class Array def extract_v1!(&block) unless block_given? to_enum(:extract!) { size } else extracted_elements, other_elements = partition(&block) replace(other_elements) extracted_elements end end def extract_v2! return to_enum(:extract!) { size } unless block_given? extracted_elements = [] reject! do |element| extracted_elements << element if yield(element) end extracted_elements end end gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end arrays_for_partition = Array.new(1000) { (0..10000).to_a } arrays_for_extract_v1 = Array.new(1000) { (0..10000).to_a } arrays_for_extract_v2 = Array.new(1000) { (0..10000).to_a } Benchmark.ips do |x| x.report("Array#partition") do arrays_for_partition.each do |numbers| odd_numbers, numbers = numbers.partition { |number| number.odd? } numbers end end x.report("Array#extract_v1!") do arrays_for_extract_v1.each do |numbers| odd_numbers = numbers.extract_v1! { |number| number.odd? } numbers end end x.report("Array#extract_v2!") do arrays_for_extract_v2.each do |numbers| odd_numbers = numbers.extract_v2! { |number| number.odd? } numbers end end x.compare! end ``` The result of the benchmarks: ``` ruby -v ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] ``` ``` Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Using benchmark-ips 2.7.2 Using bundler 1.16.1 Warming up -------------------------------------- Array#partition 1.000 i/100ms Array#extract_v1! 1.000 i/100ms Array#extract_v2! 1.000 i/100ms Calculating ------------------------------------- Array#partition 1.390 (± 0.0%) i/s - 7.000 in 5.044843s Array#extract_v1! 2.781 (± 0.0%) i/s - 14.000 in 5.050589s Array#extract_v2! 3.151 (± 0.0%) i/s - 16.000 in 5.080608s Comparison: Array#extract_v2!: 3.2 i/s Array#extract_v1!: 2.8 i/s - 1.13x slower Array#partition: 1.4 i/s - 2.27x slower ``` Avoid `unless`/`else` in favour of an early return. The double-negative of that `else` can be confusing, even though the code layout is nearly the same. Also using of early return would improve `git diff` if we needed to change this method.
| * | Use `Array#extract!` where possiblebogdanvlviv2018-08-144-11/+17
| | |
| * | Add `Array#extract!`bogdanvlviv2018-08-145-0/+90
|/ / | | | | | | | | | | | | | | | | | | | | The method removes and returns the elements for which the block returns a true value. If no block is given, an Enumerator is returned instead. ``` numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9] numbers # => [0, 2, 4, 6, 8] ```
* | Merge pull request #33602 from ↵Yuji Yaginuma2018-08-141-3/+2
|\ \ | |/ |/| | | | | darren987469/fix-header-setting-doc-in-testing-guide Fix header setting doc in testing guide [ci skip]
| * Fix header setting doc in testing guide [ci skip]Darren2018-08-131-3/+2
|/
* Merge pull request #33597 from sikachu/update-coffeelintGuillermo Iguaran2018-08-121-1/+1
|\ | | | | Update coffeelint to 2.1.0
| * Update coffeelint to 2.1.0Prem Sichanugrist2018-08-131-1/+1
|/ | | | | | | | | | | There was a warning when running `npm install` in Action View: coffee-script@1.11.1: CoffeeScript on NPM has moved to "coffeescript" (no hyphen) We are not requiring `coffee-script` explicitly, but `coffeelint` does. The latest version, 2.1.0, already fix the dependency package name, so we should upgrade to it to suppress the warning.
* Merge pull request #33590 from bogdanvlviv/follow-up-33563-33474George Claghorn2018-08-121-7/+6
|\ | | | | Update "Active Record Migrations" guide [ci skip]
| * Clarify "Old Migrations" in "Active Record Migrations" guide [ci skip]bogdanvlviv2018-08-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | - Name rails app' files relatively to its root - `structure.sql` => `db/structure.sql` - `schema.rb` => `db/schema.rb` - Clarify rails commands - `db:migrate` => `rails db:migrate` - `db:migrate:status` => `rails db:migrate:status` - Add `/` to the end of `db/migrate` in order to express that it is directory and to keep consistency with `db/migrate/` above. Follow up #33474
| * Clarify note that SQLite3 adapter doesn't support `add_foreign_key` [ci skip]bogdanvlviv2018-08-121-3/+2
| | | | | | | | | | | | Context https://github.com/rails/rails/pull/33563#discussion_r208891486. Follow up #33563
* | Merge pull request #32937 from assain/add-purpose-to-cookiesKasper Timm Hansen2018-08-128-23/+218
|\ \ | | | | | | Add Purpose Metadata to Cookies
| * | Purpose Metadata For Signed And Encrypted CookiesAssain2018-08-128-23/+218
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Purpose metadata prevents cookie values from being copy-pasted and ensures that the cookie is used only for its originally intended purpose. The Purpose and Expiry metadata are embedded inside signed/encrypted cookies and will not be readable on previous versions of Rails. We can switch off purpose and expiry metadata embedded in signed and encrypted cookies using config.action_dispatch.use_cookies_with_metadata = false if you want your cookies to be readable on older versions of Rails.
* | Merge pull request #33591 from bogdanvlviv/add-changelog-for-31503Eileen M. Uchitelle2018-08-121-0/+16
|\ \ | |/ |/| Add changelog entry for #31503 [ci skip]
| * Add changelog entry for #31503 [ci skip]bogdanvlviv2018-08-121-0/+16
|/ | | | Related to #31503
* Merge pull request #33474 from olivierlacan/old-migrationsRichard Schneeman2018-08-111-3/+22
|\ | | | | Document best practices with old migrations
| * Document best practices with old migrationsOlivier Lacan2018-08-031-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The copy here is of course up for discussion but it feels like we need to address the issue of old migrations in the Migration guide because other than mentioning the canonical nature of schema.rb/structure.sql or the actual database compared to migration files, it seems like more guidance would help. Here's a sample of the kinds of question people seem to often ask about old Rails migrations: - https://stackoverflow.com/questions/20119391/delete-old-migrations-files-in-a-rails-app - https://www.reddit.com/r/rails/comments/4ayosd/compacting_migrations_files_or_delete_them/ - https://stackoverflow.com/questions/4248682/is-it-a-good-idea-to-purge-old-rails-migration-files - https://stackoverflow.com/questions/707013/is-it-a-good-idea-to-collapse-old-rails-migrations - https://stackoverflow.com/questions/1981777/rails-remove-old-models-with-migrations - https://stackoverflow.com/questions/3343534/rebase-rails-migrations-in-a-long-running-project The common theme seems to be: "I've got old migrations, should I keep them around on an old project?". My personal stance is that as long as migrations run and don't take too long do so, you should keep them around since it allows people working on the Rails project with you to seamlessly upgrade their local development database without having to do a `db:drop db:schema:load` and lose all their seed data. While writing down this suggested new section it felt like I was describing a very cumbersome process that could be address with a rake task like: ```bash rails db:migrate:remove VERSION=20121201123456 ``` It rollback to the version just before `20121201123456`, delete the migration file, and run `db:migrate` to get back to the latest migration. This of course doesn't address a situation when someone would want to delete or merge all migrations prior to a certain date, which is addressed by [squasher](https://github.com/jalkoby/squasher). I'm not sure this is something we want to encourage people to do. Although I feel like with more and more production Rails apps over 5-years old, it's definitely a concern we should address.
* | Merge pull request #33563 from lzap/foreign-key-note-docRichard Schneeman2018-08-111-0/+4
|\ \ | | | | | | ActiveRecord Guide - sqlite3 foreign keys note
| * | ActiveRecord Guide - sqlite3 foreign keys noteLukas Zapletal2018-08-091-0/+4
| | |
* | | Merge pull request #33587 from bogdanvlviv/follow-up-33202Kasper Timm Hansen2018-08-112-4/+3
|\ \ \ | | | | | | | | `bundle binstubs bundler` should be executed after `bundle install`
| * | | `bundle binstubs bundler` should be executed after `bundle install`bogdanvlviv2018-08-112-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: `bundle binstubs bundler` doesn't generate `bin/bundle` for newly generated Rails app. ``` ... (snip) run bundle binstubs bundler The git source https://github.com/rails/web-console.git is not yet checked out. Please run `bundle install` before trying to start your application run bundle install Fetching https://github.com/rails/web-console.git (snip) ... ``` Related to #33202
* | | | Merge pull request #33581 from q-centrix/use-strings-on-decorator-methodKasper Timm Hansen2018-08-112-2/+2
|\ \ \ \ | | | | | | | | | | Use strings instead of symbols on calls to decorate_matching_attribute_types
| * | | | Use strings instead of symbols on calls to decorate_matching_attribute_typesDillon Welch2018-08-102-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first thing this method does is run on the argument. This change passes in a string so we don't allocate a bunch of unnecessary extra strings by calling to_s on a symbol over and over.
* | | | | Merge pull request #33588 from bogdanvlviv/follow-up-31503Kasper Timm Hansen2018-08-111-1/+1
|\ \ \ \ \ | | | | | | | | | | | | Fix test failure
| * | | | | Fix test failurebogdanvlviv2018-08-111-1/+1
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` ... (snip) ............F Failure: JsonSerializationTest#test_as_json_should_return_a_hash_if_include_root_ in_json_is_true [/home/travis/build/rails/rails/activemodel/test/cases/serializers/json_serialization_test.rb:145]: Expected: 2006-08-01 00:00:00 UTC Actual: "2006-08-01T00:00:00.000Z" rails test home/travis/build/rails/rails/activemodel/test/cases/serializers/json_serialization_test.rb:136 (snip) ... ``` Related to #31503