Rename trait with_answers to yes_no
We barely use this trait. In the votation type spec we're probably using it wrong, and in the answer spec we assume one of the answers is going to be "Yes". The name `yes_no` is more expressive, since it makes it clear what the answers are.
This commit is contained in:
@@ -41,8 +41,8 @@ FactoryBot.define do
|
||||
association :author, factory: :user
|
||||
sequence(:title) { |n| "Question title #{n}" }
|
||||
|
||||
trait :with_answers do
|
||||
after(:create) do |question, _evaluator|
|
||||
trait :yes_no do
|
||||
after(:create) do |question|
|
||||
create(:poll_question_answer, question: question, title: "Yes")
|
||||
create(:poll_question_answer, question: question, title: "No")
|
||||
end
|
||||
@@ -197,13 +197,13 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :poll_answer, class: "Poll::Answer" do
|
||||
association :question, factory: [:poll_question, :with_answers]
|
||||
association :question, factory: [:poll_question, :yes_no]
|
||||
association :author, factory: [:user, :level_two]
|
||||
answer { question.question_answers.sample.title }
|
||||
end
|
||||
|
||||
factory :poll_partial_result, class: "Poll::PartialResult" do
|
||||
association :question, factory: [:poll_question, :with_answers]
|
||||
association :question, factory: [:poll_question, :yes_no]
|
||||
association :author, factory: :user
|
||||
origin { "web" }
|
||||
answer { question.question_answers.sample.title }
|
||||
|
||||
@@ -419,8 +419,8 @@ describe "Stats" do
|
||||
|
||||
poll = create(:poll)
|
||||
|
||||
question1 = create(:poll_question, :with_answers, poll: poll)
|
||||
question2 = create(:poll_question, :with_answers, poll: poll)
|
||||
question1 = create(:poll_question, :yes_no, poll: poll)
|
||||
question2 = create(:poll_question, :yes_no, poll: poll)
|
||||
|
||||
create(:poll_answer, question: question1, author: user1)
|
||||
create(:poll_answer, question: question2, author: user1)
|
||||
|
||||
@@ -15,7 +15,7 @@ describe "Poll Votation Type" do
|
||||
end
|
||||
|
||||
scenario "response question without votation type" do
|
||||
question = create(:poll_question, :with_answers, poll: poll_current)
|
||||
question = create(:poll_question, :yes_no, poll: poll_current)
|
||||
visit poll_path(poll_current)
|
||||
|
||||
expect(page).to have_content(question.title)
|
||||
|
||||
@@ -43,7 +43,7 @@ describe Poll::Answer do
|
||||
|
||||
let(:author) { create(:user, :level_two) }
|
||||
let(:poll) { create(:poll) }
|
||||
let(:question) { create(:poll_question, :with_answers, poll: poll) }
|
||||
let(:question) { create(:poll_question, :yes_no, poll: poll) }
|
||||
|
||||
it "creates a poll_voter with user and poll data" do
|
||||
answer = create(:poll_answer, question: question, author: author, answer: "Yes")
|
||||
|
||||
Reference in New Issue
Block a user