From 4eb4851aba56dc3e9642221a6c5101df75a892b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= <15726+Senen@users.noreply.github.com> Date: Thu, 1 Sep 2022 12:52:23 +0200 Subject: [PATCH] Rename component as now it renders all question answers additional information --- ...onent.html.erb => read_more_component.html.erb} | 0 ..._answer_component.rb => read_more_component.rb} | 2 +- app/views/polls/show.html.erb | 2 +- ...mponent_spec.rb => read_more_component_spec.rb} | 14 +++++++------- 4 files changed, 9 insertions(+), 9 deletions(-) rename app/components/polls/questions/{read_more_answer_component.html.erb => read_more_component.html.erb} (100%) rename app/components/polls/questions/{read_more_answer_component.rb => read_more_component.rb} (75%) rename spec/components/polls/questions/{read_more_answer_component_spec.rb => read_more_component_spec.rb} (72%) diff --git a/app/components/polls/questions/read_more_answer_component.html.erb b/app/components/polls/questions/read_more_component.html.erb similarity index 100% rename from app/components/polls/questions/read_more_answer_component.html.erb rename to app/components/polls/questions/read_more_component.html.erb diff --git a/app/components/polls/questions/read_more_answer_component.rb b/app/components/polls/questions/read_more_component.rb similarity index 75% rename from app/components/polls/questions/read_more_answer_component.rb rename to app/components/polls/questions/read_more_component.rb index 81d868ab4..035cc2888 100644 --- a/app/components/polls/questions/read_more_answer_component.rb +++ b/app/components/polls/questions/read_more_component.rb @@ -1,4 +1,4 @@ -class Polls::Questions::ReadMoreAnswerComponent < ApplicationComponent +class Polls::Questions::ReadMoreComponent < ApplicationComponent with_collection_parameter :question attr_reader :question delegate :wysiwyg, to: :helpers diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index b911e3391..22f1fae32 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -46,7 +46,7 @@
- <%= render Polls::Questions::ReadMoreAnswerComponent.with_collection(@questions) %> + <%= render Polls::Questions::ReadMoreComponent.with_collection(@questions) %>
diff --git a/spec/components/polls/questions/read_more_answer_component_spec.rb b/spec/components/polls/questions/read_more_component_spec.rb similarity index 72% rename from spec/components/polls/questions/read_more_answer_component_spec.rb rename to spec/components/polls/questions/read_more_component_spec.rb index dff77db77..053bc5097 100644 --- a/spec/components/polls/questions/read_more_answer_component_spec.rb +++ b/spec/components/polls/questions/read_more_component_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -describe Polls::Questions::ReadMoreAnswerComponent do +describe Polls::Questions::ReadMoreComponent do include Rails.application.routes.url_helpers let(:poll) { create(:poll) } let(:question) { create(:poll_question, poll: poll, title: "Question title?") } @@ -9,7 +9,7 @@ describe Polls::Questions::ReadMoreAnswerComponent do it "renders question title" do create(:poll_question_answer, question: question, description: "Question answer description") - render_inline Polls::Questions::ReadMoreAnswerComponent.new(question: question) + render_inline Polls::Questions::ReadMoreComponent.new(question: question) expect(page).to have_content "Question title?" end @@ -18,7 +18,7 @@ describe Polls::Questions::ReadMoreAnswerComponent do create(:poll_question_answer, title: "Answer A", question: question, given_order: 2) create(:poll_question_answer, title: "Answer B", question: question, given_order: 1) - render_inline Polls::Questions::ReadMoreAnswerComponent.new(question: question) + render_inline Polls::Questions::ReadMoreComponent.new(question: question) expect("Answer B").to appear_before("Answer A") end @@ -26,7 +26,7 @@ describe Polls::Questions::ReadMoreAnswerComponent do it "does not render when answers does not have more information" do answer.update!(description: nil) - render_inline Polls::Questions::ReadMoreAnswerComponent.new(question: question) + render_inline Polls::Questions::ReadMoreComponent.new(question: question) expect(page).not_to be_rendered end @@ -34,7 +34,7 @@ describe Polls::Questions::ReadMoreAnswerComponent do it "renders answers with videos" do create(:poll_answer_video, answer: answer, title: "Awesome video", url: "youtube.com/watch?v=123") - render_inline Polls::Questions::ReadMoreAnswerComponent.new(question: question) + render_inline Polls::Questions::ReadMoreComponent.new(question: question) expect(page).to have_link("Awesome video", href: "youtube.com/watch?v=123") end @@ -42,7 +42,7 @@ describe Polls::Questions::ReadMoreAnswerComponent do it "renders answers with images" do create(:image, imageable: answer, title: "The yes movement") - render_inline Polls::Questions::ReadMoreAnswerComponent.new(question: question) + render_inline Polls::Questions::ReadMoreComponent.new(question: question) expect(page).to have_css "img[alt='The yes movement']" end @@ -50,7 +50,7 @@ describe Polls::Questions::ReadMoreAnswerComponent do it "renders answers with documents" do create(:document, documentable: answer, title: "The yes movement") - render_inline Polls::Questions::ReadMoreAnswerComponent.new(question: question) + render_inline Polls::Questions::ReadMoreComponent.new(question: question) expect(page).to have_link("The yes movement") end