-
-
Notifications
You must be signed in to change notification settings - Fork 910
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
feat: Add have_delegated_type
matcher
#1606
Changes from 1 commit
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 |
---|---|---|
|
@@ -13,7 +13,11 @@ def initialize(reflection) | |
end | ||
|
||
def associated_class | ||
reflection.klass | ||
if polymorphic? | ||
subject | ||
else | ||
reflection.klass | ||
end | ||
Comment on lines
+16
to
+20
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. I'll wait to see what happens when running all the specs, but when the relation is polymorphic, the My solution was to return a valid ActiveRecord object(which in that case, I returned the subject itself) because this will be used only to grab the value of the |
||
end | ||
|
||
def polymorphic? | ||
|
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 is not great, but currently, there's no way to check the types besides doing that. A PR was merged recently, adding a
types
method to the object, which will greatly simplify this check. I will update this method once it is released in Rails.rails/rails#50662