New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opting out of strict loading on a per-record base #41181
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,13 @@ def test_strict_loading! | |
assert_raises ActiveRecord::StrictLoadingViolationError do | ||
developer.audit_logs.to_a | ||
end | ||
|
||
developer.strict_loading!(false) | ||
assert_not_predicate developer, :strict_loading? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add an assertion that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 8223023 |
||
|
||
assert_nothing_raised do | ||
developer.audit_logs.to_a | ||
end | ||
end | ||
|
||
def test_strict_loading | ||
|
@@ -147,6 +154,10 @@ def test_eager_load_audit_logs_are_strict_loading_because_parent_is_strict_loadi | |
dev = Developer.eager_load(:strict_loading_audit_logs).first | ||
|
||
assert dev.strict_loading_audit_logs.all?(&:strict_loading?), "Expected all audit logs to be strict_loading" | ||
|
||
dev = Developer.eager_load(:strict_loading_audit_logs).strict_loading(false).first | ||
|
||
assert dev.audit_logs.none?(&:strict_loading?), "Expected no audit logs to be strict_loading" | ||
end | ||
|
||
def test_eager_load_audit_logs_are_strict_loading_because_parent_is_strict_loading | ||
|
@@ -160,6 +171,11 @@ def test_eager_load_audit_logs_are_strict_loading_because_parent_is_strict_loadi | |
|
||
assert_predicate dev, :strict_loading? | ||
assert dev.audit_logs.all?(&:strict_loading?), "Expected all audit logs to be strict_loading" | ||
|
||
dev = Developer.eager_load(:audit_logs).strict_loading(false).first | ||
|
||
assert_not_predicate dev, :strict_loading? | ||
assert dev.audit_logs.none?(&:strict_loading?), "Expected no audit logs to be strict_loading" | ||
end | ||
|
||
def test_eager_load_audit_logs_are_strict_loading_because_it_is_strict_loading_by_default | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user.strict_loading!(false)