Rename `#show` to `#index` action for comment reactions

This commit is contained in:
Andreas Nedbal 2023-10-29 21:48:41 +01:00
parent 91716454c3
commit 5d093c621b
4 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class Comments::ReactionsController < ApplicationController class Comments::ReactionsController < ApplicationController
def show def index
comment = Comment.find(params[:id]) comment = Comment.find(params[:id])
@reactions = Reaction.where(parent_type: "Comment", parent: comment.id).includes([{ user: :profile }]) @reactions = Reaction.where(parent_type: "Comment", parent: comment.id).includes([{ user: :profile }])

View File

@ -157,7 +157,7 @@ Rails.application.routes.draw do
get "/@:username/a/:id/comments", to: "comments#index", as: :comments get "/@:username/a/:id/comments", to: "comments#index", as: :comments
get "/@:username/a/:id/reactions", to: "reaction#index", as: :reactions get "/@:username/a/:id/reactions", to: "reaction#index", as: :reactions
get "/@:username/q/:id", to: "question#show", as: :question get "/@:username/q/:id", to: "question#show", as: :question
get "/@:username/c/:id/reactions", to: "comments/reactions#show", as: :comment_reactions get "/@:username/c/:id/reactions", to: "comments/reactions#index", as: :comment_reactions
get "/@:username/followers", to: "user#followers", as: :show_user_followers get "/@:username/followers", to: "user#followers", as: :show_user_followers
get "/@:username/followings", to: "user#followings", as: :show_user_followings get "/@:username/followings", to: "user#followings", as: :show_user_followings
get "/@:username/friends", to: redirect("/@%{username}/followings") get "/@:username/friends", to: redirect("/@%{username}/followings")

View File

@ -3,14 +3,14 @@
require "rails_helper" require "rails_helper"
describe Comments::ReactionsController, type: :controller do describe Comments::ReactionsController, type: :controller do
describe "#show" do describe "#index" do
let(:answer_author) { FactoryBot.create(:user) } let(:answer_author) { FactoryBot.create(:user) }
let(:answer) { FactoryBot.create(:answer, user: answer_author) } let(:answer) { FactoryBot.create(:answer, user: answer_author) }
let(:commenter) { FactoryBot.create(:user) } let(:commenter) { FactoryBot.create(:user) }
let(:comment) { FactoryBot.create(:comment, answer:, user: commenter) } let(:comment) { FactoryBot.create(:comment, answer:, user: commenter) }
context "a regular web navigation request" do context "a regular web navigation request" do
subject { get :show, params: { username: commenter.screen_name, id: comment.id } } subject { get :index, params: { username: commenter.screen_name, id: comment.id } }
it "should redirect to the answer page" do it "should redirect to the answer page" do
subject subject
@ -20,14 +20,14 @@ describe Comments::ReactionsController, type: :controller do
end end
context "a Turbo Frame request" do context "a Turbo Frame request" do
subject { get :show, params: { username: commenter.screen_name, id: comment.id } } subject { get :index, params: { username: commenter.screen_name, id: comment.id } }
it "renders the show_reaction template" do it "renders the index template" do
@request.headers["Turbo-Frame"] = "some_id" @request.headers["Turbo-Frame"] = "some_id"
subject subject
expect(response).to render_template(:show) expect(response).to render_template(:index)
end end
end end
end end