1. 18 12月, 2017 1 次提交
  2. 17 12月, 2017 1 次提交
  3. 16 12月, 2017 1 次提交
    • Y
      Add `skip_bootsnap` option · 838b40da
      yuuji.yaginuma 提交于
      `bootsnap` is a useful gem normally. However, `bootsnap` is unnecessary
      when generating a Rails application to be used only for testing.
      So I want to control whether use this or not by option.
      838b40da
  4. 14 12月, 2017 3 次提交
    • R
      Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the future · 245c1daf
      Ryuta Kamizono 提交于
      Follow up of #31432.
      245c1daf
    • O
      Log call site for all queries · 3876defd
      Olivier Lacan 提交于
      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).
      3876defd
    • M
      Expose Active Storage routes · ff25c251
      Mehmet Emin INAC 提交于
      ff25c251
  5. 12 12月, 2017 1 次提交
  6. 09 12月, 2017 2 次提交
    • A
      Set the Rails environment from an environment variable · a50b8ea3
      Aaron Patterson 提交于
      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`)
      a50b8ea3
    • A
      Add failing test for wrong database connection · a58543db
      Aaron Patterson 提交于
      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.
      a58543db
  7. 07 12月, 2017 1 次提交
    • A
      Fix Rails environment when running tests with Ruby · da225c0d
      Aaron Patterson 提交于
      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.
      da225c0d
  8. 05 12月, 2017 2 次提交
  9. 04 12月, 2017 1 次提交
  10. 03 12月, 2017 2 次提交
    • Y
      Make `Migrator.current_version` work without a current database · dbee80bc
      yuuji.yaginuma 提交于
      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
      dbee80bc
    • C
      Fix typo in test error message · a71bbed7
      claudiob 提交于
      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
      ```
      a71bbed7
  11. 30 11月, 2017 1 次提交
  12. 28 11月, 2017 1 次提交
  13. 27 11月, 2017 4 次提交
  14. 26 11月, 2017 2 次提交
    • Y
      Remove field ids from scaffold form · fbb8b373
      yuuji.yaginuma 提交于
      This was added with 27f103fc for link labels and fields.
      However, `form_with` changed to generates ids by default with d3893ec3.
      So I think that adding an explicit ids is unnecessary.
      fbb8b373
    • N
      Change `form_with` to generates ids by default · 260d6f11
      npezza93 提交于
      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.`
      260d6f11
  15. 22 11月, 2017 1 次提交
  16. 18 11月, 2017 1 次提交
  17. 16 11月, 2017 2 次提交
    • Y
      Add master key to `gitignore` on `rails new` · f27319a7
      yuuji.yaginuma 提交于
      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.
      f27319a7
    • W
      Add CLI to manage encrypted files/configs. · 7a8728a0
      Wojciech Wnętrzak 提交于
      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")
      ```
      7a8728a0
  18. 14 11月, 2017 3 次提交
  19. 13 11月, 2017 1 次提交
  20. 09 11月, 2017 2 次提交
  21. 08 11月, 2017 2 次提交
  22. 07 11月, 2017 4 次提交
    • B
      Fix `bin/rails db:migrate` with specified `VERSION` · 90fe2a42
      bogdanvlviv 提交于
      Ensure that `bin/rails db:migrate` with specified `VERSION` reverts
      all migrations only if `VERSION` is `0`.
      Raise error if target migration doesn't exist.
      90fe2a42
    • B
      f4af77ab
    • B
      `rails new` runs `rails active_storage:install` · 0835527d
      bogdanvlviv 提交于
      Omit `rails activestorage:install` for jdbcmysql, jdbc and shebang tests
      
      AppGeneratorTest#test_config_jdbcmysql_database
      
        rails aborted!
        LoadError: Could not load 'active_record/connection_adapters/mysql_adapter'.
        Make sure that the adapter in config/database.yml is valid.
        If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
        the necessary adapter gem to the Gemfile.
        (compressed)
        bin/rails:4:in `<main>'
        Tasks: TOP => activestorage:install => environment
        (See full trace by running task with --trace)
      
      AppGeneratorTest#test_config_jdbc_database
      
        rails aborted!
        LoadError: Could not load 'active_record/connection_adapters/jdbc_adapter'.
        Make sure that the adapter in config/database.yml is valid.
        If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
        the necessary adapter gem to the Gemfile.
        (compressed)
        bin/rails:4:in `<main>'
        Tasks: TOP => activestorage:install => environment
        (See full trace by running task with --trace)
      
      AppGeneratorTest#test_shebang_is_added_to_rails_file
      
        /home/ubuntu/.rbenv/versions/2.4.1/bin/ruby: no Ruby script found in input (LoadError)
      
      Prevent PendingMigrationError in tests
      
       * Run `bin/rails db:migrate RAILS_ENV=test` in test_cases before start tests to prevent PendingMigrationError
       * FileUtils.rm_r("db/migrate")
       * --skip-active-storage
      
      Fix failed tests in `railties/test/railties/engine_test.rb`
      
      Related to #30111
      
      Imporve `SharedGeneratorTests#test_default_frameworks_are_required_when_others_are_removed`
      
       - Explicitly skip active_storage
       - Ensure that skipped frameworks are commented
       - Ensure that default frameworks are not commented
      
      Fix error `Errno::ENOSPC: No space left on device - sendfile`
      
      Since `rails new` runs `rails active_storage:install`
      that boots an app.
      
      Since adding Bootsnap 0312a5c6
      during booting an app, it creates the cache:
      
         264K    tmp/cache/bootsnap-load-path-cache
         27M     tmp/cache/bootsnap-compile-cache
      
      * teardown_app must remove app
      0835527d
    • B
      Add --skip-active-storage and do so automatically when --skip-active-record is used · 4a835aa3
      bogdanvlviv 提交于
      Closes #30102
      
      Revert part 787fe90d
      
      --skip-active-storage pass throughs `rails plugin new`
      
      Add changelog entry about default initialization of Active Storage
      4a835aa3
  23. 05 11月, 2017 1 次提交
    • Y
      Generate the correct path in nested scaffold generator · 4dcb630c
      yuuji.yaginuma 提交于
      Currently, namespaced scaffold generator will generate an incorrect path
      and the generated file will not work properly.
      
      ```
      $ ./bin/rails g scaffold admin/user
      $ ./bin/rails db:migrate
      $  ./bin/rails t test/controllers
      # Running:
      
      E
      
      Error:
      Admin::UsersControllerTest#test_should_create_admin_user:
      NameError: undefined local variable or method `admin_admin_users_url' for #<Admin::UsersControllerTest:0x000055a59f25ff68>
      Did you mean?  admin_users
          test/controllers/admin/users_controller_test.rb:20:in `block (2 levels) in <class:UsersControllerTest>'
          test/controllers/admin/users_controller_test.rb:19:in `block in <class:UsersControllerTest>'
      
      bin/rails test test/controllers/admin/users_controller_test.rb:18
      ```
      
      This is because combine `controller_class_path` and `singular_table_name`
      to generate route.
      https://github.com/rails/rails/blob/360698aa245b45349d1d1b12e1afb34759515e69/railties/lib/rails/generators/named_base.rb#L172
      
      Normally, if using namspaced generator, table name already contains
      namespace. Therefore, adding `controller_class_path` adds extra namespace.
      Since it is special only when explicitly specifying `model-name`, it is
      modified to change the value only when `model-name`is specified.
      
      Follow up of #30729
      4dcb630c