-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new poll sample with all kind of questions
- Loading branch information
Showing
3 changed files
with
35 additions
and
275 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 was deleted.
Oops, something went wrong.
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,34 @@ | ||
require_dependency "poll/answer" | ||
require_dependency "poll/question/answer" | ||
|
||
section "Creating surveys" do | ||
name = "Testing all kind of questions" | ||
poll = Poll.create!(name: name, | ||
slug: name.parameterize, | ||
starts_at: 7.days.ago, | ||
ends_at: 1.year.from_now, | ||
geozone_restricted: false) | ||
|
||
author = Administrator.first.user | ||
|
||
Poll::Question.create!(title: "Open answer question (Optional)", poll: poll, kind: :open_answer, mandatory_answer: false, author: author) | ||
Poll::Question.create!(title: "Open answer question (Required)", poll: poll, kind: :open_answer, mandatory_answer: true, author: author) | ||
|
||
question = Poll::Question.create!(title: "Single choice question (Optional)", poll: poll, kind: :single_choice, mandatory_answer: false, author: author) | ||
%w[A B C].each_with_index do |option, index| | ||
Poll::Question::Answer.create!(title: "Single choice question answer #{option}", question: question, given_order: index + 1) | ||
end | ||
question = Poll::Question.create!(title: "Single choice question (Required)", poll: poll, kind: :single_choice, mandatory_answer: true, author: author) | ||
%w[A B C].each_with_index do |option, index| | ||
Poll::Question::Answer.create!(title: "Single choice question answer #{option}", question: question, given_order: index + 1) | ||
end | ||
|
||
question = Poll::Question.create!(title: "Multiple choice question (Optional)", poll: poll, kind: :multiple_choice, mandatory_answer: false, author: author) | ||
%w[X Y W Z].each_with_index do |option, index| | ||
Poll::Question::Answer.create!(title: "Multiple choice question answer #{option}", question: question, given_order: index + 1) | ||
end | ||
question = Poll::Question.create!(title: "Multiple choice question (Required)", poll: poll, kind: :multiple_choice, mandatory_answer: true, author: author) | ||
%w[X Y W Z].each_with_index do |option, index| | ||
Poll::Question::Answer.create!(title: "Multiple choice question answer #{option}", question: question, given_order: index + 1) | ||
end | ||
end |