Skip to content
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

Merged
merged 1 commit into from Apr 19, 2024
Merged

Conversation

casperisfine
Copy link
Contributor

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.

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.
@@ -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")))
Copy link
Member

@kamipo kamipo Apr 19, 2024

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

cc @jonathanhefner

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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!

Copy link
Contributor Author

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.

@byroot byroot merged commit cbf0046 into rails:main Apr 19, 2024
2 of 3 checks passed
casperisfine pushed a commit to Shopify/rails that referenced this pull request Apr 22, 2024
casperisfine pushed a commit to Shopify/rails that referenced this pull request Apr 22, 2024
casperisfine pushed a commit to Shopify/rails that referenced this pull request Apr 22, 2024
casperisfine pushed a commit to Shopify/rails that referenced this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants