mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #41839 from abhaynikam/fix-return-type-for-strict-loading
ActiveRecord#strict_loading! should return boolean instead of current mode set.
This commit is contained in:
commit
80a23227ea
2 changed files with 6 additions and 3 deletions
|
@ -765,8 +765,8 @@ module ActiveRecord
|
|||
raise ArgumentError, "The :mode option must be one of [:all, :n_plus_one_only]."
|
||||
end
|
||||
|
||||
@strict_loading = value
|
||||
@strict_loading_mode = mode
|
||||
@strict_loading = value
|
||||
end
|
||||
|
||||
# Returns +true+ if the record uses strict_loading with +:n_plus_one_only+ mode enabled.
|
||||
|
|
|
@ -19,19 +19,22 @@ class StrictLoadingTest < ActiveRecord::TestCase
|
|||
developer = Developer.first
|
||||
assert_not_predicate developer, :strict_loading?
|
||||
|
||||
developer.strict_loading!
|
||||
assert developer.strict_loading!
|
||||
assert_predicate developer, :strict_loading?
|
||||
|
||||
assert_raises ActiveRecord::StrictLoadingViolationError do
|
||||
developer.audit_logs.to_a
|
||||
end
|
||||
|
||||
developer.strict_loading!(false)
|
||||
assert_not developer.strict_loading!(false)
|
||||
assert_not_predicate developer, :strict_loading?
|
||||
|
||||
assert_nothing_raised do
|
||||
developer.audit_logs.to_a
|
||||
end
|
||||
|
||||
assert developer.strict_loading!(mode: :n_plus_one_only)
|
||||
assert developer.strict_loading_n_plus_one_only?
|
||||
end
|
||||
|
||||
def test_strict_loading_n_plus_one_only_mode
|
||||
|
|
Loading…
Reference in a new issue