Add support for open-ended questions in admin section
Introduce a new "open" votation type for poll questions in the admin interface. This type allows open answers provided by the user.
This commit is contained in:
@@ -81,6 +81,8 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).to have_content "It's only possible to answer one time to the question."
|
||||
expect(page).not_to have_content "Allows to choose multiple answers."
|
||||
expect(page).not_to have_field "Maximum number of votes"
|
||||
expect(page).not_to have_content "Open-ended question that allows users to provide " \
|
||||
"a single answer in their own words."
|
||||
|
||||
click_button "Save"
|
||||
|
||||
@@ -94,6 +96,8 @@ describe "Admin poll questions", :admin do
|
||||
|
||||
expect(page).not_to have_content "It's only possible to answer one time to the question."
|
||||
expect(page).to have_content "Allows to choose multiple answers."
|
||||
expect(page).not_to have_content "Open-ended question that allows users to provide " \
|
||||
"a single answer in their own words."
|
||||
|
||||
fill_in "Maximum number of votes", with: 6
|
||||
click_button "Save"
|
||||
@@ -101,6 +105,21 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).to have_content "Question with multiple answers"
|
||||
expect(page).to have_content "Multiple answers"
|
||||
end
|
||||
|
||||
scenario "Open-ended" do
|
||||
fill_in "Question", with: "What do you want?"
|
||||
select "Open-ended", from: "Votation type"
|
||||
|
||||
expect(page).not_to have_content "Allows to choose multiple answers."
|
||||
expect(page).not_to have_field "Maximum number of votes"
|
||||
expect(page).to have_content "Open-ended question that allows users to provide " \
|
||||
"a single answer in their own words."
|
||||
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content "What do you want?"
|
||||
expect(page).to have_content "Open-ended"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -143,7 +162,7 @@ describe "Admin poll questions", :admin do
|
||||
|
||||
scenario "Update" do
|
||||
poll = create(:poll, :future)
|
||||
question = create(:poll_question, poll: poll)
|
||||
question = create(:poll_question_open, poll: poll)
|
||||
old_title = question.title
|
||||
new_title = "Vegetables are great and everyone should have one"
|
||||
|
||||
@@ -154,6 +173,12 @@ describe "Admin poll questions", :admin do
|
||||
end
|
||||
|
||||
expect(page).to have_link "Go back", href: admin_poll_path(poll)
|
||||
expect(page).to have_select "Votation type", selected: "Open-ended"
|
||||
expect(page).not_to have_content "Allows to choose multiple answers."
|
||||
expect(page).not_to have_field "Maximum number of votes"
|
||||
expect(page).to have_content "Open-ended question that allows users to provide " \
|
||||
"a single answer in their own words."
|
||||
|
||||
fill_in "Question", with: new_title
|
||||
|
||||
click_button "Save"
|
||||
|
||||
Reference in New Issue
Block a user