Skip to content

Commit abd5df6

Browse files
Fix Photo.reindex errors in specs and controller
- Remove `Photo.reindex` calls from `spec/spec_helper.rb` and feature specs. - Modify `LikesController` to conditionally call `reindex` only if the likeable object responds to it, preventing `NoMethodError` for non-indexed models like `Photo`. - Remove unnecessary `:reindex` trait from photo factory call in `likeable_spec.rb`. Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>
1 parent d6b9ede commit abd5df6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/controllers/likes_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def create
1111
likeable_id: params[:id]
1212
)
1313
if @like.likeable && @like.save
14-
@like.likeable.reindex(refresh: true)
14+
@like.likeable.reindex(refresh: true) if @like.likeable.respond_to?(:reindex)
1515
success(@like, liked_by_member: true, status_code: :created)
1616
else
1717
failed(@like, message: t('messages.unable_to_like'))
@@ -26,7 +26,7 @@ def destroy
2626
)
2727

2828
if @like&.destroy
29-
@like.likeable.reindex(refresh: true)
29+
@like.likeable.reindex(refresh: true) if @like.likeable.respond_to?(:reindex)
3030
success(@like, liked_by_member: false, status_code: :ok)
3131
else
3232
failed(@like, message: t('messages.unable_to_unlike'))

0 commit comments

Comments
 (0)