-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add read more links to poll question component
- Loading branch information
Showing
5 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
spec/components/polls/questions/question_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require "rails_helper" | ||
|
||
describe Polls::Questions::QuestionComponent do | ||
it "renders more information links when any question answer has additional information" do | ||
question = create(:poll_question) | ||
answer_a = create(:poll_question_answer, question: question, title: "Answer A") | ||
answer_b = create(:poll_question_answer, question: question, title: "Answer B") | ||
allow_any_instance_of(Poll::Question::Answer).to receive(:with_read_more?).and_return(true) | ||
|
||
render_inline Polls::Questions::QuestionComponent.new(question: question) | ||
|
||
poll_question = page.find("#poll_question_#{question.id}") | ||
expect(poll_question).to have_content("Read more about") | ||
expect(poll_question).to have_link("Answer A", href: "#answer_#{answer_a.id}") | ||
expect(poll_question).to have_link("Answer B", href: "#answer_#{answer_b.id}") | ||
expect(poll_question).to have_content("Answer A, Answer B") | ||
end | ||
end |