- <% if can?(:create, Poll::Question::Answer.new(question: @question)) %>
- <%= link_to t("admin.questions.show.add_answer"), new_admin_question_answer_path(@question),
+ <% if can?(:create, Poll::Question::Option.new(question: @question)) %>
+ <%= link_to t("admin.questions.show.add_answer"), new_admin_question_option_path(@question),
class: "button float-right" %>
<% else %>
diff --git a/app/views/dashboard/polls/_question_answer_fields.html.erb b/app/views/dashboard/polls/_question_option_fields.html.erb
similarity index 100%
rename from app/views/dashboard/polls/_question_answer_fields.html.erb
rename to app/views/dashboard/polls/_question_option_fields.html.erb
diff --git a/app/views/officing/results/index.html.erb b/app/views/officing/results/index.html.erb
index 1f689e07a..2b2d8ef15 100644
--- a/app/views/officing/results/index.html.erb
+++ b/app/views/officing/results/index.html.erb
@@ -39,11 +39,11 @@
diff --git a/app/views/officing/results/new.html.erb b/app/views/officing/results/new.html.erb
index 06f49a251..86330cbc7 100644
--- a/app/views/officing/results/new.html.erb
+++ b/app/views/officing/results/new.html.erb
@@ -16,7 +16,7 @@
- <% question.question_answers.each_with_index do |answer, i| %>
+ <% question.question_options.each_with_index do |answer, i| %>
<%= text_field_tag "questions[#{question.id}][#{i}]", answer_result_value(question.id, i), placeholder: "0" %>
diff --git a/app/views/polls/questions/answers.js.erb b/app/views/polls/questions/options.js.erb
similarity index 56%
rename from app/views/polls/questions/answers.js.erb
rename to app/views/polls/questions/options.js.erb
index 2c4380238..f906184a5 100644
--- a/app/views/polls/questions/answers.js.erb
+++ b/app/views/polls/questions/options.js.erb
@@ -1 +1 @@
-$("#<%= dom_id(@question) %>_answers").html("<%= j render Polls::Questions::AnswersComponent.new(@question) %>");
+$("#<%= dom_id(@question) %>_answers").html("<%= j render Polls::Questions::OptionsComponent.new(@question) %>");
diff --git a/config/initializers/routes_hierarchy.rb b/config/initializers/routes_hierarchy.rb
index 298805088..fc9eac7f0 100644
--- a/config/initializers/routes_hierarchy.rb
+++ b/config/initializers/routes_hierarchy.rb
@@ -25,8 +25,8 @@ module ActionDispatch::Routing::UrlFor
def namespaced_polymorphic_path(namespace, resource, options = {})
if %w[Budget::Group Budget::Heading Legislation::DraftVersion Legislation::Question
- Poll::Booth Poll::BoothAssignment Poll::Officer Poll::Question Poll::Question::Answer
- Poll::Question::Answer::Video Poll::Shift SDG::LocalTarget].include?(resource.class.name)
+ Poll::Booth Poll::BoothAssignment Poll::Officer Poll::Question Poll::Question::Option
+ Poll::Question::Option::Video Poll::Shift SDG::LocalTarget].include?(resource.class.name)
resolve = resolve_for(resource)
resolve_options = resolve.pop
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index 787eaabf7..43397129f 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -459,13 +459,13 @@ en:
image:
title: Title
attachment: "Choose image"
- poll/question/answer:
+ poll/question/option:
title: Answer
description: Description
- poll/question/answer/translation:
+ poll/question/option/translation:
title: Answer
description: "Description (optional)"
- poll/question/answer/video:
+ poll/question/option/video:
title: Title
url: External video
newsletter:
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index 50d61d52e..3137ea334 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -162,7 +162,7 @@ en:
legislation/process: process
legislation/question: question
poll/shift: Shift
- poll/question/answer: Answer
+ poll/question/option: Answer
user: Account
verification/sms: phone
signature_sheet: Signature sheet
diff --git a/config/locales/en/responders.yml b/config/locales/en/responders.yml
index b4d2799ce..550a5b9f1 100644
--- a/config/locales/en/responders.yml
+++ b/config/locales/en/responders.yml
@@ -7,9 +7,9 @@ en:
direct_message: "You message has been sent successfully."
poll: "Poll created successfully."
poll_booth: "Booth created successfully."
- poll_question_answer: "Answer created successfully"
- poll_question_answer_video: "Video created successfully"
- poll_question_answer_image: "Image uploaded successfully"
+ poll_question_option: "Answer created successfully"
+ poll_question_option_video: "Video created successfully"
+ poll_question_option_image: "Image uploaded successfully"
proposal: "Proposal created successfully."
proposal_notification: "Your message has been sent correctly."
budget_investment: "Budget Investment created successfully."
@@ -34,7 +34,7 @@ en:
destroy:
budget_investment: "Investment project deleted successfully."
topic: "Topic deleted successfully."
- poll_question_answer_image: "Image deleted successfully."
- poll_question_answer_video: "Answer video deleted successfully."
+ poll_question_option_image: "Image deleted successfully."
+ poll_question_option_video: "Answer video deleted successfully."
valuator_group: "Valuator group deleted successfully"
vote: "Vote deleted successfully"
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index a9fc0a0e8..4aa224ae7 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -459,13 +459,13 @@ es:
image:
title: Título
attachment: "Selecciona una imagen"
- poll/question/answer:
+ poll/question/option:
title: Respuesta
description: Descripción
- poll/question/answer/translation:
+ poll/question/option/translation:
title: Respuesta
description: "Descripción (opcional)"
- poll/question/answer/video:
+ poll/question/option/video:
title: Título
url: Vídeo externo
newsletter:
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index bb91f8d66..0e658e9ec 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -162,7 +162,7 @@ es:
legislation/process: el proceso
legislation/question: la pregunta
poll/shift: el turno
- poll/question/answer: la respuesta
+ poll/question/option: la respuesta
user: la cuenta
verification/sms: el teléfono
signature_sheet: la hoja de firmas
diff --git a/config/locales/es/responders.yml b/config/locales/es/responders.yml
index 8928540e5..49a78fad1 100644
--- a/config/locales/es/responders.yml
+++ b/config/locales/es/responders.yml
@@ -7,9 +7,9 @@ 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"
- poll_question_answer_video: "Vídeo creado correctamente"
- poll_question_answer_image: "Imagen cargada correctamente"
+ poll_question_option: "Respuesta creada correctamente"
+ poll_question_option_video: "Vídeo creado correctamente"
+ poll_question_option_image: "Imagen cargada correctamente"
proposal: "Propuesta creada correctamente."
proposal_notification: "Tu mensaje ha sido enviado correctamente."
budget_investment: "Proyecto de gasto creado correctamente."
@@ -34,7 +34,7 @@ es:
destroy:
budget_investment: "Proyecto de gasto eliminado."
topic: "Tema eliminado."
- poll_question_answer_image: "Imagen eliminada correctamente."
- poll_question_answer_video: "Vídeo de respuesta eliminado."
+ poll_question_option_image: "Imagen eliminada correctamente."
+ poll_question_option_video: "Vídeo de respuesta eliminado."
valuator_group: "Grupo de evaluadores eliminado correctamente"
vote: "Voto eliminado correctamente"
diff --git a/config/routes/admin.rb b/config/routes/admin.rb
index c38eaf672..6f3f3d561 100644
--- a/config/routes/admin.rb
+++ b/config/routes/admin.rb
@@ -175,13 +175,13 @@ namespace :admin do
end
resources :questions, shallow: true do
- resources :answers, except: [:index, :show], controller: "questions/answers", shallow: false
- resources :answers, only: [], controller: "questions/answers" do
- resources :images, controller: "questions/answers/images"
- resources :videos, controller: "questions/answers/videos", shallow: false
- resources :documents, only: [:index, :create], controller: "questions/answers/documents"
+ resources :options, except: [:index, :show], controller: "questions/options", shallow: false
+ resources :options, only: [], controller: "questions/options" do
+ resources :images, controller: "questions/options/images"
+ resources :videos, controller: "questions/options/videos", shallow: false
+ resources :documents, only: [:index, :create], controller: "questions/options/documents"
end
- post "/answers/order_answers", to: "questions/answers#order_answers"
+ post "/options/order_options", to: "questions/options#order_options"
end
resource :active_polls, only: [:create, :edit, :update]
@@ -336,12 +336,12 @@ resolve "Poll::Officer" do |officer, options|
[:officer, options.merge(id: officer)]
end
-resolve "Poll::Question::Answer" do |answer, options|
- [:question, :answer, options.merge(question_id: answer.question, id: answer)]
+resolve "Poll::Question::Option" do |option, options|
+ [:question, :option, options.merge(question_id: option.question, id: option)]
end
-resolve "Poll::Question::Answer::Video" do |video, options|
- [:answer, :video, options.merge(answer_id: video.answer, id: video)]
+resolve "Poll::Question::Option::Video" do |video, options|
+ [:option, :video, options.merge(option_id: video.option, id: video)]
end
resolve "Legislation::DraftVersion" do |version, options|
diff --git a/db/dev_seeds/polls.rb b/db/dev_seeds/polls.rb
index 9dd7883ea..b32b4ca39 100644
--- a/db/dev_seeds/polls.rb
+++ b/db/dev_seeds/polls.rb
@@ -64,17 +64,17 @@ section "Creating Poll Questions & Answers" do
question.save!
Faker::Lorem.words(number: (2..4).to_a.sample).each_with_index do |title, index|
description = "
#{Faker::Lorem.paragraphs.join("
")}
"
- answer = Poll::Question::Answer.new(question: question,
+ option = Poll::Question::Option.new(question: question,
title: title.capitalize,
description: description,
given_order: index + 1)
Setting.enabled_locales.map do |locale|
Globalize.with_locale(locale) do
- answer.title = "#{title} (#{locale})"
- answer.description = "#{description} (#{locale})"
+ option.title = "#{title} (#{locale})"
+ option.description = "#{description} (#{locale})"
end
end
- answer.save!
+ option.save!
end
end
end
@@ -160,7 +160,7 @@ section "Creating Poll Voters" do
Poll::Answer.create!(question_id: question.id,
author: user,
- answer: question.question_answers.sample.title)
+ answer: question.question_options.sample.title)
end
end
@@ -210,7 +210,7 @@ section "Creating Poll Results" do
author = Poll::Officer.first.user
poll.questions.each do |question|
- question.question_answers.each do |answer|
+ question.question_options.each do |answer|
Poll::PartialResult.create!(officer_assignment: officer_assignment,
booth_assignment: booth_assignment,
date: Date.current,
@@ -240,17 +240,17 @@ section "Creating Poll Questions from Proposals" do
question.save!
Faker::Lorem.words(number: (2..4).to_a.sample).each_with_index do |title, index|
description = "
#{Faker::ChuckNorris.fact}
"
- answer = Poll::Question::Answer.new(question: question,
+ option = Poll::Question::Option.new(question: question,
title: title.capitalize,
description: description,
given_order: index + 1)
Setting.enabled_locales.map do |locale|
Globalize.with_locale(locale) do
- answer.title = "#{title} (#{locale})"
- answer.description = "#{description} (#{locale})"
+ option.title = "#{title} (#{locale})"
+ option.description = "#{description} (#{locale})"
end
end
- answer.save!
+ option.save!
end
end
end
@@ -270,17 +270,17 @@ section "Creating Successful Proposals" do
question.save!
Faker::Lorem.words(number: (2..4).to_a.sample).each_with_index do |title, index|
description = "
#{Faker::ChuckNorris.fact}
"
- answer = Poll::Question::Answer.new(question: question,
+ option = Poll::Question::Option.new(question: question,
title: title.capitalize,
description: description,
given_order: index + 1)
Setting.enabled_locales.map do |locale|
Globalize.with_locale(locale) do
- answer.title = "#{title} (#{locale})"
- answer.description = "#{description} (#{locale})"
+ option.title = "#{title} (#{locale})"
+ option.description = "#{description} (#{locale})"
end
end
- answer.save!
+ option.save!
end
end
end
diff --git a/spec/components/admin/menu_component_spec.rb b/spec/components/admin/menu_component_spec.rb
index 0a7ccf82f..c8ca22c9c 100644
--- a/spec/components/admin/menu_component_spec.rb
+++ b/spec/components/admin/menu_component_spec.rb
@@ -19,4 +19,20 @@ describe Admin::MenuComponent, controller: Admin::NewslettersController do
expect(page).to have_css "button[aria-expanded='false']", exact_text: "Settings"
end
+
+ describe "#polls_link" do
+ it "is marked as current when managing poll options",
+ controller: Admin::Poll::Questions::OptionsController do
+ render_inline Admin::MenuComponent.new
+
+ expect(page).to have_css "[aria-current]", exact_text: "Polls"
+ end
+
+ it "is marked as current when managing poll options content",
+ controller: Admin::Poll::Questions::Options::VideosController do
+ render_inline Admin::MenuComponent.new
+
+ expect(page).to have_css "[aria-current]", exact_text: "Polls"
+ end
+ end
end
diff --git a/spec/components/admin/poll/questions/answers/documents/index_component_spec.rb b/spec/components/admin/poll/questions/options/documents/index_component_spec.rb
similarity index 59%
rename from spec/components/admin/poll/questions/answers/documents/index_component_spec.rb
rename to spec/components/admin/poll/questions/options/documents/index_component_spec.rb
index 053c37ce5..135a1d572 100644
--- a/spec/components/admin/poll/questions/answers/documents/index_component_spec.rb
+++ b/spec/components/admin/poll/questions/options/documents/index_component_spec.rb
@@ -1,18 +1,18 @@
require "rails_helper"
-describe Admin::Poll::Questions::Answers::Documents::IndexComponent do
+describe Admin::Poll::Questions::Options::Documents::IndexComponent do
before { sign_in(create(:administrator).user) }
- let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
- let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
+ let(:future_answer) { create(:poll_question_option, poll: create(:poll, :future)) }
+ let(:current_answer) { create(:poll_question_option, poll: create(:poll)) }
it "displays the 'Add new document' link when the poll has not started" do
- render_inline Admin::Poll::Questions::Answers::Documents::IndexComponent.new(future_answer)
+ render_inline Admin::Poll::Questions::Options::Documents::IndexComponent.new(future_answer)
expect(page).to have_link "Add new document"
end
it "does not display the 'Add new document' link when the poll has started" do
- render_inline Admin::Poll::Questions::Answers::Documents::IndexComponent.new(current_answer)
+ render_inline Admin::Poll::Questions::Options::Documents::IndexComponent.new(current_answer)
expect(page).not_to have_link "Add new document"
end
diff --git a/spec/components/admin/poll/questions/answers/documents/table_actions_component_spec.rb b/spec/components/admin/poll/questions/options/documents/table_actions_component_spec.rb
similarity index 68%
rename from spec/components/admin/poll/questions/answers/documents/table_actions_component_spec.rb
rename to spec/components/admin/poll/questions/options/documents/table_actions_component_spec.rb
index 218b46c41..651856659 100644
--- a/spec/components/admin/poll/questions/answers/documents/table_actions_component_spec.rb
+++ b/spec/components/admin/poll/questions/options/documents/table_actions_component_spec.rb
@@ -1,13 +1,13 @@
require "rails_helper"
-describe Admin::Poll::Questions::Answers::Documents::TableActionsComponent, :admin do
- let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
- let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
+describe Admin::Poll::Questions::Options::Documents::TableActionsComponent, :admin do
+ let(:future_answer) { create(:poll_question_option, poll: create(:poll, :future)) }
+ let(:current_answer) { create(:poll_question_option, poll: create(:poll)) }
it "displays the destroy action when the poll has not started" do
document = create(:document, documentable: future_answer)
- render_inline Admin::Poll::Questions::Answers::Documents::TableActionsComponent.new(document)
+ render_inline Admin::Poll::Questions::Options::Documents::TableActionsComponent.new(document)
expect(page).to have_link "Download file"
expect(page).to have_button "Delete"
@@ -17,7 +17,7 @@ describe Admin::Poll::Questions::Answers::Documents::TableActionsComponent, :adm
it "does not display the destroy action when the poll has started" do
document = create(:document, documentable: current_answer)
- render_inline Admin::Poll::Questions::Answers::Documents::TableActionsComponent.new(document)
+ render_inline Admin::Poll::Questions::Options::Documents::TableActionsComponent.new(document)
expect(page).to have_link "Download file"
expect(page).not_to have_button "Delete"
diff --git a/spec/components/admin/poll/questions/answers/table_actions_component_spec.rb b/spec/components/admin/poll/questions/options/table_actions_component_spec.rb
similarity index 51%
rename from spec/components/admin/poll/questions/answers/table_actions_component_spec.rb
rename to spec/components/admin/poll/questions/options/table_actions_component_spec.rb
index 4b8243209..f991395ac 100644
--- a/spec/components/admin/poll/questions/answers/table_actions_component_spec.rb
+++ b/spec/components/admin/poll/questions/options/table_actions_component_spec.rb
@@ -1,19 +1,19 @@
require "rails_helper"
-describe Admin::Poll::Questions::Answers::TableActionsComponent, :admin do
+describe Admin::Poll::Questions::Options::TableActionsComponent, :admin do
it "displays the edit and destroy actions when the poll has not started" do
- answer = create(:poll_question_answer, poll: create(:poll, :future))
+ option = create(:poll_question_option, poll: create(:poll, :future))
- render_inline Admin::Poll::Questions::Answers::TableActionsComponent.new(answer)
+ render_inline Admin::Poll::Questions::Options::TableActionsComponent.new(option)
expect(page).to have_link "Edit"
expect(page).to have_button "Delete"
end
it "does not display the edit and destroy actions when the poll has started" do
- answer = create(:poll_question_answer, poll: create(:poll))
+ option = create(:poll_question_option, poll: create(:poll))
- render_inline Admin::Poll::Questions::Answers::TableActionsComponent.new(answer)
+ render_inline Admin::Poll::Questions::Options::TableActionsComponent.new(option)
expect(page).not_to have_link "Edit"
expect(page).not_to have_button "Delete"
diff --git a/spec/components/admin/poll/questions/answers/videos/table_actions_component_spec.rb b/spec/components/admin/poll/questions/options/videos/table_actions_component_spec.rb
similarity index 58%
rename from spec/components/admin/poll/questions/answers/videos/table_actions_component_spec.rb
rename to spec/components/admin/poll/questions/options/videos/table_actions_component_spec.rb
index 199e83c7a..d55532abb 100644
--- a/spec/components/admin/poll/questions/answers/videos/table_actions_component_spec.rb
+++ b/spec/components/admin/poll/questions/options/videos/table_actions_component_spec.rb
@@ -1,19 +1,19 @@
require "rails_helper"
-describe Admin::Poll::Questions::Answers::Videos::TableActionsComponent, :admin do
+describe Admin::Poll::Questions::Options::Videos::TableActionsComponent, :admin do
it "displays the edit and destroy actions when the poll has not started" do
- video = create(:poll_answer_video, poll: create(:poll, :future))
+ video = create(:poll_option_video, poll: create(:poll, :future))
- render_inline Admin::Poll::Questions::Answers::Videos::TableActionsComponent.new(video)
+ render_inline Admin::Poll::Questions::Options::Videos::TableActionsComponent.new(video)
expect(page).to have_link "Edit"
expect(page).to have_button "Delete"
end
it "does not display the edit and destroy actions when the poll has started" do
- video = create(:poll_answer_video, poll: create(:poll))
+ video = create(:poll_option_video, poll: create(:poll))
- render_inline Admin::Poll::Questions::Answers::Videos::TableActionsComponent.new(video)
+ render_inline Admin::Poll::Questions::Options::Videos::TableActionsComponent.new(video)
expect(page).not_to have_link "Edit"
expect(page).not_to have_button "Delete"
diff --git a/spec/components/polls/questions/answers_component_spec.rb b/spec/components/polls/questions/options_component_spec.rb
similarity index 82%
rename from spec/components/polls/questions/answers_component_spec.rb
rename to spec/components/polls/questions/options_component_spec.rb
index e63fa68c6..c50416cd5 100644
--- a/spec/components/polls/questions/answers_component_spec.rb
+++ b/spec/components/polls/questions/options_component_spec.rb
@@ -1,12 +1,12 @@
require "rails_helper"
-describe Polls::Questions::AnswersComponent do
+describe Polls::Questions::OptionsComponent do
include Rails.application.routes.url_helpers
let(:poll) { create(:poll) }
let(:question) { create(:poll_question, :yes_no, poll: poll) }
it "renders answers in given order" do
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect("Yes").to appear_before("No")
end
@@ -14,7 +14,7 @@ describe Polls::Questions::AnswersComponent do
it "renders buttons to vote question answers" do
sign_in(create(:user, :verified))
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_button "Yes"
expect(page).to have_button "No"
@@ -26,7 +26,7 @@ describe Polls::Questions::AnswersComponent do
create(:poll_answer, author: user, question: question, answer: "Yes")
sign_in(user)
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_button "You have voted Yes"
expect(page).to have_button "Vote No"
@@ -40,7 +40,7 @@ describe Polls::Questions::AnswersComponent do
create(:poll_answer, author: user, question: question, answer: "Answer C")
sign_in(user)
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_button "You have voted Answer A"
expect(page).to have_button "Vote Answer B", disabled: true
@@ -48,7 +48,7 @@ describe Polls::Questions::AnswersComponent do
end
it "when user is not signed in, renders answers links pointing to user sign in path" do
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_link "Yes", href: new_user_session_path
expect(page).to have_link "No", href: new_user_session_path
@@ -57,7 +57,7 @@ describe Polls::Questions::AnswersComponent do
it "when user is not verified, renders answers links pointing to user verification in path" do
sign_in(create(:user))
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_link "Yes", href: verification_path
expect(page).to have_link "No", href: verification_path
@@ -68,7 +68,7 @@ describe Polls::Questions::AnswersComponent do
create(:poll_voter, :from_booth, poll: poll, user: user)
sign_in(user)
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_css "span.disabled", text: "Yes"
expect(page).to have_css "span.disabled", text: "No"
@@ -78,7 +78,7 @@ describe Polls::Questions::AnswersComponent do
question = create(:poll_question, :yes_no, poll: create(:poll, :expired))
sign_in(create(:user, :level_two))
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_css "span.disabled", text: "Yes"
expect(page).to have_css "span.disabled", text: "No"
@@ -93,7 +93,7 @@ describe Polls::Questions::AnswersComponent do
poll.geozones << geozone
sign_in(create(:user, :level_two))
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_css "span.disabled", text: "Yes"
expect(page).to have_css "span.disabled", text: "No"
@@ -103,7 +103,7 @@ describe Polls::Questions::AnswersComponent do
poll.geozones << geozone
sign_in(create(:user, :level_two, geozone: geozone))
- render_inline Polls::Questions::AnswersComponent.new(question)
+ render_inline Polls::Questions::OptionsComponent.new(question)
expect(page).to have_button "Yes"
expect(page).to have_button "No"
diff --git a/spec/components/polls/questions/question_component_spec.rb b/spec/components/polls/questions/question_component_spec.rb
index 4ca884af5..b580045e8 100644
--- a/spec/components/polls/questions/question_component_spec.rb
+++ b/spec/components/polls/questions/question_component_spec.rb
@@ -3,9 +3,9 @@ require "rails_helper"
describe Polls::Questions::QuestionComponent do
it "renders more information links when any question answer has additional information" do
question = create(:poll_question)
- answer_a = create(:poll_question_answer, question: question, title: "Answer A")
- answer_b = create(:poll_question_answer, question: question, title: "Answer B")
- allow_any_instance_of(Poll::Question::Answer).to receive(:with_read_more?).and_return(true)
+ answer_a = create(:poll_question_option, question: question, title: "Answer A")
+ answer_b = create(:poll_question_option, question: question, title: "Answer B")
+ allow_any_instance_of(Poll::Question::Option).to receive(:with_read_more?).and_return(true)
render_inline Polls::Questions::QuestionComponent.new(question: question)
diff --git a/spec/components/polls/questions/read_more_component_spec.rb b/spec/components/polls/questions/read_more_component_spec.rb
index 26c9899ca..239e7b28c 100644
--- a/spec/components/polls/questions/read_more_component_spec.rb
+++ b/spec/components/polls/questions/read_more_component_spec.rb
@@ -4,51 +4,51 @@ describe Polls::Questions::ReadMoreComponent do
include Rails.application.routes.url_helpers
let(:poll) { create(:poll) }
let(:question) { create(:poll_question, poll: poll, title: "Question title?") }
- let(:answer) { create(:poll_question_answer, question: question) }
+ let(:option) { create(:poll_question_option, question: question) }
it "renders question title" do
- create(:poll_question_answer, question: question, description: "Question answer description")
+ create(:poll_question_option, question: question, description: "Question option description")
render_inline Polls::Questions::ReadMoreComponent.new(question: question)
expect(page).to have_content "Question title?"
end
- it "renders answers in the given order" do
- create(:poll_question_answer, title: "Answer A", question: question, given_order: 2)
- create(:poll_question_answer, title: "Answer B", question: question, given_order: 1)
+ it "renders options in the given order" do
+ create(:poll_question_option, title: "Answer A", question: question, given_order: 2)
+ create(:poll_question_option, title: "Answer B", question: question, given_order: 1)
render_inline Polls::Questions::ReadMoreComponent.new(question: question)
expect("Answer B").to appear_before("Answer A")
end
- it "does not render when answers does not have more information" do
- answer.update!(description: nil)
+ it "does not render when options does not have more information" do
+ option.update!(description: nil)
render_inline Polls::Questions::ReadMoreComponent.new(question: question)
expect(page).not_to be_rendered
end
- it "renders answers with videos" do
- create(:poll_answer_video, answer: answer, title: "Awesome video", url: "youtube.com/watch?v=123")
+ it "renders options with videos" do
+ create(:poll_option_video, option: option, title: "Awesome video", url: "youtube.com/watch?v=123")
render_inline Polls::Questions::ReadMoreComponent.new(question: question)
expect(page).to have_link("Awesome video", href: "youtube.com/watch?v=123")
end
- it "renders answers with images" do
- create(:image, imageable: answer, title: "The yes movement")
+ it "renders options with images" do
+ create(:image, imageable: option, title: "The yes movement")
render_inline Polls::Questions::ReadMoreComponent.new(question: question)
expect(page).to have_css "img[alt='The yes movement']"
end
- it "renders answers with documents" do
- create(:document, documentable: answer, title: "The yes movement")
+ it "renders options with documents" do
+ create(:document, documentable: option, title: "The yes movement")
render_inline Polls::Questions::ReadMoreComponent.new(question: question)
diff --git a/spec/controllers/admin/poll/questions/answers/documents_controller_spec.rb b/spec/controllers/admin/poll/questions/options/documents_controller_spec.rb
similarity index 54%
rename from spec/controllers/admin/poll/questions/answers/documents_controller_spec.rb
rename to spec/controllers/admin/poll/questions/options/documents_controller_spec.rb
index 84e02f0f6..b33e7591a 100644
--- a/spec/controllers/admin/poll/questions/answers/documents_controller_spec.rb
+++ b/spec/controllers/admin/poll/questions/options/documents_controller_spec.rb
@@ -1,11 +1,11 @@
require "rails_helper"
-describe Admin::Poll::Questions::Answers::DocumentsController, :admin do
- let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
- let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
+describe Admin::Poll::Questions::Options::DocumentsController, :admin do
+ let(:current_option) { create(:poll_question_option, poll: create(:poll)) }
+ let(:future_option) { create(:poll_question_option, poll: create(:poll, :future)) }
describe "POST create" do
- let(:answer_attributes) do
+ let(:option_attributes) do
{
documents_attributes: {
"0" => {
@@ -18,16 +18,16 @@ describe Admin::Poll::Questions::Answers::DocumentsController, :admin do
end
it "is not possible for an already started poll" do
- post :create, params: { poll_question_answer: answer_attributes, answer_id: current_answer }
+ post :create, params: { poll_question_option: option_attributes, option_id: current_option }
- expect(flash[:alert]).to eq "You do not have permission to carry out the action 'update' on Answer."
+ expect(flash[:alert]).to eq "You do not have permission to carry out the action 'update' on Option."
expect(Document.count).to eq 0
end
it "is possible for a not started poll" do
- post :create, params: { poll_question_answer: answer_attributes, answer_id: future_answer }
+ post :create, params: { poll_question_option: option_attributes, option_id: future_option }
- expect(response).to redirect_to admin_answer_documents_path(future_answer)
+ expect(response).to redirect_to admin_option_documents_path(future_option)
expect(flash[:notice]).to eq "Document uploaded successfully"
expect(Document.count).to eq 1
end
diff --git a/spec/controllers/admin/poll/questions/answers/images_controller_spec.rb b/spec/controllers/admin/poll/questions/options/images_controller_spec.rb
similarity index 62%
rename from spec/controllers/admin/poll/questions/answers/images_controller_spec.rb
rename to spec/controllers/admin/poll/questions/options/images_controller_spec.rb
index 6e2c27b82..d19acc184 100644
--- a/spec/controllers/admin/poll/questions/answers/images_controller_spec.rb
+++ b/spec/controllers/admin/poll/questions/options/images_controller_spec.rb
@@ -1,11 +1,11 @@
require "rails_helper"
-describe Admin::Poll::Questions::Answers::ImagesController, :admin do
- let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
- let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
+describe Admin::Poll::Questions::Options::ImagesController, :admin do
+ let(:current_option) { create(:poll_question_option, poll: create(:poll)) }
+ let(:future_option) { create(:poll_question_option, poll: create(:poll, :future)) }
describe "POST create" do
- let(:answer_attributes) do
+ let(:option_attributes) do
{
images_attributes: {
"0" => {
@@ -18,16 +18,16 @@ describe Admin::Poll::Questions::Answers::ImagesController, :admin do
end
it "is not possible for an already started poll" do
- post :create, params: { poll_question_answer: answer_attributes, answer_id: current_answer }
+ post :create, params: { poll_question_option: option_attributes, option_id: current_option }
- expect(flash[:alert]).to eq "You do not have permission to carry out the action 'update' on Answer."
+ expect(flash[:alert]).to eq "You do not have permission to carry out the action 'update' on Option."
expect(Image.count).to eq 0
end
it "is possible for a not started poll" do
- post :create, params: { poll_question_answer: answer_attributes, answer_id: future_answer }
+ post :create, params: { poll_question_option: option_attributes, option_id: future_option }
- expect(response).to redirect_to admin_answer_images_path(future_answer)
+ expect(response).to redirect_to admin_option_images_path(future_option)
expect(flash[:notice]).to eq "Image uploaded successfully"
expect(Image.count).to eq 1
end
@@ -35,7 +35,7 @@ describe Admin::Poll::Questions::Answers::ImagesController, :admin do
describe "DELETE destroy" do
it "is not possible for an already started poll" do
- current_image = create(:image, imageable: current_answer)
+ current_image = create(:image, imageable: current_option)
delete :destroy, xhr: true, params: { id: current_image }
expect(flash[:alert]).to eq "You do not have permission to carry out the action 'destroy' on Image."
@@ -43,7 +43,7 @@ describe Admin::Poll::Questions::Answers::ImagesController, :admin do
end
it "is possible for a not started poll" do
- future_image = create(:image, imageable: future_answer)
+ future_image = create(:image, imageable: future_option)
delete :destroy, xhr: true, params: { id: future_image }
expect(Image.count).to eq 0
diff --git a/spec/controllers/admin/poll/questions/answers/videos_controller_spec.rb b/spec/controllers/admin/poll/questions/options/videos_controller_spec.rb
similarity index 55%
rename from spec/controllers/admin/poll/questions/answers/videos_controller_spec.rb
rename to spec/controllers/admin/poll/questions/options/videos_controller_spec.rb
index 6a2e7bcf4..a65d0243b 100644
--- a/spec/controllers/admin/poll/questions/answers/videos_controller_spec.rb
+++ b/spec/controllers/admin/poll/questions/options/videos_controller_spec.rb
@@ -1,48 +1,48 @@
require "rails_helper"
-describe Admin::Poll::Questions::Answers::VideosController, :admin do
- let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
- let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
+describe Admin::Poll::Questions::Options::VideosController, :admin do
+ let(:current_option) { create(:poll_question_option, poll: create(:poll)) }
+ let(:future_option) { create(:poll_question_option, poll: create(:poll, :future)) }
describe "POST create" do
it "is not possible for an already started poll" do
post :create, params: {
- poll_question_answer_video: {
+ poll_question_option_video: {
title: "Video from started poll",
url: "https://www.youtube.com/watch?v=-JMf43st-1A"
},
- answer_id: current_answer
+ option_id: current_option
}
expect(flash[:alert]).to eq "You do not have permission to carry out the action 'create' on Video."
- expect(Poll::Question::Answer::Video.count).to eq 0
+ expect(Poll::Question::Option::Video.count).to eq 0
end
it "is possible for a not started poll" do
post :create, params: {
- poll_question_answer_video: {
+ poll_question_option_video: {
title: "Video from not started poll",
url: "https://www.youtube.com/watch?v=-JMf43st-1A"
},
- answer_id: future_answer
+ option_id: future_option
}
- expect(response).to redirect_to admin_answer_videos_path(future_answer)
+ expect(response).to redirect_to admin_option_videos_path(future_option)
expect(flash[:notice]).to eq "Video created successfully"
- expect(Poll::Question::Answer::Video.count).to eq 1
+ expect(Poll::Question::Option::Video.count).to eq 1
end
end
describe "PATCH update" do
it "is not possible for an already started poll" do
- current_video = create(:poll_answer_video, answer: current_answer, title: "Sample title")
+ current_video = create(:poll_option_video, option: current_option, title: "Sample title")
patch :update, params: {
- poll_question_answer_video: {
+ poll_question_option_video: {
title: "New title"
},
id: current_video,
- answer_id: current_answer
+ option_id: current_option
}
expect(flash[:alert]).to eq "You do not have permission to carry out the action 'update' on Video."
@@ -50,17 +50,17 @@ describe Admin::Poll::Questions::Answers::VideosController, :admin do
end
it "is possible for a not started poll" do
- future_video = create(:poll_answer_video, answer: future_answer)
+ future_video = create(:poll_option_video, option: future_option)
patch :update, params: {
- poll_question_answer_video: {
+ poll_question_option_video: {
title: "New title"
},
id: future_video,
- answer_id: future_answer
+ option_id: future_option
}
- expect(response).to redirect_to admin_answer_videos_path(future_answer)
+ expect(response).to redirect_to admin_option_videos_path(future_option)
expect(flash[:notice]).to eq "Changes saved"
expect(future_video.reload.title).to eq "New title"
end
@@ -68,20 +68,20 @@ describe Admin::Poll::Questions::Answers::VideosController, :admin do
describe "DELETE destroy" do
it "is not possible for an already started poll" do
- current_video = create(:poll_answer_video, answer: current_answer)
- delete :destroy, params: { answer_id: current_answer, id: current_video }
+ current_video = create(:poll_option_video, option: current_option)
+ delete :destroy, params: { option_id: current_option, id: current_video }
expect(flash[:alert]).to eq "You do not have permission to carry out the action 'destroy' on Video."
- expect(Poll::Question::Answer::Video.count).to eq 1
+ expect(Poll::Question::Option::Video.count).to eq 1
end
it "is possible for a not started poll" do
- future_video = create(:poll_answer_video, answer: future_answer)
- delete :destroy, params: { answer_id: future_answer, id: future_video }
+ future_video = create(:poll_option_video, option: future_option)
+ delete :destroy, params: { option_id: future_option, id: future_video }
- expect(response).to redirect_to admin_answer_videos_path(future_answer)
+ expect(response).to redirect_to admin_option_videos_path(future_option)
expect(flash[:notice]).to eq "Answer video deleted successfully."
- expect(Poll::Question::Answer::Video.count).to eq 0
+ expect(Poll::Question::Option::Video.count).to eq 0
end
end
end
diff --git a/spec/controllers/admin/poll/questions/answers_controller_spec.rb b/spec/controllers/admin/poll/questions/options_controller_spec.rb
similarity index 67%
rename from spec/controllers/admin/poll/questions/answers_controller_spec.rb
rename to spec/controllers/admin/poll/questions/options_controller_spec.rb
index bdee4c59a..2245947d9 100644
--- a/spec/controllers/admin/poll/questions/answers_controller_spec.rb
+++ b/spec/controllers/admin/poll/questions/options_controller_spec.rb
@@ -1,13 +1,13 @@
require "rails_helper"
-describe Admin::Poll::Questions::AnswersController, :admin do
+describe Admin::Poll::Questions::OptionsController, :admin do
let(:current_question) { create(:poll_question, poll: create(:poll)) }
let(:future_question) { create(:poll_question, poll: create(:poll, :future)) }
describe "POST create" do
it "is not possible for an already started poll" do
post :create, params: {
- poll_question_answer: {
+ poll_question_option: {
translations_attributes: {
"0" => {
locale: "en",
@@ -18,13 +18,13 @@ describe Admin::Poll::Questions::AnswersController, :admin do
question_id: current_question
}
- expect(flash[:alert]).to eq "You do not have permission to carry out the action 'create' on Answer."
- expect(Poll::Question::Answer.count).to eq 0
+ expect(flash[:alert]).to eq "You do not have permission to carry out the action 'create' on Option."
+ expect(Poll::Question::Option.count).to eq 0
end
it "is possible for a not started poll" do
post :create, params: {
- poll_question_answer: {
+ poll_question_option: {
translations_attributes: {
"0" => {
locale: "en",
@@ -36,72 +36,72 @@ describe Admin::Poll::Questions::AnswersController, :admin do
}
expect(response).to redirect_to admin_question_path(future_question)
- expect(Poll::Question::Answer.last.title).to eq "Answer from future poll"
- expect(Poll::Question::Answer.count).to eq 1
+ expect(Poll::Question::Option.last.title).to eq "Answer from future poll"
+ expect(Poll::Question::Option.count).to eq 1
end
end
describe "PATCH update" do
it "is not possible for an already started poll" do
- current_answer = create(:poll_question_answer, question: current_question, title: "Sample title")
+ current_option = create(:poll_question_option, question: current_question, title: "Sample title")
patch :update, params: {
- poll_question_answer: {
+ poll_question_option: {
translations_attributes: {
"0" => {
locale: "en",
title: "New title",
- id: current_answer.translations.first.id
+ id: current_option.translations.first.id
}
}
},
question_id: current_question,
- id: current_answer
+ id: current_option
}
- expect(flash[:alert]).to eq "You do not have permission to carry out the action 'update' on Answer."
- expect(current_answer.reload.title).to eq "Sample title"
+ expect(flash[:alert]).to eq "You do not have permission to carry out the action 'update' on Option."
+ expect(current_option.reload.title).to eq "Sample title"
end
it "is possible for a not started poll" do
- future_answer = create(:poll_question_answer, question: future_question)
+ future_option = create(:poll_question_option, question: future_question)
patch :update, params: {
- poll_question_answer: {
+ poll_question_option: {
translations_attributes: {
"0" => {
locale: "en",
title: "New title",
- id: future_answer.translations.first.id
+ id: future_option.translations.first.id
}
}
},
question_id: future_question,
- id: future_answer
+ id: future_option
}
expect(response).to redirect_to admin_question_path(future_question)
expect(flash[:notice]).to eq "Changes saved"
- expect(future_answer.reload.title).to eq "New title"
+ expect(future_option.reload.title).to eq "New title"
end
end
describe "DELETE destroy" do
it "is not possible for an already started poll" do
- current_answer = create(:poll_question_answer, question: current_question)
- delete :destroy, params: { question_id: current_question, id: current_answer }
+ current_option = create(:poll_question_option, question: current_question)
+ delete :destroy, params: { question_id: current_question, id: current_option }
- expect(flash[:alert]).to eq "You do not have permission to carry out the action 'destroy' on Answer."
- expect(Poll::Question::Answer.count).to eq 1
+ expect(flash[:alert]).to eq "You do not have permission to carry out the action 'destroy' on Option."
+ expect(Poll::Question::Option.count).to eq 1
end
it "is possible for a not started poll" do
- future_answer = create(:poll_question_answer, question: future_question)
- delete :destroy, params: { question_id: future_question, id: future_answer }
+ future_option = create(:poll_question_option, question: future_question)
+ delete :destroy, params: { question_id: future_question, id: future_option }
expect(response).to redirect_to admin_question_path(future_question)
expect(flash[:notice]).to eq "Answer deleted successfully"
- expect(Poll::Question::Answer.count).to eq 0
+ expect(Poll::Question::Option.count).to eq 0
end
end
end
diff --git a/spec/controllers/documents_controller_spec.rb b/spec/controllers/documents_controller_spec.rb
index 2fc0638cc..c28108ea2 100644
--- a/spec/controllers/documents_controller_spec.rb
+++ b/spec/controllers/documents_controller_spec.rb
@@ -3,8 +3,8 @@ require "rails_helper"
describe DocumentsController do
describe "DELETE destroy" do
context "Poll answers administration", :admin do
- let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
- let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
+ let(:current_answer) { create(:poll_question_option, poll: create(:poll)) }
+ let(:future_answer) { create(:poll_question_option, poll: create(:poll, :future)) }
it "is not possible for an already started poll" do
document = create(:document, documentable: current_answer)
@@ -17,10 +17,10 @@ describe DocumentsController do
it "is possible for a not started poll" do
document = create(:document, documentable: future_answer)
- request.env["HTTP_REFERER"] = admin_answer_documents_path(future_answer)
+ request.env["HTTP_REFERER"] = admin_option_documents_path(future_answer)
delete :destroy, params: { id: document }
- expect(response).to redirect_to admin_answer_documents_path(future_answer)
+ expect(response).to redirect_to admin_option_documents_path(future_answer)
expect(flash[:notice]).to eq "Document was deleted successfully."
expect(Document.count).to eq 0
end
diff --git a/spec/factories/polls.rb b/spec/factories/polls.rb
index a7eb4a1b5..4f61232bc 100644
--- a/spec/factories/polls.rb
+++ b/spec/factories/polls.rb
@@ -60,15 +60,15 @@ FactoryBot.define do
trait :yes_no do
after(:create) do |question|
- create(:poll_question_answer, question: question, title: "Yes")
- create(:poll_question_answer, question: question, title: "No")
+ create(:poll_question_option, question: question, title: "Yes")
+ create(:poll_question_option, question: question, title: "No")
end
end
trait :abc do
after(:create) do |question, evaluator|
%w[A B C].each do |letter|
- create(:poll_question_answer, question: question, title: "Answer #{letter}")
+ create(:poll_question_option, question: question, title: "Answer #{letter}")
end
end
end
@@ -88,7 +88,7 @@ FactoryBot.define do
end
end
- factory :poll_question_answer, class: "Poll::Question::Answer" do
+ factory :poll_question_option, class: "Poll::Question::Option" do
sequence(:title) { |n| "Answer title #{n}" }
sequence(:description) { |n| "Answer description #{n}" }
sequence(:given_order) { |n| n }
@@ -98,29 +98,29 @@ FactoryBot.define do
question { association(:poll_question, poll: poll) }
trait :with_image do
- after(:create) { |answer| create(:image, imageable: answer) }
+ after(:create) { |option| create(:image, imageable: option) }
end
trait :with_document do
- after(:create) { |answer| create(:document, documentable: answer) }
+ after(:create) { |option| create(:document, documentable: option) }
end
trait :with_video do
- after(:create) { |answer| create(:poll_answer_video, answer: answer) }
+ after(:create) { |option| create(:poll_option_video, option: option) }
end
- factory :future_poll_question_answer do
+ factory :future_poll_question_option do
poll { association(:poll, :future) }
end
end
- factory :poll_answer_video, class: "Poll::Question::Answer::Video" do
+ factory :poll_option_video, class: "Poll::Question::Option::Video" do
title { "Sample video title" }
url { "https://youtu.be/nhuNb0XtRhQ" }
transient { poll { association(:poll) } }
- answer { association(:poll_question_answer, poll: poll) }
+ option { association(:poll_question_option, poll: poll) }
end
factory :poll_booth, class: "Poll::Booth" do
@@ -204,14 +204,14 @@ FactoryBot.define do
factory :poll_answer, class: "Poll::Answer" do
question factory: [:poll_question, :yes_no]
author factory: [:user, :level_two]
- answer { question.question_answers.sample.title }
+ answer { question.question_options.sample.title }
end
factory :poll_partial_result, class: "Poll::PartialResult" do
question factory: [:poll_question, :yes_no]
author factory: :user
origin { "web" }
- answer { question.question_answers.sample.title }
+ answer { question.question_options.sample.title }
end
factory :poll_recount, class: "Poll::Recount" do
diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb
index 7fb48b225..f24a6f4b4 100644
--- a/spec/models/abilities/administrator_spec.rb
+++ b/spec/models/abilities/administrator_spec.rb
@@ -20,14 +20,14 @@ describe Abilities::Administrator do
let(:future_poll) { create(:poll, :future) }
let(:current_poll_question) { create(:poll_question) }
let(:future_poll_question) { create(:poll_question, poll: future_poll) }
- let(:current_poll_question_answer) { create(:poll_question_answer) }
- let(:future_poll_question_answer) { create(:poll_question_answer, poll: future_poll) }
- let(:current_poll_answer_video) { create(:poll_answer_video, answer: current_poll_question_answer) }
- let(:future_poll_answer_video) { create(:poll_answer_video, answer: future_poll_question_answer) }
- let(:current_poll_answer_image) { build(:image, imageable: current_poll_question_answer) }
- let(:future_poll_answer_image) { build(:image, imageable: future_poll_question_answer) }
- let(:current_poll_answer_document) { build(:document, documentable: current_poll_question_answer) }
- let(:future_poll_answer_document) { build(:document, documentable: future_poll_question_answer) }
+ let(:current_poll_question_option) { create(:poll_question_option) }
+ let(:future_poll_question_option) { create(:poll_question_option, poll: future_poll) }
+ let(:current_poll_option_video) { create(:poll_option_video, option: current_poll_question_option) }
+ let(:future_poll_option_video) { create(:poll_option_video, option: future_poll_question_option) }
+ let(:current_poll_option_image) { build(:image, imageable: current_poll_question_option) }
+ let(:future_poll_option_image) { build(:image, imageable: future_poll_question_option) }
+ let(:current_poll_option_document) { build(:document, documentable: current_poll_question_option) }
+ let(:future_poll_option_document) { build(:document, documentable: future_poll_question_option) }
let(:past_process) { create(:legislation_process, :past) }
let(:past_draft_process) { create(:legislation_process, :past, :not_published) }
@@ -131,27 +131,27 @@ describe Abilities::Administrator do
it { should_not be_able_to(:update, current_poll_question) }
it { should_not be_able_to(:destroy, current_poll_question) }
- it { should be_able_to(:read, Poll::Question::Answer) }
- it { should be_able_to(:order_answers, Poll::Question::Answer) }
- it { should be_able_to(:create, future_poll_question_answer) }
- it { should be_able_to(:update, future_poll_question_answer) }
- it { should be_able_to(:destroy, future_poll_question_answer) }
- it { should_not be_able_to(:create, current_poll_question_answer) }
- it { should_not be_able_to(:update, current_poll_question_answer) }
- it { should_not be_able_to(:destroy, current_poll_question_answer) }
+ it { should be_able_to(:read, Poll::Question::Option) }
+ it { should be_able_to(:order_options, Poll::Question::Option) }
+ it { should be_able_to(:create, future_poll_question_option) }
+ it { should be_able_to(:update, future_poll_question_option) }
+ it { should be_able_to(:destroy, future_poll_question_option) }
+ it { should_not be_able_to(:create, current_poll_question_option) }
+ it { should_not be_able_to(:update, current_poll_question_option) }
+ it { should_not be_able_to(:destroy, current_poll_question_option) }
- it { should be_able_to(:create, future_poll_answer_video) }
- it { should be_able_to(:update, future_poll_answer_video) }
- it { should be_able_to(:destroy, future_poll_answer_video) }
- it { should_not be_able_to(:create, current_poll_answer_video) }
- it { should_not be_able_to(:update, current_poll_answer_video) }
- it { should_not be_able_to(:destroy, current_poll_answer_video) }
+ it { should be_able_to(:create, future_poll_option_video) }
+ it { should be_able_to(:update, future_poll_option_video) }
+ it { should be_able_to(:destroy, future_poll_option_video) }
+ it { should_not be_able_to(:create, current_poll_option_video) }
+ it { should_not be_able_to(:update, current_poll_option_video) }
+ it { should_not be_able_to(:destroy, current_poll_option_video) }
- it { should be_able_to(:destroy, future_poll_answer_image) }
- it { should_not be_able_to(:destroy, current_poll_answer_image) }
+ it { should be_able_to(:destroy, future_poll_option_image) }
+ it { should_not be_able_to(:destroy, current_poll_option_image) }
- it { should be_able_to(:destroy, future_poll_answer_document) }
- it { should_not be_able_to(:destroy, current_poll_answer_document) }
+ it { should be_able_to(:destroy, future_poll_option_document) }
+ it { should_not be_able_to(:destroy, current_poll_option_document) }
it { is_expected.to be_able_to :manage, Dashboard::AdministratorTask }
it { is_expected.to be_able_to :manage, dashboard_administrator_task }
diff --git a/spec/models/poll/answer_spec.rb b/spec/models/poll/answer_spec.rb
index ac5acb402..fd77d5666 100644
--- a/spec/models/poll/answer_spec.rb
+++ b/spec/models/poll/answer_spec.rb
@@ -47,11 +47,11 @@ describe Poll::Answer do
expect(Poll::Answer.count).to be 2
end
- it "is valid for answers included in the Poll::Question's question_answers list" do
+ it "is valid for answers included in the Poll::Question's question_options list" do
question = create(:poll_question)
- create(:poll_question_answer, title: "One", question: question)
- create(:poll_question_answer, title: "Two", question: question)
- create(:poll_question_answer, title: "Three", question: question)
+ create(:poll_question_option, title: "One", question: question)
+ create(:poll_question_option, title: "Two", question: question)
+ create(:poll_question_option, title: "Three", question: question)
expect(build(:poll_answer, question: question, answer: "One")).to be_valid
expect(build(:poll_answer, question: question, answer: "Two")).to be_valid
diff --git a/spec/models/poll/partial_result_spec.rb b/spec/models/poll/partial_result_spec.rb
index 3e92379a2..2c05b69d2 100644
--- a/spec/models/poll/partial_result_spec.rb
+++ b/spec/models/poll/partial_result_spec.rb
@@ -4,9 +4,9 @@ describe Poll::PartialResult do
describe "validations" do
it "validates that the answers are included in the Poll::Question's list" do
question = create(:poll_question)
- create(:poll_question_answer, title: "One", question: question)
- create(:poll_question_answer, title: "Two", question: question)
- create(:poll_question_answer, title: "Three", question: question)
+ create(:poll_question_option, title: "One", question: question)
+ create(:poll_question_option, title: "Two", question: question)
+ create(:poll_question_option, title: "Three", question: question)
expect(build(:poll_partial_result, question: question, answer: "One")).to be_valid
expect(build(:poll_partial_result, question: question, answer: "Two")).to be_valid
diff --git a/spec/models/poll/question/answer_spec.rb b/spec/models/poll/question/answer_spec.rb
deleted file mode 100644
index 14777cad5..000000000
--- a/spec/models/poll/question/answer_spec.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-require "rails_helper"
-
-describe Poll::Question::Answer do
- it_behaves_like "globalizable", :poll_question_answer
-
- describe "#with_content" do
- it "returns answers with a description" do
- answer = create(:poll_question_answer, description: "I've got a description")
-
- expect(Poll::Question::Answer.with_content).to eq [answer]
- end
-
- it "returns answers with images and no description" do
- answer = create(:poll_question_answer, :with_image, description: "")
-
- expect(Poll::Question::Answer.with_content).to eq [answer]
- end
-
- it "returns answers with documents and no description" do
- answer = create(:poll_question_answer, :with_document, description: "")
-
- expect(Poll::Question::Answer.with_content).to eq [answer]
- end
-
- it "returns answers with videos and no description" do
- answer = create(:poll_question_answer, :with_video, description: "")
-
- expect(Poll::Question::Answer.with_content).to eq [answer]
- end
-
- it "does not return answers with no description and no images, documents nor videos" do
- create(:poll_question_answer, description: "")
-
- expect(Poll::Question::Answer.with_content).to be_empty
- end
- end
-
- describe "#with_read_more?" do
- it "returns false when the answer does not have description, images, videos nor documents" do
- answer = build(:poll_question_answer, description: nil)
-
- expect(answer.with_read_more?).to be_falsy
- end
-
- it "returns true when the answer has description, images, videos or documents" do
- answer = build(:poll_question_answer, description: "Answer description")
-
- expect(answer.with_read_more?).to be_truthy
-
- answer = build(:poll_question_answer, :with_image)
-
- expect(answer.with_read_more?).to be_truthy
-
- answer = build(:poll_question_answer, :with_document)
-
- expect(answer.with_read_more?).to be_truthy
-
- answer = build(:poll_question_answer, :with_video)
-
- expect(answer.with_read_more?).to be_truthy
- end
- end
-end
diff --git a/spec/models/poll/question/option_spec.rb b/spec/models/poll/question/option_spec.rb
new file mode 100644
index 000000000..f719064ff
--- /dev/null
+++ b/spec/models/poll/question/option_spec.rb
@@ -0,0 +1,63 @@
+require "rails_helper"
+
+describe Poll::Question::Option do
+ it_behaves_like "globalizable", :poll_question_option
+
+ describe "#with_content" do
+ it "returns options with a description" do
+ option = create(:poll_question_option, description: "I've got a description")
+
+ expect(Poll::Question::Option.with_content).to eq [option]
+ end
+
+ it "returns options with images and no description" do
+ option = create(:poll_question_option, :with_image, description: "")
+
+ expect(Poll::Question::Option.with_content).to eq [option]
+ end
+
+ it "returns options with documents and no description" do
+ option = create(:poll_question_option, :with_document, description: "")
+
+ expect(Poll::Question::Option.with_content).to eq [option]
+ end
+
+ it "returns options with videos and no description" do
+ option = create(:poll_question_option, :with_video, description: "")
+
+ expect(Poll::Question::Option.with_content).to eq [option]
+ end
+
+ it "does not return options with no description and no images, documents nor videos" do
+ create(:poll_question_option, description: "")
+
+ expect(Poll::Question::Option.with_content).to be_empty
+ end
+ end
+
+ describe "#with_read_more?" do
+ it "returns false when the option does not have description, images, videos nor documents" do
+ option = build(:poll_question_option, description: nil)
+
+ expect(option.with_read_more?).to be_falsy
+ end
+
+ it "returns true when the option has description, images, videos or documents" do
+ option = build(:poll_question_option, description: "Option description")
+
+ expect(option.with_read_more?).to be_truthy
+
+ option = build(:poll_question_option, :with_image)
+
+ expect(option.with_read_more?).to be_truthy
+
+ option = build(:poll_question_option, :with_document)
+
+ expect(option.with_read_more?).to be_truthy
+
+ option = build(:poll_question_option, :with_video)
+
+ expect(option.with_read_more?).to be_truthy
+ end
+ end
+end
diff --git a/spec/routing/polymorphic_routes_spec.rb b/spec/routing/polymorphic_routes_spec.rb
index 9810cfcda..ce2cca70b 100644
--- a/spec/routing/polymorphic_routes_spec.rb
+++ b/spec/routing/polymorphic_routes_spec.rb
@@ -115,9 +115,9 @@ describe "Polymorphic routes" do
end
it "routes poll answer videos" do
- video = create(:poll_answer_video)
+ video = create(:poll_option_video)
- expect(admin_polymorphic_path(video)).to eq admin_answer_video_path(video.answer, video)
+ expect(admin_polymorphic_path(video)).to eq admin_option_video_path(video.option, video)
end
it "routes milestones for resources with no hierarchy" do
diff --git a/spec/shared/system/nested_imageable.rb b/spec/shared/system/nested_imageable.rb
index d75404e8a..6121f0a0f 100644
--- a/spec/shared/system/nested_imageable.rb
+++ b/spec/shared/system/nested_imageable.rb
@@ -125,7 +125,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
end
scenario "Render image preview after sending the form with validation errors",
- unless: imageable_factory_name == "poll_question_answer" do
+ unless: imageable_factory_name == "poll_question_option" do
do_login_for user, management: management
visit send(path, arguments)
diff --git a/spec/system/admin/poll/booth_assigments_spec.rb b/spec/system/admin/poll/booth_assigments_spec.rb
index 59edff9d6..0402b0d39 100644
--- a/spec/system/admin/poll/booth_assigments_spec.rb
+++ b/spec/system/admin/poll/booth_assigments_spec.rb
@@ -236,8 +236,8 @@ describe "Admin booths assignments", :admin do
question_1 = create(:poll_question, :yes_no, poll: poll)
question_2 = create(:poll_question, poll: poll)
- create(:poll_question_answer, title: "Today", question: question_2)
- create(:poll_question_answer, title: "Tomorrow", question: question_2)
+ create(:poll_question_option, title: "Today", question: question_2)
+ create(:poll_question_option, title: "Tomorrow", question: question_2)
create(:poll_partial_result,
booth_assignment: booth_assignment,
diff --git a/spec/system/admin/poll/polls_spec.rb b/spec/system/admin/poll/polls_spec.rb
index 2b52e2182..272ee3268 100644
--- a/spec/system/admin/poll/polls_spec.rb
+++ b/spec/system/admin/poll/polls_spec.rb
@@ -133,12 +133,12 @@ describe "Admin polls", :admin do
expect(page).not_to have_content("Do you support CONSUL?")
expect(Poll::Question.count).to eq(0)
- expect(Poll::Question::Answer.count).to eq(0)
+ expect(Poll::Question::Option.count).to eq(0)
end
- scenario "Can destroy polls with answers including videos" do
+ scenario "Can destroy polls with options including videos" do
poll = create(:poll, name: "Do you support CONSUL?")
- create(:poll_answer_video, poll: poll)
+ create(:poll_option_video, poll: poll)
visit admin_polls_path
@@ -354,12 +354,12 @@ describe "Admin polls", :admin do
booth_assignment_3 = create(:poll_booth_assignment, poll: poll)
question_1 = create(:poll_question, poll: poll)
- create(:poll_question_answer, title: "Oui", question: question_1)
- create(:poll_question_answer, title: "Non", question: question_1)
+ create(:poll_question_option, title: "Oui", question: question_1)
+ create(:poll_question_option, title: "Non", question: question_1)
question_2 = create(:poll_question, poll: poll)
- create(:poll_question_answer, title: "Aujourd'hui", question: question_2)
- create(:poll_question_answer, title: "Demain", question: question_2)
+ create(:poll_question_option, title: "Aujourd'hui", question: question_2)
+ create(:poll_question_option, title: "Demain", question: question_2)
[booth_assignment_1, booth_assignment_2, booth_assignment_3].each do |ba|
create(:poll_partial_result,
@@ -430,8 +430,8 @@ describe "Admin polls", :admin do
question_1 = create(:poll_question, :yes_no, poll: poll)
question_2 = create(:poll_question, poll: poll)
- create(:poll_question_answer, title: "Today", question: question_2)
- create(:poll_question_answer, title: "Tomorrow", question: question_2)
+ create(:poll_question_option, title: "Today", question: question_2)
+ create(:poll_question_option, title: "Tomorrow", question: question_2)
[booth_assignment_1, booth_assignment_2, booth_assignment_3].each do |ba|
create(:poll_partial_result,
@@ -456,17 +456,17 @@ describe "Admin polls", :admin do
click_link "Results"
expect(page).to have_content(question_1.title)
- question_1.question_answers.each_with_index do |answer, i|
+ question_1.question_options.each_with_index do |option, i|
within("#question_#{question_1.id}_#{i}_result") do
- expect(page).to have_content(answer.title)
+ expect(page).to have_content(option.title)
expect(page).to have_content([33, 0][i])
end
end
expect(page).to have_content(question_2.title)
- question_2.question_answers.each_with_index do |answer, i|
+ question_2.question_options.each_with_index do |option, i|
within("#question_#{question_2.id}_#{i}_result") do
- expect(page).to have_content(answer.title)
+ expect(page).to have_content(option.title)
expect(page).to have_content([0, 15][i])
end
end
diff --git a/spec/system/admin/poll/questions/answers/documents/documents_spec.rb b/spec/system/admin/poll/questions/options/documents/documents_spec.rb
similarity index 63%
rename from spec/system/admin/poll/questions/answers/documents/documents_spec.rb
rename to spec/system/admin/poll/questions/options/documents/documents_spec.rb
index 9a65fc182..b3611c4c3 100644
--- a/spec/system/admin/poll/questions/answers/documents/documents_spec.rb
+++ b/spec/system/admin/poll/questions/options/documents/documents_spec.rb
@@ -4,31 +4,31 @@ describe "Documents", :admin do
let(:future_poll) { create(:poll, :future) }
context "Index" do
- scenario "Answer with no documents" do
- answer = create(:poll_question_answer)
+ scenario "Option with no documents" do
+ option = create(:poll_question_option)
document = create(:document)
- visit admin_answer_documents_path(answer)
+ visit admin_option_documents_path(option)
expect(page).not_to have_content(document.title)
- expect(page).to have_link "Go back", href: admin_question_path(answer.question)
+ expect(page).to have_link "Go back", href: admin_question_path(option.question)
end
- scenario "Answer with documents" do
- answer = create(:poll_question_answer)
- document = create(:document, documentable: answer)
+ scenario "Option with documents" do
+ option = create(:poll_question_option)
+ document = create(:document, documentable: option)
- visit admin_answer_documents_path(answer)
+ visit admin_option_documents_path(option)
expect(page).to have_content(document.title)
end
end
- describe "Create document for answer" do
+ describe "Create document for option" do
scenario "with valid data" do
- answer = create(:poll_question_answer, poll: future_poll)
+ option = create(:poll_question_option, poll: future_poll)
- visit admin_answer_documents_path(answer)
+ visit admin_option_documents_path(option)
expect(page).not_to have_link "Download file"
@@ -43,9 +43,9 @@ describe "Documents", :admin do
end
scenario "with invalid data" do
- answer = create(:poll_question_answer, poll: future_poll)
+ option = create(:poll_question_option, poll: future_poll)
- visit admin_answer_documents_path(answer)
+ visit admin_option_documents_path(option)
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/clippy.pdf"))
fill_in "Title", with: ""
@@ -56,11 +56,11 @@ describe "Documents", :admin do
end
end
- scenario "Remove document from answer" do
- answer = create(:poll_question_answer, poll: future_poll)
- document = create(:document, documentable: answer)
+ scenario "Remove document from option" do
+ option = create(:poll_question_option, poll: future_poll)
+ document = create(:document, documentable: option)
- visit admin_answer_documents_path(answer)
+ visit admin_option_documents_path(option)
expect(page).to have_content(document.title)
accept_confirm("Are you sure? This action will delete \"#{document.title}\" and can't be undone.") do
diff --git a/spec/system/admin/poll/questions/answers/images/images_spec.rb b/spec/system/admin/poll/questions/options/images/images_spec.rb
similarity index 65%
rename from spec/system/admin/poll/questions/answers/images/images_spec.rb
rename to spec/system/admin/poll/questions/options/images/images_spec.rb
index a6e35acc8..53558072e 100644
--- a/spec/system/admin/poll/questions/answers/images/images_spec.rb
+++ b/spec/system/admin/poll/questions/options/images/images_spec.rb
@@ -5,39 +5,39 @@ describe "Images", :admin do
let(:current_poll) { create(:poll) }
it_behaves_like "nested imageable",
- "future_poll_question_answer",
- "new_admin_answer_image_path",
- { answer_id: "id" },
+ "future_poll_question_option",
+ "new_admin_option_image_path",
+ { option_id: "id" },
nil,
"Save image",
"Image uploaded successfully",
true
context "Index" do
- scenario "Answer with no images" do
- answer = create(:poll_question_answer)
+ scenario "Option with no images" do
+ option = create(:poll_question_option)
- visit admin_answer_images_path(answer)
+ visit admin_option_images_path(option)
expect(page).not_to have_css("img[title='']")
end
- scenario "Answer with images" do
- answer = create(:poll_question_answer)
- image = create(:image, imageable: answer)
+ scenario "Option with images" do
+ option = create(:poll_question_option)
+ image = create(:image, imageable: option)
- visit admin_answer_images_path(answer)
+ visit admin_option_images_path(option)
expect(page).to have_css("img[title='#{image.title}']")
expect(page).to have_content(image.title)
end
end
- describe "Add image to answer" do
+ describe "Add image to option" do
scenario "Is possible for a not started poll" do
- answer = create(:poll_question_answer, poll: future_poll)
+ option = create(:poll_question_option, poll: future_poll)
- visit admin_answer_images_path(answer)
+ visit admin_option_images_path(option)
expect(page).not_to have_css "img[title='clippy.jpg']"
expect(page).not_to have_content "clippy.jpg"
@@ -54,21 +54,21 @@ describe "Images", :admin do
end
scenario "Is not possible for an already started poll" do
- answer = create(:poll_question_answer, poll: current_poll)
+ option = create(:poll_question_option, poll: current_poll)
- visit admin_answer_images_path(answer)
+ visit admin_option_images_path(option)
expect(page).not_to have_link "Add image"
expect(page).to have_content "Once the poll has started it will not be possible to create, edit or"
end
end
- describe "Remove image from answer" do
+ describe "Remove image from option" do
scenario "Is possible for a not started poll" do
- answer = create(:poll_question_answer, poll: future_poll)
- image = create(:image, imageable: answer)
+ option = create(:poll_question_option, poll: future_poll)
+ image = create(:image, imageable: option)
- visit admin_answer_images_path(answer)
+ visit admin_option_images_path(option)
expect(page).to have_css "img[title='#{image.title}']"
expect(page).to have_content image.title
@@ -81,10 +81,10 @@ describe "Images", :admin do
end
scenario "Is not possible for an already started poll" do
- answer = create(:poll_question_answer, poll: current_poll)
- image = create(:image, imageable: answer)
+ option = create(:poll_question_option, poll: current_poll)
+ image = create(:image, imageable: option)
- visit admin_answer_images_path(answer)
+ visit admin_option_images_path(option)
expect(page).to have_css "img[title='#{image.title}']"
expect(page).to have_content image.title
diff --git a/spec/system/admin/poll/questions/answers/answers_spec.rb b/spec/system/admin/poll/questions/options/options_spec.rb
similarity index 85%
rename from spec/system/admin/poll/questions/answers/answers_spec.rb
rename to spec/system/admin/poll/questions/options/options_spec.rb
index 21e53e2b1..6f79f8378 100644
--- a/spec/system/admin/poll/questions/answers/answers_spec.rb
+++ b/spec/system/admin/poll/questions/options/options_spec.rb
@@ -1,6 +1,6 @@
require "rails_helper"
-describe "Answers", :admin do
+describe "Poll question options", :admin do
let(:future_poll) { create(:poll, :future) }
let(:current_poll) { create(:poll) }
@@ -34,7 +34,7 @@ describe "Answers", :admin do
scenario "Create second answer and place after the first one" do
question = create(:poll_question, poll: future_poll)
- create(:poll_question_answer, title: "First", question: question, given_order: 1)
+ create(:poll_question_option, title: "First", question: question, given_order: 1)
visit admin_question_path(question)
click_link "Add answer"
@@ -50,8 +50,8 @@ describe "Answers", :admin do
scenario "Update" do
question = create(:poll_question, poll: future_poll)
- create(:poll_question_answer, question: question, title: "Answer title", given_order: 2)
- create(:poll_question_answer, question: question, title: "Another title", given_order: 1)
+ create(:poll_question_option, question: question, title: "Answer title", given_order: 2)
+ create(:poll_question_option, question: question, title: "Another title", given_order: 1)
visit admin_question_path(question)
within("tr", text: "Answer title") { click_link "Edit" }
@@ -72,9 +72,9 @@ describe "Answers", :admin do
end
scenario "Destroy" do
- answer = create(:poll_question_answer, poll: future_poll, title: "I'm not useful")
+ option = create(:poll_question_option, poll: future_poll, title: "I'm not useful")
- visit admin_question_path(answer.question)
+ visit admin_question_path(option.question)
within("tr", text: "I'm not useful") do
accept_confirm("Are you sure? This action will delete \"I'm not useful\" and can't be undone.") do
@@ -88,8 +88,8 @@ describe "Answers", :admin do
scenario "Reorder" do
question = create(:poll_question)
- create(:poll_question_answer, question: question, title: "First", given_order: 1)
- create(:poll_question_answer, question: question, title: "Last", given_order: 2)
+ create(:poll_question_option, question: question, title: "First", given_order: 1)
+ create(:poll_question_option, question: question, title: "Last", given_order: 2)
visit admin_question_path(question)
diff --git a/spec/system/admin/poll/questions/answers/videos/videos_spec.rb b/spec/system/admin/poll/questions/options/videos/videos_spec.rb
similarity index 74%
rename from spec/system/admin/poll/questions/answers/videos/videos_spec.rb
rename to spec/system/admin/poll/questions/options/videos/videos_spec.rb
index 67278fbdd..c903f4e51 100644
--- a/spec/system/admin/poll/questions/answers/videos/videos_spec.rb
+++ b/spec/system/admin/poll/questions/options/videos/videos_spec.rb
@@ -9,11 +9,11 @@ describe "Videos", :admin do
describe "Create" do
scenario "Is possible for a not started poll" do
question = create(:poll_question, poll: future_poll)
- answer = create(:poll_question_answer, question: question)
+ option = create(:poll_question_option, question: question)
visit admin_question_path(question)
- within("#poll_question_answer_#{answer.id}") do
+ within("#poll_question_option_#{option.id}") do
click_link "Video list"
end
click_link "Add video"
@@ -29,9 +29,9 @@ describe "Videos", :admin do
end
scenario "Is not possible for an already started poll" do
- answer = create(:poll_question_answer, poll: current_poll)
+ option = create(:poll_question_option, poll: current_poll)
- visit admin_answer_videos_path(answer)
+ visit admin_option_videos_path(option)
expect(page).not_to have_link "Add video"
expect(page).to have_content "Once the poll has started it will not be possible to create, edit or"
@@ -39,11 +39,11 @@ describe "Videos", :admin do
end
scenario "Update" do
- video = create(:poll_answer_video, poll: future_poll)
+ video = create(:poll_option_video, poll: future_poll)
- visit edit_admin_answer_video_path(video.answer, video)
+ visit edit_admin_option_video_path(video.option, video)
- expect(page).to have_link "Go back", href: admin_answer_videos_path(video.answer)
+ expect(page).to have_link "Go back", href: admin_option_videos_path(video.option)
fill_in "Title", with: title
fill_in "External video", with: url
@@ -56,9 +56,9 @@ describe "Videos", :admin do
end
scenario "Destroy" do
- video = create(:poll_answer_video, poll: future_poll)
+ video = create(:poll_option_video, poll: future_poll)
- visit admin_answer_videos_path(video.answer)
+ visit admin_option_videos_path(video.option)
within("tr", text: video.title) do
accept_confirm("Are you sure? This action will delete \"#{video.title}\" and can't be undone.") do
diff --git a/spec/system/admin/translatable_spec.rb b/spec/system/admin/translatable_spec.rb
index b65513649..51e25ce9a 100644
--- a/spec/system/admin/translatable_spec.rb
+++ b/spec/system/admin/translatable_spec.rb
@@ -215,8 +215,8 @@ describe "Admin edit translatable records", :admin do
end
context "CKEditor fields" do
- let(:translatable) { create(:poll_question_answer, poll: create(:poll, :future)) }
- let(:path) { edit_admin_question_answer_path(translatable.question, translatable) }
+ let(:translatable) { create(:poll_question_option, poll: create(:poll, :future)) }
+ let(:path) { edit_admin_question_option_path(translatable.question, translatable) }
scenario "Changes the existing translation" do
visit path
diff --git a/spec/system/officing/results_spec.rb b/spec/system/officing/results_spec.rb
index 8f65e714c..a3147093d 100644
--- a/spec/system/officing/results_spec.rb
+++ b/spec/system/officing/results_spec.rb
@@ -9,11 +9,11 @@ describe "Officing Results", :with_frozen_time do
before do
create(:poll_shift, :recount_scrutiny_task, officer: poll_officer, booth: booth, date: Date.current)
- create(:poll_question_answer, title: "Yes", question: question_1, given_order: 1)
- create(:poll_question_answer, title: "No", question: question_1, given_order: 2)
+ create(:poll_question_option, title: "Yes", question: question_1, given_order: 1)
+ create(:poll_question_option, title: "No", question: question_1, given_order: 2)
- create(:poll_question_answer, title: "Today", question: question_2, given_order: 1)
- create(:poll_question_answer, title: "Tomorrow", question: question_2, given_order: 2)
+ create(:poll_question_option, title: "Today", question: question_2, given_order: 1)
+ create(:poll_question_option, title: "Tomorrow", question: question_2, given_order: 2)
login_as(poll_officer.user)
set_officing_booth(booth)
@@ -86,7 +86,7 @@ describe "Officing Results", :with_frozen_time do
booth_assignment: poll_officer.officer_assignments.first.booth_assignment,
date: Date.current,
question: question_1,
- answer: question_1.question_answers.first.title,
+ answer: question_1.question_options.first.title,
author: poll_officer.user,
amount: 7777
)
@@ -160,12 +160,12 @@ describe "Officing Results", :with_frozen_time do
expect(page).to have_content(booth.name)
expect(page).to have_content(question_1.title)
- question_1.question_answers.each_with_index do |answer, i|
+ question_1.question_options.each_with_index do |answer, i|
within("#question_#{question_1.id}_#{i}_result") { expect(page).to have_content(answer.title) }
end
expect(page).to have_content(question_2.title)
- question_2.question_answers.each_with_index do |answer, i|
+ question_2.question_options.each_with_index do |answer, i|
within("#question_#{question_2.id}_#{i}_result") { expect(page).to have_content(answer.title) }
end
diff --git a/spec/system/polls/polls_spec.rb b/spec/system/polls/polls_spec.rb
index c8b286c9a..ffde159e0 100644
--- a/spec/system/polls/polls_spec.rb
+++ b/spec/system/polls/polls_spec.rb
@@ -152,8 +152,8 @@ describe "Polls" do
scenario "Buttons to slide through images work back and forth" do
question = create(:poll_question, :yes_no, poll: poll)
- create(:image, imageable: question.question_answers.last, title: "The no movement")
- create(:image, imageable: question.question_answers.last, title: "No movement planning")
+ create(:image, imageable: question.question_options.last, title: "The no movement")
+ create(:image, imageable: question.question_options.last, title: "No movement planning")
visit poll_path(poll)
diff --git a/spec/system/polls/questions_spec.rb b/spec/system/polls/questions_spec.rb
index a655a2677..b6b92e215 100644
--- a/spec/system/polls/questions_spec.rb
+++ b/spec/system/polls/questions_spec.rb
@@ -13,8 +13,8 @@ describe "Poll Questions" do
scenario "shows answers with an image and no description" do
poll = create(:poll)
- answer = create(:poll_question_answer, poll: poll, title: "Pedestrian road", description: "")
- create(:image, imageable: answer, title: "Trees on both sides of the road")
+ option = create(:poll_question_option, poll: poll, title: "Pedestrian road", description: "")
+ create(:image, imageable: option, title: "Trees on both sides of the road")
visit poll_path(poll)
diff --git a/spec/system/polls/results_spec.rb b/spec/system/polls/results_spec.rb
index 2fbfe82a1..b9549e703 100644
--- a/spec/system/polls/results_spec.rb
+++ b/spec/system/polls/results_spec.rb
@@ -8,13 +8,13 @@ describe "Poll Results" do
poll = create(:poll, results_enabled: true)
question1 = create(:poll_question, poll: poll)
- answer1 = create(:poll_question_answer, question: question1, title: "Yes")
- answer2 = create(:poll_question_answer, question: question1, title: "No")
+ answer1 = create(:poll_question_option, question: question1, title: "Yes")
+ answer2 = create(:poll_question_option, question: question1, title: "No")
question2 = create(:poll_question, poll: poll)
- answer3 = create(:poll_question_answer, question: question2, title: "Blue")
- answer4 = create(:poll_question_answer, question: question2, title: "Green")
- answer5 = create(:poll_question_answer, question: question2, title: "Yellow")
+ answer3 = create(:poll_question_option, question: question2, title: "Blue")
+ answer4 = create(:poll_question_option, question: question2, title: "Green")
+ answer5 = create(:poll_question_option, question: question2, title: "Yellow")
login_as user1
vote_for_poll_via_web(poll, question1, "Yes")