- 04 3月, 2020 5 次提交
-
-
由 Rafael França 提交于
Fix AJ wrong deprecation message on `after_callbacks_if_terminated`:
-
由 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.
-
由 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.
-
由 Rafael França 提交于
Simplify route score
-
由 Rafael França 提交于
Add activerecord/db/ to gitignore
-
- 03 3月, 2020 2 次提交
-
-
由 Vinicius Stock 提交于
-
由 bogdanvlviv 提交于
-
- 02 3月, 2020 3 次提交
-
-
由 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.
-
由 Arun Agrawal 提交于
Fixed typo classsic -> classic [ci skip]
-
由 Abhay Nikam 提交于
-
- 29 2月, 2020 4 次提交
-
-
由 Eileen M. Uchitelle 提交于
Fix error in deprecation
-
由 Ryuta Kamizono 提交于
[ci skip] Security guide: change raw HTML elements and signs to backquoted ones
-
由 hachi8833 提交于
-
由 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" } > ```
-
- 28 2月, 2020 14 次提交
-
-
由 Eileen M. Uchitelle 提交于
Testing Guides: Added section on Parallell Testing of Transactions
-
由 Thomas Fankhauser 提交于
Based on https://github.com/rails/rails/issues/38578, it would be nice to have some information on transactions in test cases
-
由 Ryuta Kamizono 提交于
Closes #37435.
-
由 Abhay Nikam 提交于
-
由 Aaron Patterson 提交于
ActionText is using ActionView in a way that ActionView doesn't have in it's test suite. This is just a regression test to hit that same use case.
-
由 Kasper Timm Hansen 提交于
[ci skip] Documentation: Use yml extension for locale files example
-
由 Alberto Almagro 提交于
The default extension we use for locale files is `.yml`. This patch reflects this in the documentation example.
-
由 Eileen M. Uchitelle 提交于
Dumps the schema or structure of a database when calling db:migrate:name
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
Fix `unscope` when an `eq` node which has no arel attribute
-
由 Kyle Thompson 提交于
-
由 Eileen M. Uchitelle 提交于
Resets the `ActiveRecord::Base` connection after `rails db:migrate:name`
-
由 Kyle Thompson 提交于
-
- 27 2月, 2020 5 次提交
-
-
由 Eileen M. Uchitelle 提交于
Remove unused argument
-
由 Ryuta Kamizono 提交于
Current code expect an `eq` node has one arel attribute at least, but an `eq` node may have no arel attribute (e.g. `Arel.sql("...").eq(...)`). In that case `unscope` will raise `NoMethodError`: ``` % bundle exec ruby -w -Itest test/cases/relations_test.rb -n test_unscope_with_arel_sql Using sqlite3 Run options: -n test_unscope_with_arel_sql --seed 4477 # Running: E Error: RelationTest#test_unscope_with_arel_sql: NoMethodError: undefined method `name' for #<Arel::Nodes::Quoted:0x00007f9938e55960> /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:157:in `block (2 levels) in except_predicates' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/arel.rb:57:in `fetch_attribute' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:157:in `block in except_predicates' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:156:in `reject' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:156:in `except_predicates' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:31:in `except' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:487:in `block (2 levels) in unscope!' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:481:in `each' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:481:in `block in unscope!' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:471:in `each' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:471:in `unscope!' /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:464:in `unscope' test/cases/relations_test.rb:2062:in `test_unscope_with_arel_sql' ``` We should check for both `value.left` and `value.right` those are arel attribute or not.
-
由 eileencodes 提交于
This was leftover in debugging we did to support `shard` in `connected_to`. We don't need this because `with_shard` already has access to `connection_specification_name` because they are in the same class.
-
由 Rafael França 提交于
Disallow calling `connected_to` on subclasses of `ActiveRecord::Base`
-
由 eileencodes 提交于
Behavior has not changed here but the previous API could be misleading to people who thought it would switch connections for only that class. `connected_to` switches the context from which we are getting connections, not the connections themselves. Co-authored-by: NJohn Crepezzi <john.crepezzi@gmail.com>
-
- 26 2月, 2020 3 次提交
-
-
由 John Hawthorn 提交于
Simplify fixture resolver
-
由 Eugene Kenny 提交于
Update some references to finder options [ci skip]
-
由 Gannon McGibbon 提交于
Use type attribute in ActionView::Helpers::JavaScriptHelper#javascript_tag example
-
- 25 2月, 2020 4 次提交
-
-
由 Ryuta Kamizono 提交于
https://gist.github.com/kamipo/296b9dd97f690d7960fdfe8de3ca08c7 Before: ``` ================================= All symbols ================================== Warming up -------------------------------------- assign_attributes 4.425k i/100ms Calculating ------------------------------------- assign_attributes 44.983k (± 2.8%) i/s - 225.675k in 5.020906s ==================================== Mixed ===================================== Warming up -------------------------------------- assign_attributes 4.546k i/100ms Calculating ------------------------------------- assign_attributes 46.103k (± 5.2%) i/s - 231.846k in 5.046489s ================================= All strings ================================== Warming up -------------------------------------- assign_attributes 4.511k i/100ms Calculating ------------------------------------- assign_attributes 47.931k (± 7.4%) i/s - 239.083k in 5.023971s ``` After: ``` ================================= All symbols ================================== Warming up -------------------------------------- assign_attributes 4.831k i/100ms Calculating ------------------------------------- assign_attributes 48.206k (± 8.5%) i/s - 241.550k in 5.058372s ==================================== Mixed ===================================== Warming up -------------------------------------- assign_attributes 4.960k i/100ms Calculating ------------------------------------- assign_attributes 50.628k (± 3.5%) i/s - 252.960k in 5.002779s ================================= All strings ================================== Warming up -------------------------------------- assign_attributes 5.006k i/100ms Calculating ------------------------------------- assign_attributes 52.242k (± 5.5%) i/s - 260.312k in 5.001695s ```
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
[ci skip]
-
由 Ryuta Kamizono 提交于
Before: ``` DEPRECATION WARNING: spec_name is deprecated and will be removed from Rails 6.2 (spec_name accessors are deprecated and will be removed in Rails 6.2, please use name instead.) ``` After: ``` DEPRECATION WARNING: spec_name is deprecated and will be removed from Rails 6.2 (please use name instead) ``` Follow up of #38536.
-