1. 05 3月, 2020 10 次提交
  2. 04 3月, 2020 12 次提交
    • E
      Merge pull request #38636 from eileencodes/refactor-invert_predicate · c779d527
      Eileen M. Uchitelle 提交于
      Refactor invert predicate
      c779d527
    • E
      Refactor invert predicate · 27fb3563
      eileencodes 提交于
      Instead of doing a case statement here we can have each of the objects
      respond to `invert`. This means that when adding new objects we don't
      need to increase this case statement, it's more object oriented, and
      let's be fair, it looks better too.
      
      Aaron and I stumbled upon this while working on some performance
      work in Arel.
      
      I removed `random_object` from the invert test because we don't support
      random objects. If you pass a random object to Arel, it should raise,
      not be inverted.
      Co-authored-by: NAaron Patterson <aaron.patterson@gmail.com>
      27fb3563
    • E
      Merge pull request #38635 from tiramizoo/que-queue-name · 4b4f6b87
      Eileen M. Uchitelle 提交于
      Add support for que name to Que adapter.
      4b4f6b87
    • W
      Add support for que name to Que adapter. · d12a31b1
      Wojciech Wnętrzak 提交于
      Co-authored-by: NBrad Nauta <bradnauta@gmail.com>
      d12a31b1
    • N
      Allow `rails new —master` to point to master branch · 531fd3d5
      Nick Schwaderer 提交于
      Currently the `rails new` generator supports options `—dev` and `—edge`.
      
      `—dev` points to one’s local rails setup and `--edge` points to the latest stable Rails branch.
      
      However, in the Rails community we often think of the ‘edge’ as the latest merged master. We can see as much in Shopify’s fantastic article showing how they point to the latest master version of Rails: https://engineering.shopify.com/blogs/engineering/living-on-the-edge-of-rails
      
      I would originally have recommended changing ‘edge’ to point to master, as it has tripped me up on numerous occasions now.
      
      However I would rather add the desired functionality then change the current edge functionality.
      
      Therefore this PR adds the `—master` flag.
      
      It is intended to do exactly as `edge` does, simply with the changethat it points to Rails’ master branch instead of latest stable (i.e. 6_0_stable)
      
      Whenever developers see a new feature in Rails, such as the recently committed horizontal sharding (which prompted my PR), we would love to spin up a new Rails App to try out these new features.
      
      This command would allow us to jump right in with no configuration and offer our testing of the features, even those of us who aren’t able to spend a lot of time on OSS support.
      531fd3d5
    • J
    • J
    • R
      Merge pull request #38576 from Edouard-chin/ec-activejob-deprecation · 40b7d93c
      Rafael França 提交于
      Fix AJ wrong deprecation message on `after_callbacks_if_terminated`:
      40b7d93c
    • E
      Fix AJ wrong deprecation message on `after_callbacks_if_terminated`: · 0cdeee42
      Edouard CHIN 提交于
      - ### Problem
      
        In some cirumstances, the deprecation message to warn that AJ won't
        run `after_(enqueue/perform)` callbacks when the chain is halted
        by a `throw(:abort)` will be thrown even though no `throw(:abort)`
        was thrown.
      
        ```ruby
          run_callback(:foo) do
            ...
          end
        ```
      
        There is two possible way for the callback body to not be executed:
      
        1) `before` callback throw a `abort`
        2) `before` callback raises an error which is rescued by an
           around callback (See associated test in this commit for
           an example)
      
        When 2) happen we don't want to output a deprecation message,
        because what the message says isn't true and doesn't apply.
      
        ### Solution
      
        In order to differentiate between 1) and 2), I have added
        a `halted_callback_hook` which is called by ActiveSupport callback
        whenever the callback chain is halted.
      0cdeee42
    • E
      `ActiveSupport::Calbacks#halted_callback_hook` receive callback name: · 06dd162f
      Edouard CHIN 提交于
      - The `halted_callback_hook` method is called whenever the
        `terminator` halt the callback execution.
        Usually, this translate to when a `before` callback throw
        an `:abort`.
      
        <details>
          <summary> Example </summary>
      
          ```ruby
            class Foo
              include ActiveSupport::Callbacks
      
      	define_callbacks :save
      	set_callback(:save, :before) { throw(:abort) }
      
      	def run
      	  run_callbacks(:save) do
      	    'hello'
      	  end
      	end
      
      	def halted_callback_hook(filter)
      	  # filter is the proc passed to `set_callback` above
      	end
            end
          ```
        </details>
      
        ### Problem
      
        When a class has multiple callbacks, (i.e. `save`, `validate` ...),
        it's impossible to tell in the halted_callback_hook which type of
        callback halted the execution.
        This is useful to take different action based on the callback.
      
        <details>
          <summary> Use Case </summary>
      
          ```ruby
            class Foo
              include ActiveSupport::Callbacks
      
      	define_callbacks :save
      	define_callbacks :validate
      
      	set_callback(:save, :before) { throw(:abort) }
      	set_callback(:validate, :before) { throw(:abort) }
      
      	def run
      	  run_callbacks(:validate) do
      	    ...
      	  end
      
      	  run_callbacks(:save) do
      	    ...
      	  end
      	end
      
      	def halted_callback_hook(filter)
      	  Rails.logger.warn("Couldn't save the record, the ??? callback halted the execution")
      	end
            end
          ```
        </details>
      
        ### Solution
      
        Allow `halted_callback_hook` to receive a second argument which is
        the name of the callback being run.
      06dd162f
    • R
      Merge pull request #38628 from vinistock/simplify_route_score · 9d66da2f
      Rafael França 提交于
      Simplify route score
      9d66da2f
    • R
      Merge pull request #38620 from bogdanvlviv/add-activerecord-db-folder-to-gitignore · 2d2fa64f
      Rafael França 提交于
      Add activerecord/db/ to gitignore
      2d2fa64f
  3. 03 3月, 2020 3 次提交
    • V
      Simplify route score · 0334eb6d
      Vinicius Stock 提交于
      0334eb6d
    • B
      Rename 'db' to 'test/db' in Active Record's tests · 82a13625
      bogdanvlviv 提交于
      82a13625
    • G
      [guides] Update missing translation example · 7c8d0ec3
      Geoff Harcourt 提交于
      The Rails Guides contain an example of how to raise for a missing
      translation when `I18n.t` is called from anywhere, including
      non-ActionView contexts. The example builds a custom exception handler
      that catches and raises any instance of `I18n::MissingTranslationData`
      and passes on any other exception to be handled by `I18n` as normally
      happens.
      
      Unfortunately, while `I18n::MissingTranslationData` is what eventually
      should be raised for a missing translation, the initial exception the
      handler sees is actually `I18n::MissingTranslation`, and
      `MissingTranslationData` is the product of calling `#to_exception` on
      that exception object. As a result, the example in the guides ends up
      not raising for missing translations, silently resulting in the return
      of the missing translation key.
      
      This change updates the guides to with a working example, catching
      `I18n::MissingTranslation` which results in a raise of
      `I18n::MissingTranslationData` with the missing key.
      7c8d0ec3
  4. 02 3月, 2020 3 次提交
    • B
      Add activerecord/db/ to gitignore · 22877a9d
      bogdanvlviv 提交于
      After running `bundle exec rake test:sqlite3` and `bundle exec rake test:sqlite3_mem`
      on my VM I noticed that it had created untracked files:
      
      ```bash
      vagrant@ubuntu-bionic:/rails/activerecord$ git status
      Untracked files:
        (use "git add <file>..." to include in what will be committed)
              db/
              file::memory:
      ```
      
      To prevent them from being accidentally committed I put 'file::memory:' to
      `activerecord/db/` folder and added the folder to .gitignore
      Also, we could consider fixing this by removing `db/` folder in each test that
      creates the folder.
      
      It would be great if someone confirms that it happens not only on my VM.
      22877a9d
    • A
      Merge pull request #38616 from abhaynikam/fix-typo-in-rails-engine-guides · 6d0895a4
      Arun Agrawal 提交于
      Fixed typo classsic -> classic [ci skip]
      6d0895a4
    • A
      Fixed typo classsic -> classic [ci skip] · de4c941e
      Abhay Nikam 提交于
      de4c941e
  5. 29 2月, 2020 4 次提交
    • E
      Merge pull request #38609 from eileencodes/fix-error-in-deprecation · c63cfc87
      Eileen M. Uchitelle 提交于
      Fix error in deprecation
      c63cfc87
    • R
      Merge pull request #38610 from hachi8833/fix_security_guide · d877729e
      Ryuta Kamizono 提交于
      [ci skip] Security guide: change raw HTML elements and signs to backquoted ones
      d877729e
    • H
      Change raw HTML elements and signs to backquoted ones · 54256d52
      hachi8833 提交于
      54256d52
    • E
      Fix error in deprecation · 13e28f5f
      eileencodes 提交于
      When I implemented the deprecation for #38536 I left in the setter in
      the initalizer. This meant that objects returned had both `@name` and
      `@spec_name` set and objects looked like this:
      
      ```
      <ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fe0f7100c68
        @env_name="development",
        @name="primary",
        @spec_name="primary",
        @config={
          :adapter=>"mysql2",
          :database=>"recipes_app_development"
        }
      >
      ```
      
      Since we don't use the kwarg to create the hash config and we have the
      reader for reading off the object or selecting from the configurations
      objects list we can remove this so the object looks like:
      
      ```
      <ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fe0f7100c68
        @env_name="development",
        @name="primary",
        @config={
          :adapter=>"mysql2",
          :database=>"recipes_app_development"
        }
      >
      ```
      13e28f5f
  6. 28 2月, 2020 8 次提交