Merge pull request #1972 from consul/1954-remove_question_show_and_description
Removed poll question show view and description attribute
This commit is contained in:
@@ -56,7 +56,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
|
||||
private
|
||||
|
||||
def question_params
|
||||
params.require(:poll_question).permit(:poll_id, :title, :question, :description, :proposal_id, :valid_answers, :video_url,
|
||||
params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id, :valid_answers, :video_url,
|
||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
|
||||
end
|
||||
|
||||
|
||||
@@ -5,15 +5,6 @@ class Polls::QuestionsController < ApplicationController
|
||||
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
|
||||
def show
|
||||
@commentable = @question.proposal.present? ? @question.proposal : @question
|
||||
@comment_tree = CommentTree.new(@commentable, params[:page], @current_order)
|
||||
set_comment_flags(@comment_tree.comments)
|
||||
|
||||
question_answer = @question.answers.where(author_id: current_user.try(:id)).first
|
||||
@answers_by_question_id = {@question.id => question_answer.try(:answer)}
|
||||
end
|
||||
|
||||
def answer
|
||||
answer = @question.answers.find_or_initialize_by(author: current_user)
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ class Poll::Question < ActiveRecord::Base
|
||||
validates :poll_id, presence: true
|
||||
|
||||
validates :title, length: { minimum: 4 }
|
||||
validates :description, length: { maximum: Poll::Question.description_max_length }
|
||||
|
||||
scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) }
|
||||
|
||||
@@ -40,15 +39,10 @@ class Poll::Question < ActiveRecord::Base
|
||||
def searchable_values
|
||||
{ title => 'A',
|
||||
proposal.try(:title) => 'A',
|
||||
description => 'B',
|
||||
author.username => 'C',
|
||||
author_visible_name => 'C' }
|
||||
end
|
||||
|
||||
def description
|
||||
super.try :html_safe
|
||||
end
|
||||
|
||||
def valid_answers
|
||||
(super.try(:split, ',').compact || []).map(&:strip)
|
||||
end
|
||||
@@ -59,7 +53,6 @@ class Poll::Question < ActiveRecord::Base
|
||||
self.author_visible_name = proposal.author.name
|
||||
self.proposal_id = proposal.id
|
||||
self.title = proposal.title
|
||||
self.description = proposal.description
|
||||
self.valid_answers = I18n.t('poll_questions.default_valid_answers')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,12 +20,6 @@
|
||||
<p class="help-text" id="valid-answers-help-text"><%= t("admin.questions.new.valid_answers_note") %></p>
|
||||
<%= f.text_field :valid_answers, label: false, aria: {describedby: "valid-answers-help-text"} %>
|
||||
|
||||
<div class="ckeditor">
|
||||
<%= f.cktext_area :description,
|
||||
maxlength: Poll::Question.description_max_length,
|
||||
ckeditor: { language: I18n.locale } %>
|
||||
</div>
|
||||
|
||||
<div class="documents small-12">
|
||||
<%= render 'documents/nested_documents', documentable: @question, f: f %>
|
||||
</div>
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<strong><%= t("admin.questions.show.description") %></strong>
|
||||
<br>
|
||||
<%= @question.description %>
|
||||
</p>
|
||||
|
||||
<% if @question.video_url.present? %>
|
||||
<p>
|
||||
<strong><%= t("admin.questions.show.video_url") %></strong>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<%= poll_dates(poll) %>
|
||||
<ul class="margin-top">
|
||||
<% poll.questions.each do |question| %>
|
||||
<li><%= link_to question.title, question_path(question) %></li>
|
||||
<li><%= question.title %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@commentable), @comment_tree.comments, @comment_tree.comment_authors, @commentable.comments_count, @comment_flags] do %>
|
||||
<section class="row-full comments">
|
||||
<div class="row">
|
||||
<div id="comments" class="small-12 column">
|
||||
<h2>
|
||||
<%= t("shared.comments.title") %>
|
||||
<span class="js-comments-count">(<%= @commentable.comments_count %>)</span>
|
||||
</h2>
|
||||
|
||||
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
||||
|
||||
<% if user_signed_in? %>
|
||||
<%= render 'comments/form', {commentable: @commentable, parent_id: nil, toggeable: false} %>
|
||||
<% else %>
|
||||
<br>
|
||||
|
||||
<div data-alert class="callout primary">
|
||||
<%= t("shared.comments.login_to_comment",
|
||||
signin: link_to(t("votes.signin"), new_user_session_path),
|
||||
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% @comment_tree.root_comments.each do |comment| %>
|
||||
<%= render 'comments/comment', comment: comment %>
|
||||
<% end %>
|
||||
<%= paginate @comment_tree.root_comments %>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<% end %>
|
||||
@@ -1,22 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<ul class="tabs" data-tabs id="questions-tabs">
|
||||
<li class="tabs-title is-active">
|
||||
<%= link_to "#tab-comments" do %>
|
||||
<h3>
|
||||
<%= t("proposals.show.comments_tab") %>
|
||||
<span class="js-comments-count">(<%= @question.comments_count %>)</span>
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-documents" do %>
|
||||
<h3>
|
||||
<%= t("documents.tab") %>
|
||||
(<%= @question.documents.count %>)
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<div id="<%= dom_id(question) %>" class="poll-question">
|
||||
<h3>
|
||||
<%= link_to question.title, question_path(question) %>
|
||||
<%= question.title %>
|
||||
</h3>
|
||||
|
||||
<div id="<%= dom_id(question) %>_answers" class="padding">
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<% provide :title do %><%= @question.title %><% end %>
|
||||
|
||||
<div class="expanded no-margin-top dark-heading">
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column padding">
|
||||
<%= back_link_to %>
|
||||
|
||||
<h1><%= @question.title %></h1>
|
||||
|
||||
<% if @question.proposal.present? %>
|
||||
<div class="margin-bottom">
|
||||
<%= link_to t('poll_questions.show.original_proposal'), @question.proposal %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if can? :answer, @question %>
|
||||
<%= link_to t('poll_questions.show.answer_this_question'),
|
||||
@question.poll,
|
||||
class: 'large button' %>
|
||||
<% else %>
|
||||
<%= render 'polls/reasons_for_not_answering', poll: @question.poll %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column info">
|
||||
<p>
|
||||
<span class="title">
|
||||
<strong><%= t('poll_questions.show.author') %></strong>
|
||||
</span>
|
||||
<br>
|
||||
<% if @question.author_visible_name.present? %>
|
||||
<%= @question.author_visible_name %>
|
||||
<% else %>
|
||||
<%= link_to @question.author.name, @question.author %>
|
||||
<% end %>
|
||||
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span class="title">
|
||||
<strong><%= t('poll_questions.show.poll') %></strong>
|
||||
</span>
|
||||
<br>
|
||||
<%= link_to @question.poll.name, @question.poll %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span class="title">
|
||||
<strong><%= t('poll_questions.show.dates_title') %></strong>
|
||||
</span>
|
||||
<br>
|
||||
<%= poll_dates(@question.poll) %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @question.video_url.present? %>
|
||||
<div class="row margin-top poll-question-show">
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="video-link">
|
||||
<p>
|
||||
<span class="icon-video"></span>
|
||||
<strong><%= t('proposals.show.title_video_url') %></strong>
|
||||
</p>
|
||||
<%= text_with_links @question.video_url %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<div class="row margin-top">
|
||||
<div class="small-12 medium-9 column">
|
||||
<h3><%= t('poll_questions.show.more_info') %></h3>
|
||||
<%= @question.description %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tabs-content" data-tabs-content="questions-tabs" role="tablist">
|
||||
<%= render "polls/questions/filter_subnav" %>
|
||||
|
||||
<div class="tabs-panel is-active" id="tab-comments">
|
||||
<%= render "polls/questions/comments" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-documents">
|
||||
<%= render 'documents/documents',
|
||||
documents: @question.documents,
|
||||
max_documents_allowed: Poll::Question.max_documents_allowed %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -593,7 +593,6 @@ en:
|
||||
author: Author
|
||||
title: Title
|
||||
valid_answers: Valid answers
|
||||
description: Description
|
||||
video_url: External video
|
||||
documents: Documents (1)
|
||||
recounts:
|
||||
|
||||
@@ -494,11 +494,6 @@ en:
|
||||
create_question: "Create question"
|
||||
default_valid_answers: "Yes, No"
|
||||
show:
|
||||
answer_this_question: "Go to voting page"
|
||||
original_proposal: "Original proposal"
|
||||
author: "Created by"
|
||||
dates_title: "Participation dates"
|
||||
more_info: "More information"
|
||||
not_logged_in: "You must %{signin} or %{signup} to participate."
|
||||
signin: Sign in
|
||||
signup: Sign up
|
||||
@@ -509,7 +504,6 @@ en:
|
||||
cant_answer_wrong_geozone: "This question is not available on your geozone."
|
||||
vote_answer: "Vote %{answer}"
|
||||
voted: "You have voted %{answer}"
|
||||
poll: "Poll"
|
||||
proposal_notifications:
|
||||
new:
|
||||
title: "Send message"
|
||||
@@ -524,9 +518,6 @@ en:
|
||||
edit: 'Edit'
|
||||
save: 'Save'
|
||||
delete: 'Delete'
|
||||
comments:
|
||||
title: 'Comments'
|
||||
login_to_comment: 'You must %{signin} or %{signup} to leave a comment.'
|
||||
"yes": "Yes"
|
||||
"no": "No"
|
||||
search_results: "Search results"
|
||||
|
||||
@@ -593,7 +593,6 @@ es:
|
||||
author: Autor
|
||||
title: Título
|
||||
valid_answers: Respuestas válidas
|
||||
description: Descripción
|
||||
video_url: Video externo
|
||||
documents: Documentos (1)
|
||||
recounts:
|
||||
|
||||
@@ -494,11 +494,6 @@ es:
|
||||
create_question: "Crear pregunta para votación"
|
||||
default_valid_answers: "Sí, No"
|
||||
show:
|
||||
answer_this_question: "Responder a esta pregunta"
|
||||
original_proposal: "Propuesta original"
|
||||
author: "Creado por"
|
||||
dates_title: "Fechas de participación"
|
||||
more_info: "Más información"
|
||||
not_logged_in: "Necesitas %{signin} o %{signup} para participar."
|
||||
signin: iniciar sesión
|
||||
signup: registrarte
|
||||
@@ -509,7 +504,6 @@ es:
|
||||
cant_answer_wrong_geozone: "Esta votación no está disponible en tu zona."
|
||||
vote_answer: "Votar %{answer}"
|
||||
voted: "Has votado %{answer}"
|
||||
poll: "Votación"
|
||||
proposal_notifications:
|
||||
new:
|
||||
title: "Enviar mensaje"
|
||||
@@ -524,9 +518,6 @@ es:
|
||||
edit: 'Editar'
|
||||
save: 'Guardar'
|
||||
delete: 'Borrar'
|
||||
comments:
|
||||
title: 'Comentarios'
|
||||
login_to_comment: 'Necesitas %{signin} o %{signup} para comentar.'
|
||||
"yes": "Sí"
|
||||
"no": "No"
|
||||
search_results: "Resultados de búsqueda"
|
||||
|
||||
@@ -113,7 +113,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
resources :polls, only: [:show, :index] do
|
||||
resources :questions, only: [:show], controller: 'polls/questions', shallow: true do
|
||||
resources :questions, controller: 'polls/questions', shallow: true do
|
||||
post :answer, on: :member
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class RemoveDescriptionFromPollQuestions < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :poll_questions, :description
|
||||
end
|
||||
end
|
||||
@@ -675,7 +675,6 @@ ActiveRecord::Schema.define(version: 20171003223152) do
|
||||
t.string "author_visible_name"
|
||||
t.string "title"
|
||||
t.string "valid_answers"
|
||||
t.text "description"
|
||||
t.integer "comments_count"
|
||||
t.datetime "hidden_at"
|
||||
t.datetime "created_at"
|
||||
|
||||
@@ -498,7 +498,6 @@ FactoryGirl.define do
|
||||
poll
|
||||
association :author, factory: :user
|
||||
sequence(:title) { |n| "Question title #{n}" }
|
||||
sequence(:description) { |n| "Question description #{n}" }
|
||||
valid_answers { Faker::Lorem.words(3).join(', ') }
|
||||
end
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ feature 'Admin poll questions' do
|
||||
visit admin_question_path(question)
|
||||
|
||||
expect(page).to have_content(question.title)
|
||||
expect(page).to have_content(question.description)
|
||||
expect(page).to have_content(question.author.name)
|
||||
expect(page).to have_content(question.valid_answers.join(" "))
|
||||
end
|
||||
@@ -45,13 +44,11 @@ feature 'Admin poll questions' do
|
||||
|
||||
select 'Movies', from: 'poll_question_poll_id'
|
||||
fill_in 'poll_question_title', with: title
|
||||
fill_in 'poll_question_description', with: description
|
||||
fill_in 'poll_question_video_url', with: video_url
|
||||
|
||||
click_button 'Save'
|
||||
|
||||
expect(page).to have_content(title)
|
||||
expect(page).to have_content(description)
|
||||
expect(page).to have_content(video_url)
|
||||
end
|
||||
|
||||
@@ -64,7 +61,6 @@ feature 'Admin poll questions' do
|
||||
|
||||
expect(current_path).to eq(new_admin_question_path)
|
||||
expect(page).to have_field('poll_question_title', with: proposal.title)
|
||||
expect(page).to have_field('poll_question_description', with: proposal.description)
|
||||
expect(page).to have_field('poll_question_valid_answers', with: "Yes, No")
|
||||
|
||||
select 'Proposals', from: 'poll_question_poll_id'
|
||||
@@ -72,7 +68,6 @@ feature 'Admin poll questions' do
|
||||
click_button 'Save'
|
||||
|
||||
expect(page).to have_content(proposal.title)
|
||||
expect(page).to have_content(proposal.description)
|
||||
expect(page).to have_link(proposal.title, href: proposal_path(proposal))
|
||||
expect(page).to have_link(proposal.author.name, href: user_path(proposal.author))
|
||||
end
|
||||
|
||||
@@ -11,121 +11,4 @@ feature 'Poll Questions' do
|
||||
|
||||
expect(proposal_question.title).to appear_before(normal_question.title)
|
||||
end
|
||||
|
||||
scenario 'shows the author visible name instead of a link to the author' do
|
||||
poll = create(:poll)
|
||||
question_with_author = create(:poll_question, poll: poll)
|
||||
question_with_author_visible_name = create(:poll_question, poll: poll, author_visible_name: 'potato')
|
||||
|
||||
visit question_path(question_with_author)
|
||||
expect(page).to have_link(question_with_author.author.name)
|
||||
|
||||
visit question_path(question_with_author_visible_name)
|
||||
expect(page).to_not have_link(question_with_author_visible_name.author.name)
|
||||
expect(page).to have_content(question_with_author_visible_name.author_visible_name)
|
||||
end
|
||||
|
||||
scenario '#show view has video_url present' do
|
||||
poll = create(:poll)
|
||||
normal_question = create(:poll_question, poll: poll, video_url: "https://puppyvideos.com")
|
||||
|
||||
visit question_path(normal_question)
|
||||
|
||||
expect(page).to have_link(normal_question.video_url)
|
||||
end
|
||||
|
||||
scenario '#show view has document present' do
|
||||
poll = create(:poll)
|
||||
normal_question = create(:poll_question, poll: poll)
|
||||
document = create(:document, documentable: normal_question)
|
||||
|
||||
visit question_path(normal_question)
|
||||
|
||||
expect(page).to have_content(document.title)
|
||||
end
|
||||
|
||||
context 'Answering' do
|
||||
let(:geozone) { create(:geozone) }
|
||||
let(:poll) { create(:poll, geozone_restricted: true, geozone_ids: [geozone.id]) }
|
||||
|
||||
scenario 'Non-logged in users' do
|
||||
question = create(:poll_question, valid_answers: 'Han Solo, Chewbacca')
|
||||
|
||||
visit question_path(question)
|
||||
|
||||
expect(page).to have_content('You must Sign in or Sign up to participate')
|
||||
end
|
||||
|
||||
scenario 'Level 1 users' do
|
||||
question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca')
|
||||
|
||||
login_as(create(:user, geozone: geozone))
|
||||
visit question_path(question)
|
||||
|
||||
expect(page).to have_content('You must verify your account in order to answer')
|
||||
end
|
||||
|
||||
scenario 'Level 2 users in an poll question for a geozone which is not theirs' do
|
||||
|
||||
other_poll = create(:poll, geozone_restricted: true, geozone_ids: [create(:geozone).id])
|
||||
question = create(:poll_question, poll: other_poll, valid_answers: 'Vader, Palpatine')
|
||||
|
||||
login_as(create(:user, :level_two, geozone: geozone))
|
||||
visit question_path(question)
|
||||
|
||||
expect(page).to have_content('This question is not available on your geozone')
|
||||
end
|
||||
|
||||
scenario 'Level 2 users who can answer' do
|
||||
question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca')
|
||||
|
||||
login_as(create(:user, :level_two, geozone: geozone))
|
||||
visit question_path(question)
|
||||
|
||||
expect(page).to have_link('Go to voting page')
|
||||
end
|
||||
|
||||
scenario 'Level 2 users who have already answered' do
|
||||
question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca')
|
||||
|
||||
user = create(:user, :level_two, geozone: geozone)
|
||||
create(:poll_answer, question: question, author: user, answer: 'Chewbacca')
|
||||
|
||||
login_as user
|
||||
visit question_path(question)
|
||||
|
||||
expect(page).to have_link('Go to voting page')
|
||||
end
|
||||
|
||||
scenario 'Level 2 users answering', :js do
|
||||
question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca')
|
||||
user = create(:user, :level_two, geozone: geozone)
|
||||
|
||||
login_as user
|
||||
visit question_path(question)
|
||||
|
||||
expect(page).to have_link('Go to voting page')
|
||||
end
|
||||
|
||||
scenario 'Records participation', :js do
|
||||
question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca')
|
||||
user = create(:user, :level_two, geozone: geozone, gender: 'female', date_of_birth: 33.years.ago)
|
||||
|
||||
login_as user
|
||||
visit question_path(question)
|
||||
|
||||
click_link 'Go to voting page'
|
||||
click_link 'Han Solo'
|
||||
|
||||
expect(page).to_not have_link('Han Solo')
|
||||
|
||||
voter = poll.voters.first
|
||||
expect(voter.document_number).to eq(user.document_number)
|
||||
expect(voter.geozone_id).to eq(user.geozone_id)
|
||||
expect(voter.gender).to eq(user.gender)
|
||||
expect(voter.age).to eq(33)
|
||||
expect(voter.poll_id).to eq(poll.id)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,12 +10,13 @@ feature "Voter" do
|
||||
user = create(:user, :level_two)
|
||||
|
||||
login_as user
|
||||
visit question_path(question)
|
||||
visit poll_path(poll)
|
||||
|
||||
click_link 'Go to voting page'
|
||||
click_link 'Yes'
|
||||
within("#poll_question_#{question.id}_answers") do
|
||||
click_link 'Yes'
|
||||
expect(page).to_not have_link('Yes')
|
||||
end
|
||||
|
||||
expect(page).to_not have_link('Yes')
|
||||
expect(Poll::Voter.count).to eq(1)
|
||||
expect(Poll::Voter.first.origin).to eq("web")
|
||||
end
|
||||
@@ -56,7 +57,7 @@ feature "Voter" do
|
||||
|
||||
scenario "Trying to vote in web and then in booth", :js do
|
||||
login_as user
|
||||
vote_for_poll_via_web
|
||||
vote_for_poll_via_web(poll, question)
|
||||
|
||||
click_link "Sign out"
|
||||
|
||||
@@ -79,9 +80,7 @@ feature "Voter" do
|
||||
click_link "Sign out"
|
||||
|
||||
login_as user
|
||||
visit question_path(question)
|
||||
|
||||
click_link 'Go to voting page'
|
||||
visit poll_path(poll)
|
||||
|
||||
expect(page).to_not have_link('Yes')
|
||||
expect(page).to have_content "You have already participated in a booth for this poll."
|
||||
|
||||
@@ -322,5 +322,4 @@ end
|
||||
def documentable_fill_new_valid_poll_question
|
||||
page.select documentable.poll.name, from: 'poll_question_poll_id'
|
||||
fill_in 'poll_question_title', with: "Star Wars: Episode IV - A New Hope"
|
||||
fill_in_ckeditor "poll_question_description", with: "Description"
|
||||
end
|
||||
|
||||
@@ -298,13 +298,14 @@ module CommonActions
|
||||
end
|
||||
end
|
||||
|
||||
def vote_for_poll_via_web
|
||||
visit question_path(question)
|
||||
def vote_for_poll_via_web(poll, question)
|
||||
visit poll_path(poll)
|
||||
|
||||
click_link 'Go to voting page'
|
||||
click_link 'Yes'
|
||||
within("#poll_question_#{question.id}_answers") do
|
||||
click_link 'Yes'
|
||||
expect(page).to_not have_link('Yes')
|
||||
end
|
||||
|
||||
expect(page).to_not have_link('Yes')
|
||||
expect(Poll::Voter.count).to eq(1)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user