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
Fix some more ignored block warnings #51608
Conversation
Ref: https://bugs.ruby-lang.org/issues/15554 A couple are harmless, but another couple found actual problems in the test suite where we passed blocks to `assert_*` methods that didn't expect one.
72f16ef
to
d5c88d6
Compare
@@ -502,12 +502,12 @@ def test_decorated_type_with_decorator_block | |||
klass = Class.new(ActiveRecord::Base) do | |||
self.table_name = Topic.table_name | |||
store :content, coder: ActiveRecord::Coders::JSON | |||
attribute(:content) { |subtype| EncryptedType.new(subtype: subtype) } | |||
attribute(:content, EncryptedType.new(subtype: Topic.attribute_types.fetch("content"))) |
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.
Is this required change? Actually this test case tests attribute
with a decorator block in accordance with its test name.
def test_decorated_type_with_decorator_block |
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.
Is this required change?
The attribute
method doesn't take a block and never yields. I'll go check if it did when this test was introduced, but I don't think it ever did. So this test was essentially a noop.
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.
Alright, this was changed in #44666.
So I think:
- This test should use
decorate_attributes
instead. attribute
should warn or raise when given a block, because that same issue may be present in users code.
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.
This internal feature and test was introduced in #41139 by me.
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.
Right, but as of #44666 it no longer exist. If it was never public API, then I suppose we don't need to warn or raise.
I updated the test to use the new API.
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.
Yeah, I didn't know that had been replaced to decorate_attributes
, thanks for the quick investigation!
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.
I updated the test to use the new API.
Somehow forgot to push... I'll open another PR.
Ref: https://bugs.ruby-lang.org/issues/15554
A couple are harmless, but another couple found actual problems in the test suite where we passed blocks to
assert_*
methods that didn't expect one.