2023-10-29 13:32:39 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "rails_helper"
|
|
|
|
|
|
|
|
describe Comments::ReactionsController, type: :controller do
|
2023-10-29 13:48:41 -07:00
|
|
|
describe "#index" do
|
2023-10-29 13:32:39 -07:00
|
|
|
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
|
2023-10-29 13:48:41 -07:00
|
|
|
subject { get :index, params: { username: commenter.screen_name, id: comment.id } }
|
2023-10-29 13:32:39 -07:00
|
|
|
|
|
|
|
it "should redirect to the answer page" do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(response).to redirect_to answer_path(username: answer_author.screen_name, id: answer.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "a Turbo Frame request" do
|
2023-10-29 13:48:41 -07:00
|
|
|
subject { get :index, params: { username: commenter.screen_name, id: comment.id } }
|
2023-10-29 13:32:39 -07:00
|
|
|
|
2023-10-29 13:48:41 -07:00
|
|
|
it "renders the index template" do
|
2023-10-29 13:32:39 -07:00
|
|
|
@request.headers["Turbo-Frame"] = "some_id"
|
|
|
|
|
|
|
|
subject
|
|
|
|
|
2023-10-29 13:48:41 -07:00
|
|
|
expect(response).to render_template(:index)
|
2023-10-29 13:32:39 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|