Skip to content

Commit

Permalink
AO3-6686 Bring back polymorphic_path (#4919)
Browse files Browse the repository at this point in the history
* Bring back polymorphic_path

* Test fixes
  • Loading branch information
brianjaustin authored Sep 18, 2024
1 parent 7ab3c76 commit 9e0f981
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -666,16 +666,13 @@ def redirect_to_all_comments(commentable, options = {})
if commentable.is_a?(Chapter) && (options[:view_full_work] || current_user.try(:preference).try(:view_full_works))
commentable = commentable.work
end
redirect_to controller: commentable.class.to_s.underscore.pluralize,
action: :show,
id: commentable.id,
show_comments: options[:show_comments],
add_comment_reply_id: options[:add_comment_reply_id],
delete_comment_id: options[:delete_comment_id],
view_full_work: options[:view_full_work],
anchor: options[:anchor],
page: options[:page],
only_path: true
redirect_to polymorphic_path(commentable,
options.slice(:show_comments,
:add_comment_reply_id,
:delete_comment_id,
:view_full_work,
:anchor,
:page))
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@
post :create, params: { work_id: work.id, comment: comment_attributes }
comment = Comment.last
expect(flash[:error]).to be_nil
expect(response).to redirect_to(work_chapter_path(work, comment.commentable, show_comments: true, view_full_work: false, anchor: "comment_#{comment.id}"))
expect(response).to redirect_to(chapter_path(comment.commentable, show_comments: true, view_full_work: false, anchor: "comment_#{comment.id}"))
end
end
end
Expand Down

0 comments on commit 9e0f981

Please sign in to comment.