Move create question to admin poll questions
Also move question actions to admin polls questions
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
<h3><%= t("admin.polls.show.questions_title") %></h3>
|
||||
<h3 class="inline-block"><%= t("admin.polls.show.questions_title") %></h3>
|
||||
|
||||
<%= link_to t("admin.questions.index.create"), new_admin_question_path(poll_id: @poll.id),
|
||||
class: "button float-right" %>
|
||||
|
||||
<% if @poll.questions.empty? %>
|
||||
<div class="callout primary margin-top">
|
||||
@@ -9,6 +12,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.polls.show.table_title") %></th>
|
||||
<th class="small-6"><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% @poll.questions.each do |question| %>
|
||||
@@ -17,6 +21,20 @@
|
||||
<strong>
|
||||
<%= link_to question.title, admin_question_path(question) %>
|
||||
</strong>
|
||||
<td>
|
||||
<div class="small-4 column">
|
||||
<%= link_to t("admin.polls.show.edit_answers"), admin_question_path(question),
|
||||
class: "button hollow expanded" %>
|
||||
</div>
|
||||
<div class="small-4 column">
|
||||
<%= link_to t("shared.edit"), edit_admin_question_path(question),
|
||||
class: "button hollow expanded" %>
|
||||
</div>
|
||||
<div class="small-4 column">
|
||||
<%= link_to t("shared.delete"), admin_question_path(question),
|
||||
class: "button hollow alert expanded",
|
||||
method: :delete %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -7,13 +7,19 @@
|
||||
<%= f.hidden_field :proposal_id %>
|
||||
|
||||
<div class="small-12">
|
||||
<div class="small-12 medium-6 large-4">
|
||||
<% select_options = Poll.all.map { |p| [p.name, p.id] } %>
|
||||
<%= f.select :poll_id,
|
||||
options_for_select(select_options),
|
||||
prompt: t("admin.questions.index.select_poll"),
|
||||
label: t("admin.questions.new.poll_label") %>
|
||||
</div>
|
||||
<% if @poll.present? %>
|
||||
<%= f.hidden_field :poll_id, value: @poll.id %>
|
||||
<% elsif @question.poll.present? %>
|
||||
<%= f.hidden_field :poll_id, value: @question.poll.id %>
|
||||
<% else %>
|
||||
<div class="small-12 medium-6 large-4">
|
||||
<% select_options = Poll.all.map { |p| [p.name, p.id] } %>
|
||||
<%= f.select :poll_id,
|
||||
options_for_select(select_options),
|
||||
prompt: t("admin.questions.index.select_poll"),
|
||||
label: t("admin.questions.new.poll_label") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= f.translatable_fields do |translations_form| %>
|
||||
<%= translations_form.text_field :title %>
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
<%= back_link_to %>
|
||||
|
||||
<h2 class="margin-top"><%= t("admin.questions.new.title") %></h2>
|
||||
<h2 class="margin-top">
|
||||
<% if @poll.present? %>
|
||||
<%= t("admin.questions.new.title", poll: @poll.name) %>
|
||||
<% else %>
|
||||
<%= t("admin.questions.new.title_proposal") %>
|
||||
<% end %>
|
||||
</h2>
|
||||
|
||||
<div class="poll-question-form">
|
||||
<%= render "form", form_url: admin_questions_path %>
|
||||
|
||||
@@ -974,6 +974,7 @@ en:
|
||||
no_questions: "There are no questions assigned to this poll."
|
||||
questions_title: "List of questions"
|
||||
table_title: "Title"
|
||||
edit_answers: Edit answers
|
||||
flash:
|
||||
question_added: "Question added to this poll"
|
||||
error_on_question_added: "Question could not be assigned to this poll"
|
||||
@@ -994,7 +995,8 @@ en:
|
||||
edit:
|
||||
title: "Edit Question"
|
||||
new:
|
||||
title: "Create Question"
|
||||
title: "Create question to poll %{poll}"
|
||||
title_proposal: "Create question"
|
||||
poll_label: "Poll"
|
||||
answers:
|
||||
images:
|
||||
|
||||
@@ -973,6 +973,7 @@ es:
|
||||
no_questions: "No hay preguntas asignadas a esta votación."
|
||||
questions_title: "Listado de preguntas asignadas"
|
||||
table_title: "Título"
|
||||
edit_answers: Editar respuestas
|
||||
flash:
|
||||
question_added: "Pregunta añadida a esta votación"
|
||||
error_on_question_added: "No se pudo asignar la pregunta"
|
||||
@@ -993,7 +994,8 @@ es:
|
||||
edit:
|
||||
title: "Editar pregunta ciudadana"
|
||||
new:
|
||||
title: "Crear pregunta ciudadana"
|
||||
title: "Crear pregunta ciudadana para la votación %{poll}"
|
||||
title_proposal: "Crear pregunta ciudadana"
|
||||
poll_label: "Votación"
|
||||
answers:
|
||||
images:
|
||||
|
||||
@@ -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