diff --git a/app/controllers/admin/poll/answers_controller.rb b/app/controllers/admin/poll/answers_controller.rb
index f949ad115..5650ab773 100644
--- a/app/controllers/admin/poll/answers_controller.rb
+++ b/app/controllers/admin/poll/answers_controller.rb
@@ -11,7 +11,8 @@ class Admin::Poll::AnswersController < Admin::Poll::BaseController
@answer = Poll::QuestionAnswer.new(answer_params)
if @answer.save
- redirect_to admin_question_path(@question)
+ redirect_to admin_question_path(@question),
+ notice: t("flash.actions.create.poll_question_answer")
else
render :new
end
diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb
index 1502c8357..7037afd5f 100644
--- a/app/views/admin/poll/questions/show.html.erb
+++ b/app/views/admin/poll/questions/show.html.erb
@@ -26,21 +26,27 @@
- | <%= t('admin.questions.show.valid_answers') %> |
- <%= link_to t("admin.questions.show.add_answer"), new_admin_question_answer_path(@question), class: "button hollow float-right" %> |
+
+ <%= t('admin.questions.show.valid_answers') %>
+ |
+
+ <%= link_to t("admin.questions.show.add_answer"),
+ new_admin_question_answer_path(@question),
+ class: "button hollow float-right" %>
+ |
- | <%= t("admin.questions.show.answer") %> |
- <%= t("admin.questions.show.description") %> |
+ <%= t("admin.questions.show.answers.title") %> |
+ <%= t("admin.questions.show.answers.description") %> |
-
- <% @question.question_answers.each do |answer| %>
+ <% @question.question_answers.each do |answer| %>
+
| <%= answer.title %> |
<%= answer.description %> |
- <% end %>
-
+
+ <% end %>
<% if @question.video_url.present? %>
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index fc7082edf..cf92d0cba 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -593,10 +593,12 @@ en:
title: Title
valid_answers: Valid answers
add_answer: "Add answer"
- answer: "Answer"
description: Description
video_url: External video
documents: Documents (1)
+ answers:
+ title: Answer
+ description: Description
answers:
new:
title: "New answer"
diff --git a/config/locales/en/responders.yml b/config/locales/en/responders.yml
index 203d5700e..fd187c495 100644
--- a/config/locales/en/responders.yml
+++ b/config/locales/en/responders.yml
@@ -8,6 +8,7 @@ en:
direct_message: "You message has been sent successfully."
poll: "Poll created successfully."
poll_booth: "Booth created successfully."
+ poll_question_answer: "Answer created successfully"
proposal: "Proposal created successfully."
proposal_notification: "Your message has been sent correctly."
spending_proposal: "Spending proposal created successfully. You can access it from %{activity}"
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index 818e3c569..ed4e2f87b 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -593,11 +593,13 @@ es:
title: Título
valid_answers: Respuestas válidas
add_answer: "Añadir respuesta"
- answer: "Respuesta"
description: Descripción
video_url: Video externo
documents: Documentos (1)
preview: Ver en la web
+ answers:
+ title: Respuesta
+ description: Descripción
answers:
new:
title: "Nueva respuesta"
diff --git a/config/locales/es/responders.yml b/config/locales/es/responders.yml
index 74e3ea20a..a35387ff3 100644
--- a/config/locales/es/responders.yml
+++ b/config/locales/es/responders.yml
@@ -8,6 +8,7 @@ es:
direct_message: "Tu mensaje ha sido enviado correctamente."
poll: "Votación creada correctamente."
poll_booth: "Urna creada correctamente."
+ poll_question_answer: "Respuesta creada correctamente"
proposal: "Propuesta creada correctamente."
proposal_notification: "Tu message ha sido enviado correctamente."
spending_proposal: "Propuesta de inversión creada correctamente. Puedes acceder a ella desde %{activity}"
diff --git a/spec/factories.rb b/spec/factories.rb
index 9f1fca8ed..640b50bf2 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -501,6 +501,12 @@ FactoryGirl.define do
valid_answers { Faker::Lorem.words(3).join(', ') }
end
+ factory :poll_question_answer, class: 'Poll::QuestionAnswer' do
+ association :question, factory: :poll_question
+ sequence(:title) { |n| "Question title #{n}" }
+ sequence(:description) { |n| "Question description #{n}" }
+ end
+
factory :poll_booth, class: 'Poll::Booth' do
sequence(:name) { |n| "Booth #{n}" }
sequence(:location) { |n| "Street #{n}" }
diff --git a/spec/features/polls/answers_spec.rb b/spec/features/polls/answers_spec.rb
new file mode 100644
index 000000000..5b1091134
--- /dev/null
+++ b/spec/features/polls/answers_spec.rb
@@ -0,0 +1,41 @@
+require 'rails_helper'
+
+feature 'Answers' do
+
+ background do
+ admin = create(:administrator)
+ login_as(admin.user)
+ end
+
+ scenario "Index" do
+ question = create(:poll_question)
+ answer1 = create(:poll_question_answer, question: question)
+ answer2 = create(:poll_question_answer, question: question)
+
+ visit admin_question_path(question)
+
+ expect(page).to have_css(".poll_question_answer", count: 2)
+
+ within("#poll_question_answer_#{answer1.id}") do
+ expect(page).to have_content answer1.title
+ expect(page).to have_content answer1.description
+ end
+ end
+
+ scenario "Create" do
+ question = create(:poll_question)
+
+ visit admin_question_path(question)
+
+ click_link "Add answer"
+ fill_in "poll_question_answer_title", with: "¿Would you like to reform Central Park?"
+ fill_in "poll_question_answer_description", with: "Adding more trees, creating a play area..."
+ click_button "Save"
+
+ expect(page).to have_content "Answer created successfully"
+ end
+
+ pending "Update"
+ pending "Destroy"
+
+end
\ No newline at end of file