Move create question to admin poll questions
Also move question actions to admin polls questions
This commit is contained in:
@@ -17,16 +17,24 @@ feature "Admin poll questions" do
|
||||
question1 = create(:poll_question, poll: poll1)
|
||||
question2 = create(:poll_question, poll: poll2)
|
||||
|
||||
visit admin_questions_path
|
||||
visit admin_poll_path(poll1)
|
||||
expect(page).to have_content(poll1.name)
|
||||
|
||||
within("#poll_question_#{question1.id}") do
|
||||
expect(page).to have_content(question1.title)
|
||||
expect(page).to have_content(poll1.name)
|
||||
expect(page).to have_content("Edit answers")
|
||||
expect(page).to have_content("Edit")
|
||||
expect(page).to have_content("Delete")
|
||||
end
|
||||
|
||||
visit admin_poll_path(poll2)
|
||||
expect(page).to have_content(poll2.name)
|
||||
|
||||
within("#poll_question_#{question2.id}") do
|
||||
expect(page).to have_content(question2.title)
|
||||
expect(page).to have_content(poll2.name)
|
||||
expect(page).to have_content("Edit answers")
|
||||
expect(page).to have_content("Edit")
|
||||
expect(page).to have_content("Delete")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +43,8 @@ feature "Admin poll questions" do
|
||||
poll = create(:poll, geozone_restricted: true, geozone_ids: [geozone.id])
|
||||
question = create(:poll_question, poll: poll)
|
||||
|
||||
visit admin_question_path(question)
|
||||
visit admin_poll_path(poll)
|
||||
click_link "#{question.title}"
|
||||
|
||||
expect(page).to have_content(question.title)
|
||||
expect(page).to have_content(question.author.name)
|
||||
@@ -44,17 +53,13 @@ feature "Admin poll questions" do
|
||||
scenario "Create" do
|
||||
poll = create(:poll, name: "Movies")
|
||||
title = "Star Wars: Episode IV - A New Hope"
|
||||
description = %{
|
||||
During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station
|
||||
with enough power to destroy an entire planet.
|
||||
Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her
|
||||
people and restore freedom to the galaxy....
|
||||
}
|
||||
|
||||
visit admin_questions_path
|
||||
visit admin_poll_path(poll)
|
||||
click_link "Create question"
|
||||
|
||||
select "Movies", from: "poll_question_poll_id"
|
||||
expect(page).to have_content("Create question to poll Movies")
|
||||
expect(page).to have_selector("input[id='poll_question_poll_id'][value='#{poll.id}']",
|
||||
visible: false)
|
||||
fill_in "Question", with: title
|
||||
|
||||
click_button "Save"
|
||||
@@ -101,9 +106,11 @@ feature "Admin poll questions" do
|
||||
end
|
||||
|
||||
scenario "Update" do
|
||||
question1 = create(:poll_question)
|
||||
poll = create(:poll)
|
||||
question1 = create(:poll_question, poll: poll)
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
visit admin_questions_path
|
||||
within("#poll_question_#{question1.id}") do
|
||||
click_link "Edit"
|
||||
end
|
||||
@@ -116,18 +123,15 @@ feature "Admin poll questions" do
|
||||
|
||||
expect(page).to have_content "Changes saved"
|
||||
expect(page).to have_content new_title
|
||||
|
||||
visit admin_questions_path
|
||||
|
||||
expect(page).to have_content(new_title)
|
||||
expect(page).not_to have_content(old_title)
|
||||
end
|
||||
|
||||
scenario "Destroy" do
|
||||
question1 = create(:poll_question)
|
||||
question2 = create(:poll_question)
|
||||
poll = create(:poll)
|
||||
question1 = create(:poll_question, poll: poll)
|
||||
question2 = create(:poll_question, poll: poll)
|
||||
|
||||
visit admin_questions_path
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
within("#poll_question_#{question1.id}") do
|
||||
click_link "Delete"
|
||||
@@ -141,29 +145,20 @@ feature "Admin poll questions" do
|
||||
|
||||
context "Poll select box" do
|
||||
|
||||
let(:poll) { create(:poll, name_en: "Name in English",
|
||||
name_es: "Nombre en Español",
|
||||
summary_en: "Summary in English",
|
||||
summary_es: "Resumen en Español",
|
||||
description_en: "Description in English",
|
||||
description_es: "Descripción en Español") }
|
||||
|
||||
let(:question) { create(:poll_question, poll: poll,
|
||||
title_en: "Question in English",
|
||||
title_es: "Pregunta en Español") }
|
||||
|
||||
before do
|
||||
@edit_question_url = edit_admin_question_path(question)
|
||||
end
|
||||
|
||||
scenario "translates the poll name in options", :js do
|
||||
visit @edit_question_url
|
||||
|
||||
expect(page).to have_select("poll_question_poll_id", options: [poll.name_en])
|
||||
poll = create(:poll, name_en: "Name in English", name_es: "Nombre en Español")
|
||||
proposal = create(:proposal)
|
||||
|
||||
visit admin_proposal_path(proposal)
|
||||
click_link "Add this proposal to a poll to be voted"
|
||||
|
||||
expect(page).to have_select("poll_question_poll_id", options: ["Select Poll", poll.name_en])
|
||||
|
||||
select("Español", from: "locale-switcher")
|
||||
|
||||
expect(page).to have_select("poll_question_poll_id", options: [poll.name_es])
|
||||
expect(page).to have_select("poll_question_poll_id",
|
||||
options: ["Seleccionar votación", poll.name_es])
|
||||
end
|
||||
|
||||
scenario "uses fallback if name is not translated to current locale", :js do
|
||||
@@ -171,13 +166,18 @@ feature "Admin poll questions" do
|
||||
skip("Spec only useful when French falls back to Spanish")
|
||||
end
|
||||
|
||||
visit @edit_question_url
|
||||
poll = create(:poll, name_en: "Name in English", name_es: "Nombre en Español")
|
||||
proposal = create(:proposal)
|
||||
|
||||
expect(page).to have_select("poll_question_poll_id", options: [poll.name_en])
|
||||
visit admin_proposal_path(proposal)
|
||||
click_link "Add this proposal to a poll to be voted"
|
||||
|
||||
expect(page).to have_select("poll_question_poll_id", options: ["Select Poll", poll.name_en])
|
||||
|
||||
select("Français", from: "locale-switcher")
|
||||
|
||||
expect(page).to have_select("poll_question_poll_id", options: [poll.name_es])
|
||||
expect(page).to have_select("poll_question_poll_id",
|
||||
options: ["Sélectionner un vote", poll.name_es])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user