aboutsummaryrefslogtreecommitdiffstats
path: root/railties
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #31434 from olivierlacan/boot-feedbackSean Griffin2017-12-141-0/+4
|\ | | | | Provide instant feedback when booting Rails
| * Provide instant feedback when booting RailsOlivier Lacan2017-12-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've noticed during pair/mob programming sessions with peers that despite the speed boosts provided by Bootsnap and Spring, there is a noticeable latency between firing a bin/rails server command and any feedback being provided to the console. Depending on the size of the application this lack of feedback can make it seem like something is wrong when Rails is simply busy initializing. This change may seem gratuitous but by just printing one line to STDOUT we're giving a clear signal to the Rails user that their command has been received and that Rails is indeed booting. It almost imperciptibly makes Rails feel more responsive. Sure the code doesn't look very fancy but there's no other appropriate place I could think of putting it than boot.rb. Compare these two GIFs of booting without and with this change: Before: ![Without Boot Feedback](https://user-images.githubusercontent.com/65950/33964140-721041fc-e025-11e7-9b25-9d839ce92977.gif) After: ![With Boot Feedback](https://user-images.githubusercontent.com/65950/33964151-79e12f86-e025-11e7-93e9-7a75c70d408f.gif)
* | Merge pull request #26815 from olivierlacan/log-query-sourceEileen M. Uchitelle2017-12-144-4/+17
|\ \ | | | | | | Log the original call site for an ActiveRecord query
| * | Log call site for all queriesOlivier Lacan2017-12-134-4/+17
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new ActiveRecord configuration option allows you to easily pinpoint what line of application code is triggering SQL queries in the development log by appending below each SQL statement log the line of Ruby code that triggered it. It’s useful with N+1 issues, and to locate stray queries. By default this new option ignores Rails and Ruby code in order to surface only callers from your application Ruby code or your gems. It is enabled on newly generated Rails 5.2 applications and can be enabled on existing Rails applications: ```ruby Rails.application.configure do # ... config.active_record.verbose_query_logs = true end ``` The `rails app:upgrade` task will also add it to `config/development.rb`. This feature purposely avoids coupling with ActiveSupport::BacktraceCleaner since ActiveRecord can be used without ActiveRecord. This decision can be reverted in the future to allow more configurable backtraces (the exclusion of gem callers for example).
* / Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-2/+2
|/ | | | Follow up of #31432.
* Expose Active Storage routesMehmet Emin INAC2017-12-131-13/+32
|
* Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-121-6/+6
| | | | Follow up of #31390.
* Fix secrets command deprecation messageStefan Wrobel2017-12-111-1/+1
|
* `create_fixtures` doesn't work since at least ↵Edouard CHIN2017-12-111-4/+0
| | | | | | | a94220b66c9e4890007f66b092b25f8a64a19d31: - The namespacing should be `ActiveRecord::FixtureSet` - I might be missing something but I'm not sure why `create_fixtures` is useful for nowaday (unless for testing rails internal /shrug) and since it's been that long it wasn't working I think it should be fine to just fire it
* Set the Rails environment from an environment variableAaron Patterson2017-12-082-5/+2
| | | | | | | | | Option parsing happens too late to have any impact on the Rails environment. Rails accesses the environment name and memoizes it too early in the boot process for a commandline option to have any impact on the database connection, so we'll change this test to set the environment from an environment variable (and ensure it still works when running tests with `ruby`)
* Revert "remove unnecessary `RAILS_ENV` setting"Aaron Patterson2017-12-082-0/+4
| | | | This reverts commit 9a80f52541ed2c93ebef02909ecab3aaf9127150.
* Add failing test for wrong database connectionAaron Patterson2017-12-081-0/+17
| | | | | | When tests are run with just `ruby`, the RAILS_ENV is set to `development` too early, and we connect to the development database rather than the test database.
* Fix Rails environment when running tests with RubyAaron Patterson2017-12-063-3/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | I frequently run tests with `ruby`, not with a runner like `rake` or `rails`. When running the test with just `ruby` the `RAILS_ENV` environment variable did not get set to "test", and this would cause the tests to fail (and even mutate the development database!) This commit adds integration tests for running tests with just `ruby` and ensures the environment gets defaulted to "test". I also added a test to ensure that passing an environment to `-e` actually works (and fixed that case too). An interesting / annoying thing is that Minitest picks up it's plugins by asking RubyGems for a list of files: https://github.com/seattlerb/minitest/blob/ca6a71ca901016db09a5ad466b4adea4b52a504a/lib/minitest.rb#L92-L100 This means that RubyGems needs to somehow know about the file before it can return it to Minitest. Since we are not packaging Rails as a Gem before running the integration tests on it (duh, why would you do that?), RubyGems doesn't know about the file, so it can't tell Minitest, so Minitest doesn't automatically require it. This means I had to manually require and insert the plugin in our integration test. I've left comments about that in the test as well. Ugh.
* Add more tests for the `--webpack` optionTsukuru Tanimichi2017-12-051-0/+19
|
* Modify `test_webpack_option`Tsukuru Tanimichi2017-12-051-3/+5
|
* Merge pull request #31279 from ttanimichi/tests-for-webpack-optionGuillermo Iguaran2017-12-041-0/+14
|\ | | | | Add tests for the `--webpack` option
| * Add tests for the `--webpack` optionTsukuru Tanimichi2017-12-041-0/+14
| | | | | | | | | | We probably don't have any tests for the `--webpack` option. related: #27288
* | Merge pull request #31311 from ↵Kasper Timm Hansen2017-12-032-0/+29
|\ \ | | | | | | | | | | | | y-yagi/ignore_no_database_error_when_loading_schema_cache Ignore `NoDatabaseError` when loading schema cache
| * | Make `Migrator.current_version` work without a current databaseyuuji.yaginuma2017-12-032-0/+29
| | | | | | | | | | | | | | | | | | | | | This is necessary in order to make the processing dependent on `Migrator.current_version` work even without database. Context: https://github.com/rails/rails/pull/31135#issuecomment-348404326
* | | Fix typo in test error messageclaudiob2017-12-021-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the current code, a failing test shows this error, which is missing the number of times called and has two periods at the end. ``` /railties$ be ruby -Itest test/generators/app_generator_test.rb -n test_active_storage_install Failure: AppGeneratorTest#test_active_storage_install [test/generators/app_generator_test.rb:313]: active_storage:install expected to be called once, but was called times.. Expected: 1 Actual: 2 ``` After the fix, the error message looks correct: ``` /railties$ be ruby -Itest test/generators/app_generator_test.rb -n test_active_storage_install Failure: AppGeneratorTest#test_active_storage_install [test/generators/app_generator_test.rb:313]: active_storage:install expected to be called once, but was called 2 times. Expected: 1 Actual: 2 ```
* | Merge pull request #31241 from matthewd/no-after-forkMatthew Draper2017-12-011-23/+1
|\ \ | | | | | | Drop the before_fork/on_worker_boot advice
| * | Drop the before_fork/on_worker_boot adviceMatthew Draper2017-11-271-23/+1
| | | | | | | | | | | | | | | It's no longer required for Active Record, and other common libraries (dalli, redis-rb) all seem to be fork-proof too.
* | | Move system test dependencies to test groupAnton Rieder2017-11-301-7/+10
| | |
* | | Do not overwrite by default if credentials already existsyuuji.yaginuma2017-11-302-2/+12
| | | | | | | | | | | | Fixes #31286
* | | Build the root folder before specific filesRafael Mendonça França2017-11-291-8/+8
| | | | | | | | | | | | Fixes #31282.
* | | Use `credentials` instead of `keyfile` in GCS seviceyuuji.yaginuma2017-11-291-1/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | The `keyfile` was renamed to `credentials` in `google-cloud-storage` 1.8.0. https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/google-cloud-storage/CHANGELOG.md#180--2017-11-14 Although `keyfile` can still be used, but it looks like deprecate. https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/ddf7b2a856d676316525eb581c1a4cc83ca6097b/google-cloud-storage/lib/google/cloud/storage.rb#L589...L590 Therefore, I think that should use `credentials` in newly generated applications. Ref: https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues/1802
* | Preparing for 5.2.0.beta2 releaseRafael Mendonça França2017-11-282-1/+6
| |
* | Use same version constraint in mysql adapter and generated applicationyuuji.yaginuma2017-11-282-2/+2
| | | | | | | | Follow up of 924a368f5c654f5304e575c767eb0fc64adc8659
* | Preparing for 5.2.0.beta1 releaseRafael Mendonça França2017-11-272-1/+3
| |
* | Make form_with_generates_ids default value to be falseRafael Mendonça França2017-11-271-4/+0
| | | | | | | | | | This will keep the behavior of an application with the defaults of a 4.2 or 5.0 application behaving the same when upgrading to 5.2.
* | Remove Content-Security-Policy initializer in API-only Applicationsyuuji.yaginuma2017-11-272-0/+8
|/ | | | | | Since `ContentSecurityPolicy::Middleware` is not loaded in API-only Applications, initializer is unnecessary. Ref: https://github.com/rails/rails/blob/9c10fec4c06da38f8975dfb851f4d899aa85f8b7/railties/lib/rails/application/default_middleware_stack.rb#L66..L68
* Added missing test for presence of CSP initializerPrathamesh Sonpatki2017-11-271-0/+1
| | | | - Followup of #31162
* Add DSL for configuring Content-Security-Policy headerAndrew White2017-11-276-34/+264
| | | | https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
* Use Puma 3.11 in newly generated applicationsyuuji.yaginuma2017-11-272-2/+2
| | | | | | | In order to use early hints, need to use Puma 3.11.0 or higher. So, I think that should specify that version in newly generated applications. Ref: https://github.com/puma/puma/commit/f6f3892f4d82638fb7a2a57d993641b1486ee88a
* Merge pull request #31167 from albertoalmagro/clean-db-ambiguityRafael França2017-11-261-2/+2
|\ | | | | Clean database naming ambiguity
| * Remove DB naming ambiguityAlberto Almagro2017-11-261-2/+2
| | | | | | | | In some places this file referred to the database in three different ways: database, DB and db. The last one caused confusion with the db namespace and the db folder. This commit removes this ambiguity by using the whole word 'database' everywhere
* | Remove field ids from scaffold formyuuji.yaginuma2017-11-263-11/+7
|/ | | | | | This was added with 27f103fc7e3260efe0b8dde66bf5354f2202ee32 for link labels and fields. However, `form_with` changed to generates ids by default with d3893ec38ec61282c2598b01a298124356d6b35a. So I think that adding an explicit ids is unnecessary.
* Remove duplicated `form_with_generates_remote_forms` settingyuuji.yaginuma2017-11-261-1/+0
| | | | | When load `5.1` config, `form_with_generates_remote_forms` is set. https://github.com/rails/rails/blob/89a209f1abba5a2320d31c4898dea150c0abd0c0/railties/lib/rails/application/configuration.rb#L86
* Use parentheses for multi-line method callsRafael Mendonça França2017-11-252-5/+10
| | | | | Own style guide says we should be using parentheses for method calls with arguments.
* Make form_with_generates_ids default in Rails 5.2Rafael Mendonça França2017-11-251-2/+7
| | | | | When the defaults being loaded are the 5.0 or 5.1 we disable generation of ids with form_with.
* Change `form_with` to generates ids by defaultnpezza932017-11-252-0/+63
| | | | | | | | | | When `form_with` was introduced we disabled the automatic generation of ids that was enabled in `form_for`. This usually is not an good idea since labels don't work when the input doesn't have an id and it made harder to test with Capybara. You can still disable the automatic generation of ids setting `config.action_view.form_with_generates_ids` to `false.`
* Rubocop styleDixit Patel2017-11-241-0/+2
|
* Fix generator suggestion raise error when I18n.available_locales don’t ↵willnet2017-11-222-1/+15
| | | | include :en
* Fix formatting of `credentials` and `encrypted` [ci skip]yuuji.yaginuma2017-11-191-8/+8
|
* Deprecate an `after_bundle` callback in Rails plugin templatesyuuji.yaginuma2017-11-183-0/+40
| | | | | | | | | Since fbd1e98cf983572ca9884f17f933ffe92833632a, Rails plugin does not run `bundle install` when generating. Therefore, `after_bundle` callback is not actually executed after `bundle`. Since there is a difference between the name and the actual behavior, I think that should be remove.
* Fixed example of `Rails.application.encrypted` method usageWojciech Wnętrzak2017-11-161-1/+1
| | | | [ci skip]
* Add master key to `gitignore` on `rails new`yuuji.yaginuma2017-11-164-1/+19
| | | | | | | We generate master key on `rails new`. Therefore, if do not add master key to `.gitginore` on `rails new`as well, there is a possibility that the master key will be committed accidentally.
* Pass options onto key file generator.Kasper Timm Hansen2017-11-151-1/+1
|
* Merge branch 'freeletics-manage-multiple-credential-files'Kasper Timm Hansen2017-11-159-41/+337
|\ | | | | | | Fixes https://github.com/rails/rails/pull/30940
| * Add CLI to manage encrypted files/configs.Wojciech Wnętrzak2017-11-1510-50/+347
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To edit/show encrypted file: ``` bin/rails encrypted:edit config/staging_tokens.yml.enc bin/rails encrypted:edit config/staging_tokens.yml.enc --key config/staging.key bin/rails encrypted:show config/staging_tokens.yml.enc ``` Also provides a backing Rails.application.encrypted API for Ruby access: ```ruby Rails.application.encrypted("config/staging_tokens.yml.enc").read Rails.application.encrypted("config/staging_tokens.yml.enc").config Rails.application.encrypted("config/staging_tokens.yml.enc", key: "config/staging.key") ```