From 5d093c621bfeeeea55a67ecb18954fdc7b9eeb0e Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 29 Oct 2023 21:48:41 +0100 Subject: [PATCH] Rename `#show` to `#index` action for comment reactions --- app/controllers/comments/reactions_controller.rb | 2 +- .../reactions/{show.html.haml => index.html.haml} | 0 config/routes.rb | 2 +- spec/controllers/comments/reactions_controller_spec.rb | 10 +++++----- 4 files changed, 7 insertions(+), 7 deletions(-) rename app/views/comments/reactions/{show.html.haml => index.html.haml} (100%) diff --git a/app/controllers/comments/reactions_controller.rb b/app/controllers/comments/reactions_controller.rb index 11ca6726..0efe2c2a 100644 --- a/app/controllers/comments/reactions_controller.rb +++ b/app/controllers/comments/reactions_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Comments::ReactionsController < ApplicationController - def show + def index comment = Comment.find(params[:id]) @reactions = Reaction.where(parent_type: "Comment", parent: comment.id).includes([{ user: :profile }]) diff --git a/app/views/comments/reactions/show.html.haml b/app/views/comments/reactions/index.html.haml similarity index 100% rename from app/views/comments/reactions/show.html.haml rename to app/views/comments/reactions/index.html.haml diff --git a/config/routes.rb b/config/routes.rb index 906e2ff6..57e9e243 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -157,7 +157,7 @@ Rails.application.routes.draw do get "/@:username/a/:id/comments", to: "comments#index", as: :comments get "/@:username/a/:id/reactions", to: "reaction#index", as: :reactions 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/followings", to: "user#followings", as: :show_user_followings get "/@:username/friends", to: redirect("/@%{username}/followings") diff --git a/spec/controllers/comments/reactions_controller_spec.rb b/spec/controllers/comments/reactions_controller_spec.rb index 2c4dbb4e..083b89b5 100644 --- a/spec/controllers/comments/reactions_controller_spec.rb +++ b/spec/controllers/comments/reactions_controller_spec.rb @@ -3,14 +3,14 @@ require "rails_helper" describe Comments::ReactionsController, type: :controller do - describe "#show" do + describe "#index" do let(:answer_author) { FactoryBot.create(:user) } let(:answer) { FactoryBot.create(:answer, user: answer_author) } let(:commenter) { FactoryBot.create(:user) } let(:comment) { FactoryBot.create(:comment, answer:, user: commenter) } 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 subject @@ -20,14 +20,14 @@ describe Comments::ReactionsController, type: :controller do end 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" subject - expect(response).to render_template(:show) + expect(response).to render_template(:index) end end end