Add public changes to create and vote Poll:Questions with votation type
This commit is contained in:
@@ -7,3 +7,11 @@ App.Sortable =
|
|||||||
url: $(".sortable").data("js-url"),
|
url: $(".sortable").data("js-url"),
|
||||||
data: { ordered_list: new_order },
|
data: { ordered_list: new_order },
|
||||||
type: "POST"
|
type: "POST"
|
||||||
|
|
||||||
|
$(".sortable-priotirized-votation").sortable
|
||||||
|
update: (event, ui) ->
|
||||||
|
new_order = $(this).sortable("toArray", { attribute: "data-answer-id" })
|
||||||
|
$.ajax
|
||||||
|
url: $(this).data("js-url"),
|
||||||
|
data: { ordered_list: new_order },
|
||||||
|
type: "POST"
|
||||||
|
|||||||
@@ -1745,8 +1745,12 @@
|
|||||||
background: #fafafa;
|
background: #fafafa;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
|
|
||||||
.column:nth-child(odd) {
|
.margin-bottom {
|
||||||
border-right: 2px solid $text;
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.orbit-bullets {
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.answer-divider {
|
.answer-divider {
|
||||||
@@ -1756,14 +1760,35 @@
|
|||||||
padding-bottom: $line-height;
|
padding-bottom: $line-height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.answer-left-divider {
|
||||||
|
border-left: solid 1px $text;
|
||||||
|
padding-left: rem-calc(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
.margin-top {
|
||||||
|
margin-top: rem-calc(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
.margin-bottom {
|
||||||
|
margin-bottom: rem-calc(20);
|
||||||
|
}
|
||||||
|
|
||||||
.answer-description {
|
.answer-description {
|
||||||
height: 100%;
|
max-height: rem-calc(1000);
|
||||||
|
|
||||||
&.short {
|
&.short {
|
||||||
height: rem-calc(300);
|
max-height: rem-calc(70);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
max-width: rem-calc(700);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.question-divider {
|
||||||
|
border-bottom: rgba(219, 219, 219, 0.62) solid 1px;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
padding: rem-calc(24);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.orbit-bullets button {
|
.orbit-bullets button {
|
||||||
@@ -1991,6 +2016,69 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-like,
|
||||||
|
.icon-unlike {
|
||||||
|
background: #fff;
|
||||||
|
border: 2px solid $text-light;
|
||||||
|
border-radius: rem-calc(3);
|
||||||
|
color: $text-light;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: rem-calc(30);
|
||||||
|
line-height: rem-calc(30);
|
||||||
|
padding: rem-calc(3) rem-calc(6);
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:active {
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 1 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.active-like {
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 1 !important;
|
||||||
|
background: $like;
|
||||||
|
border: 2px solid $like;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active-unlike {
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 1 !important;
|
||||||
|
background: $unlike;
|
||||||
|
border: 2px solid $unlike;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-like {
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:active,
|
||||||
|
.picked {
|
||||||
|
background: $like;
|
||||||
|
border: 2px solid $like;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-unlike {
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:active {
|
||||||
|
background: $unlike;
|
||||||
|
border: 2px solid $unlike;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.vote-align {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vote-divider {
|
||||||
|
border-bottom: 1px solid $text-light;
|
||||||
|
}
|
||||||
|
|
||||||
// 09. Polls results and stats
|
// 09. Polls results and stats
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
|
|
||||||
|
|||||||
70
app/controllers/polls/answers_controller.rb
Normal file
70
app/controllers/polls/answers_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
class Polls::AnswersController < ApplicationController
|
||||||
|
|
||||||
|
load_and_authorize_resource :poll
|
||||||
|
load_and_authorize_resource :question, class: "Poll::Question"
|
||||||
|
authorize_resource :answer, class: "Poll::Answer"
|
||||||
|
|
||||||
|
def create
|
||||||
|
@question = Poll::Question.find_by(id: params[:id])
|
||||||
|
if @question.votation_type.open? && !check_question_answer_exist
|
||||||
|
@question.question_answers.create(
|
||||||
|
title: params[:answer],
|
||||||
|
given_order: @question.question_answers.count + 1,
|
||||||
|
hidden: false
|
||||||
|
)
|
||||||
|
flash.now[:notice] = t("dashboard.polls.index.succesfull")
|
||||||
|
else
|
||||||
|
flash.now[:alert] = "Unfortunately failed to sent"
|
||||||
|
end
|
||||||
|
load_for_answers
|
||||||
|
if @question.enum_type&.include?("answer_couples")
|
||||||
|
last_pair ||= generate_and_store_new_pair(@question)
|
||||||
|
@last_pair_question_answers = {@question.id => last_pair}
|
||||||
|
end
|
||||||
|
render "polls/questions/answer", format: :js
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete
|
||||||
|
@question = Poll::Question.find_by(id: params[:id])
|
||||||
|
!@question.answers.find_by(author: current_user, answer: params[:answer]).destroy
|
||||||
|
@question.question_answers.each do |question_answer|
|
||||||
|
question_answer.set_most_voted
|
||||||
|
end
|
||||||
|
question_answers
|
||||||
|
load_for_answers
|
||||||
|
if @question.enum_type&.include?("answer_couples")
|
||||||
|
last_pair ||= generate_and_store_new_pair(@question)
|
||||||
|
@last_pair_question_answers = {@question.id => last_pair}
|
||||||
|
end
|
||||||
|
render "polls/questions/answer", format: :js
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_question_answer_exist
|
||||||
|
exist = false
|
||||||
|
@question.question_answers.each do |question_answer|
|
||||||
|
break if exist
|
||||||
|
exist = true if question_answer.title == params[:answer]
|
||||||
|
end
|
||||||
|
exist
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_for_answers
|
||||||
|
@page = params[:page].present? ? params[:page] : 1
|
||||||
|
question_answers
|
||||||
|
@answers_by_question_id = {@question.id => @question.answers
|
||||||
|
.by_author(current_user)
|
||||||
|
.order(:order)
|
||||||
|
.pluck(:answer)}
|
||||||
|
end
|
||||||
|
|
||||||
|
def question_answers
|
||||||
|
if @question.is_positive_negative?
|
||||||
|
@answers = @question.question_answers.visibles.page(params[:page])
|
||||||
|
else
|
||||||
|
@answers = @question.question_answers.visibles
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -3,18 +3,79 @@ class Polls::QuestionsController < ApplicationController
|
|||||||
load_and_authorize_resource :poll
|
load_and_authorize_resource :poll
|
||||||
load_and_authorize_resource :question, class: "Poll::Question"
|
load_and_authorize_resource :question, class: "Poll::Question"
|
||||||
|
|
||||||
has_orders %w{most_voted newest oldest}, only: :show
|
has_orders %w[most_voted newest oldest], only: :show
|
||||||
|
|
||||||
def answer
|
def answer
|
||||||
answer = @question.answers.find_or_initialize_by(author: current_user)
|
answer = store_answer
|
||||||
token = params[:token]
|
vote_stored(answer, params[:answer], params[:token]) if answer.present?
|
||||||
|
load_for_answers
|
||||||
|
if @question.enum_type&.include?("answer_couples")
|
||||||
|
last_pair ||= generate_and_store_new_pair(@question)
|
||||||
|
@last_pair_question_answers = {@question.id => last_pair}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
answer.answer = params[:answer]
|
def load_answers
|
||||||
|
load_for_answers
|
||||||
|
render action: "answer.js.erb"
|
||||||
|
end
|
||||||
|
|
||||||
|
def prioritized_answers
|
||||||
|
unless params[:ordered_list].empty?
|
||||||
|
params[:ordered_list].each_with_index do |answer, i|
|
||||||
|
answer_obj = @question.votation_type.answer(current_user,
|
||||||
|
answer,
|
||||||
|
order: i + 1)
|
||||||
|
vote_stored(answer_obj, answer, params[:tooken]) if answer_obj.present?
|
||||||
|
end
|
||||||
|
@question.votation_type.update_priorized_values(current_user.id)
|
||||||
|
end
|
||||||
|
load_for_answers
|
||||||
|
render action: "answer.js.erb"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def load_for_answers
|
||||||
|
@page = params[:page].present? ? params[:page] : 1
|
||||||
|
question_answers
|
||||||
|
@answers_by_question_id = {@question.id => @question.answers
|
||||||
|
.by_author(current_user)
|
||||||
|
.order(:order)
|
||||||
|
.pluck(:answer)}
|
||||||
|
end
|
||||||
|
|
||||||
|
def vote_stored(answer, new_answer, token)
|
||||||
|
answer.answer = new_answer
|
||||||
answer.touch if answer.persisted?
|
answer.touch if answer.persisted?
|
||||||
answer.save!
|
answer.save!
|
||||||
answer.record_voter_participation(token)
|
answer.record_voter_participation(token)
|
||||||
|
@question.question_answers.visibles.where(question_id: @question).each do |question_answer|
|
||||||
|
question_answer.set_most_voted
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@answers_by_question_id = { @question.id => params[:answer] }
|
def store_answer
|
||||||
|
if @question.votation_type.nil?
|
||||||
|
answer = @question.answers.find_or_initialize_by(author: current_user)
|
||||||
|
else
|
||||||
|
answer = @question.votation_type.answer(current_user,
|
||||||
|
params[:answer],
|
||||||
|
positive: params[:positive])
|
||||||
|
end
|
||||||
|
answer
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_and_store_new_pair(question)
|
||||||
|
Poll::PairAnswer.generate_pair(question, current_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
def question_answers
|
||||||
|
if @question.is_positive_negative?
|
||||||
|
@answers = @question.question_answers.visibles.page(@page)
|
||||||
|
else
|
||||||
|
@answers = @question.question_answers.visibles
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,13 +20,27 @@ class PollsController < ApplicationController
|
|||||||
def show
|
def show
|
||||||
@questions = @poll.questions.for_render.sort_for_list
|
@questions = @poll.questions.for_render.sort_for_list
|
||||||
@token = poll_voter_token(@poll, current_user)
|
@token = poll_voter_token(@poll, current_user)
|
||||||
@poll_questions_answers = Poll::Question::Answer.where(question: @poll.questions)
|
@poll_questions_answers = Poll::Question::Answer.visibles
|
||||||
|
.where(question: @poll.questions)
|
||||||
.where.not(description: "").order(:given_order)
|
.where.not(description: "").order(:given_order)
|
||||||
|
|
||||||
@answers_by_question_id = {}
|
@answers_by_question_id = {}
|
||||||
poll_answers = ::Poll::Answer.by_question(@poll.question_ids).by_author(current_user.try(:id))
|
poll_answers = ::Poll::Answer.by_question(@poll.question_ids).by_author(current_user.try(:id))
|
||||||
poll_answers.each do |answer|
|
|
||||||
@answers_by_question_id[answer.question_id] = answer.answer
|
@last_pair_question_answers = {}
|
||||||
|
@questions.each do |question|
|
||||||
|
@answers_by_question_id[question.id] = question.answers.by_author(current_user).pluck(:answer)
|
||||||
|
|
||||||
|
if question.enum_type&.include?("answer_couples")
|
||||||
|
last_pair = question.pair_answers.by_author(current_user).first
|
||||||
|
last_pair ||= generate_and_store_new_pair(question)
|
||||||
|
@last_pair_question_answers[question.id] = last_pair
|
||||||
|
end
|
||||||
|
|
||||||
|
if question.enum_type&.include?("answer_set_closed") ||
|
||||||
|
question.enum_type&.include?("answer_set_open")
|
||||||
|
votation_answer_sets(question)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@commentable = @poll
|
@commentable = @poll
|
||||||
@@ -42,6 +56,18 @@ class PollsController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def votation_answer_sets(question)
|
||||||
|
if question.votation_type.votation_set_answers.by_author(current_user).empty?
|
||||||
|
question.question_answers&.sample(question.max_groups_answers).each do |question_answer|
|
||||||
|
answer = VotationSetAnswer.new(answer: question_answer.title,
|
||||||
|
votation_type: question.votation_type,
|
||||||
|
author: current_user)
|
||||||
|
question.votation_type.votation_set_answers << answer
|
||||||
|
end
|
||||||
|
!question.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def load_poll
|
def load_poll
|
||||||
@poll = Poll.where(slug: params[:id]).first || Poll.where(id: params[:id]).first
|
@poll = Poll.where(slug: params[:id]).first || Poll.where(id: params[:id]).first
|
||||||
end
|
end
|
||||||
@@ -50,4 +76,8 @@ class PollsController < ApplicationController
|
|||||||
@active_poll = ActivePoll.first
|
@active_poll = ActivePoll.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_and_store_new_pair(question)
|
||||||
|
Poll::PairAnswer.generate_pair(question, current_user)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -78,4 +78,8 @@ module PollsHelper
|
|||||||
def show_polls_description?
|
def show_polls_description?
|
||||||
@active_poll.present? && @current_filter == "current"
|
@active_poll.present? && @current_filter == "current"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stored_positive_negative_value(question, answer)
|
||||||
|
question.answers.find_by(author_id: current_user.id, answer: answer.title).positive
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -104,12 +104,18 @@ module Abilities
|
|||||||
|
|
||||||
can :create, DirectMessage
|
can :create, DirectMessage
|
||||||
can :show, DirectMessage, sender_id: user.id
|
can :show, DirectMessage, sender_id: user.id
|
||||||
can :answer, Poll do |poll|
|
|
||||||
|
can [:load_answers], Poll::Question
|
||||||
|
can [:answer], Poll do |poll|
|
||||||
poll.answerable_by?(user)
|
poll.answerable_by?(user)
|
||||||
end
|
end
|
||||||
can :answer, Poll::Question do |question|
|
can [:answer, :prioritized_answers], Poll::Question do |question|
|
||||||
question.answerable_by?(user)
|
question.answerable_by?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
can [:create, :delete], Poll::Answer do |answer|
|
||||||
|
answer.question.answerable_by?(user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
can [:create, :show], ProposalNotification, proposal: { author_id: user.id }
|
can [:create, :show], ProposalNotification, proposal: { author_id: user.id }
|
||||||
|
|||||||
@@ -1,33 +1,22 @@
|
|||||||
<div class="poll-question-answers">
|
<% if question.votation_type.nil? %>
|
||||||
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
|
<%= render "polls/questions/answers_unique", question: question, answers: answers, token: token %>
|
||||||
<% question.question_answers.each do |answer| %>
|
|
||||||
<% if @answers_by_question_id[question.id] == answer.title &&
|
|
||||||
(!voted_before_sign_in(question) ||
|
|
||||||
question.poll.voted_in_booth?(current_user)) %>
|
|
||||||
<span class="button answered"
|
|
||||||
title="<%= t("poll_questions.show.voted", answer: answer.title)%>">
|
|
||||||
<%= answer.title %>
|
|
||||||
</span>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to answer.title,
|
<% case question.votation_type.enum_type %>
|
||||||
answer_question_path(question, answer: answer.title, token: token),
|
<% when "unique" %>
|
||||||
method: :post,
|
<%= render "polls/questions/answers_unique", question: question, answers: answers, token: token %>
|
||||||
remote: true,
|
<% when "multiple", "positive_open" %>
|
||||||
title: t("poll_questions.show.vote_answer", answer: answer.title),
|
<%= render "polls/questions/answers_multiple", question: question, answers: answers, token: token %>
|
||||||
class: "button secondary hollow js-question-answer" %>
|
<% when "positive_negative_open" %>
|
||||||
<% end %>
|
<%= render "polls/questions/answers_positive_negative", question: question, answers: answers, token: token, page: page %>
|
||||||
<% end %>
|
<% when "answer_couples_closed" %>
|
||||||
<% elsif !user_signed_in? %>
|
<%= render "polls/questions/answers_couples", answers_open: false, question: question, token: token %>
|
||||||
<% question.question_answers.order(id: :desc).each do |answer| %>
|
<% when "answer_couples_open" %>
|
||||||
<%= link_to answer.title, new_user_session_path, class: "button secondary hollow" %>
|
<%= render "polls/questions/answers_couples", answers_open: true, question: question, token: token %>
|
||||||
<% end %>
|
<% when "answer_set_closed", "answer_set_open" %>
|
||||||
<% elsif !current_user.level_two_or_three_verified? %>
|
<%= render "polls/questions/answers_set", question: question, token: token, answers: question.votation_type.votation_set_answers.by_author(current_user) %>
|
||||||
<% question.question_answers.order(id: :desc).each do |answer| %>
|
<% when "prioritized" %>
|
||||||
<%= link_to answer.title, verification_path, class: "button secondary hollow" %>
|
<%= render "polls/questions/answers_prioritized", answers_open: false, question: question, answers: answers, token: token %>
|
||||||
<% end %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<% question.question_answers.order(id: :desc).each do |answer| %>
|
<%= render "polls/questions/answers_unique", question: question, answers: answers, token: token %>
|
||||||
<span class="button secondary hollow disabled"><%= answer.title %></span>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
|
||||||
|
|||||||
39
app/views/polls/questions/_answers_couples.html.erb
Normal file
39
app/views/polls/questions/_answers_couples.html.erb
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<div class="poll-question-answers">
|
||||||
|
<% if can?(:answer, question) && question.user_can_vote(current_user) %>
|
||||||
|
<div class="small-12 medium-12 text-center">
|
||||||
|
<% @last_pair_question_answers.dig(question.id)&.answers&.each do |answer| %>
|
||||||
|
<div class="small-12 medium-5 inline-block">
|
||||||
|
<%= link_to answer.title,
|
||||||
|
answer_question_path(question, answer: answer.title, token: token),
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.vote_answer", answer: answer.title),
|
||||||
|
class: "button secondary hollow js-question-answer" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-12 text-center">
|
||||||
|
<%= link_to "I can't decide",
|
||||||
|
answer_question_path(question, answer: "I can't decided", token: token),
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
title: "I can't decide",
|
||||||
|
class: "button secondary hollow js-question-answer" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if answers_open %>
|
||||||
|
<%= render "/polls/questions/new_answer", question: question, token: token %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% elsif !user_signed_in? %>
|
||||||
|
<% question.question_answers.visibles.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, new_user_session_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !current_user.level_two_or_three_verified? %>
|
||||||
|
<% question.question_answers.visibles.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, verification_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<%= t('polls.index.max_votes_reached') %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
36
app/views/polls/questions/_answers_multiple.html.erb
Normal file
36
app/views/polls/questions/_answers_multiple.html.erb
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<div class="poll-question-answers">
|
||||||
|
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
|
||||||
|
<% answers&.each do |answer| %>
|
||||||
|
<% if @answers_by_question_id[question.id].include?(answer.title) %>
|
||||||
|
<%= link_to answer.title,
|
||||||
|
answer_question_path(question, answer: answer.title, token: token),
|
||||||
|
method: :delete,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.voted", answer: answer.title),
|
||||||
|
class: "button answered expand" %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to answer.title,
|
||||||
|
answer_question_path(question, answer: answer.title, token: token),
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.vote_answer", answer: answer.title),
|
||||||
|
class: "button secondary hollow js-question-answer" %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if question.enum_type == "positive_open" %>
|
||||||
|
<%= render "/polls/questions/new_answer", question: question, token: token %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !user_signed_in? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, new_user_session_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !current_user.level_two_or_three_verified? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, verification_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<span class="button secondary hollow disabled"><%= answer.title %></span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<div class="poll-question-answers">
|
||||||
|
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
|
||||||
|
<table class="voting-list">
|
||||||
|
<% answers&.each do |answer| %>
|
||||||
|
<tr class="answer medium-12 inline-block" style="border-bottom: 1px solid lightslategrey;">
|
||||||
|
<td class="title-answer medium-9 inline-block">
|
||||||
|
<span class="inline-block"><%= answer.title %></span>
|
||||||
|
</td>
|
||||||
|
<td class="votes inline-block vote-align">
|
||||||
|
<div class="in-favor inline-block">
|
||||||
|
<% if @answers_by_question_id[question.id].include?(answer.title) &&
|
||||||
|
stored_positive_negative_value(question, answer) %>
|
||||||
|
<%= render "polls/questions/like_dislike", question: question,
|
||||||
|
answer: answer, method: "delete", positive: true,
|
||||||
|
token: token, active: true, page: page %>
|
||||||
|
<% else %>
|
||||||
|
<%= render "polls/questions/like_dislike", question: question,
|
||||||
|
answer: answer, method: "post", positive: true,
|
||||||
|
token: token, active: false, page: page %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="against inline-block">
|
||||||
|
<% if @answers_by_question_id[question.id].include?(answer.title) &&
|
||||||
|
!stored_positive_negative_value(question, answer) %>
|
||||||
|
<%= render "polls/questions/like_dislike", question: question,
|
||||||
|
answer: answer, method: "delete", positive: false,
|
||||||
|
token: token, active: true, page: page %>
|
||||||
|
<% else %>
|
||||||
|
<%= render "polls/questions/like_dislike", question: question,
|
||||||
|
answer: answer, method: "post", positive: false,
|
||||||
|
token: token, active: false, page: page %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
<%= paginate answers, params: {controller: "polls/questions", action: :load_answers, id: question}, remote: true %>
|
||||||
|
|
||||||
|
<%= render "/polls/questions/new_answer", question: question, token: token %>
|
||||||
|
|
||||||
|
<% elsif !user_signed_in? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, new_user_session_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !current_user.level_two_or_three_verified? %>
|
||||||
|
<% answers.visibles.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, verification_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<span class="button secondary hollow disabled"><%= answer.title %></span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
44
app/views/polls/questions/_answers_prioritized.html.erb
Normal file
44
app/views/polls/questions/_answers_prioritized.html.erb
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<div class="poll-question-answers">
|
||||||
|
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
|
||||||
|
<ol type="1" class="sortable-priotirized-votation" data-js-url="<%= prioritized_answers_question_path(question, token: token) %>">
|
||||||
|
<% @answers_by_question_id[question.id].each do |answer| %>
|
||||||
|
<li data-answer-id="<%= answer %>">
|
||||||
|
<span class="button answered expanded"
|
||||||
|
title="<%= t("poll_questions.show.voted", answer: answer) %>">
|
||||||
|
<%= answer %>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<% answers&.each do |answer| %>
|
||||||
|
<% if @answers_by_question_id[question.id].include?(answer.title) %>
|
||||||
|
<%= link_to answer.title,
|
||||||
|
answer_question_path(question, answer: answer.title, token: token),
|
||||||
|
method: :delete,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.voted", answer: answer.title),
|
||||||
|
class: "button answered expand" %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to answer.title,
|
||||||
|
answer_question_path(question, answer: answer.title, token: token),
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.vote_answer", answer: answer.title),
|
||||||
|
class: "button secondary hollow js-question-answer" %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !user_signed_in? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, new_user_session_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !current_user.level_two_or_three_verified? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, verification_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<span class="button secondary hollow disabled"><%= answer.title %></span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
37
app/views/polls/questions/_answers_set.html.erb
Normal file
37
app/views/polls/questions/_answers_set.html.erb
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<div class="poll-question-answers">
|
||||||
|
<% if can?(:answer, question) %>
|
||||||
|
<% answers.each do |answer| %>
|
||||||
|
<% if @answers_by_question_id[question.id].include?(answer.answer) %>
|
||||||
|
<%= link_to answer.answer,
|
||||||
|
answer_question_path(question, answer: answer.answer, token: token),
|
||||||
|
method: :delete,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.voted", answer: answer.answer),
|
||||||
|
class: "button answered" %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to answer.answer,
|
||||||
|
answer_question_path(question, answer: answer.answer, token: token),
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.vote_answer", answer: answer.answer),
|
||||||
|
class: "button secondary hollow js-question-answer" %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if question.enum_type == "answer_set_open" %>
|
||||||
|
<%= render "/polls/questions/new_answer", question: question, token: token %>
|
||||||
|
<%= flash[:notice] %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !user_signed_in? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.answer, new_user_session_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !current_user.level_two_or_three_verified? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.answer, verification_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<span class="button secondary hollow disabled"><%= answer.answer %></span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
33
app/views/polls/questions/_answers_unique.html.erb
Normal file
33
app/views/polls/questions/_answers_unique.html.erb
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<div class="poll-question-answers">
|
||||||
|
<% if can?(:answer, question) && !question.poll.voted_in_booth?(current_user) %>
|
||||||
|
<% answers&.each do |answer| %>
|
||||||
|
<% if @answers_by_question_id[question.id].include?(answer.title) &&
|
||||||
|
(!voted_before_sign_in(question) ||
|
||||||
|
question.poll.voted_in_booth?(current_user)) %>
|
||||||
|
<span class="button answered"
|
||||||
|
title="<%= t("poll_questions.show.voted", answer: answer.title) %>">
|
||||||
|
<%= answer.title %>
|
||||||
|
</span>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to answer.title,
|
||||||
|
answer_question_path(question, answer: answer.title, token: token),
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.vote_answer", answer: answer.title),
|
||||||
|
class: "button secondary hollow js-question-answer" %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !user_signed_in? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, new_user_session_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif !current_user.level_two_or_three_verified? %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<%= link_to answer.title, verification_path, class: "button secondary hollow" %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% answers.order(id: :desc).each do |answer| %>
|
||||||
|
<span class="button secondary hollow disabled"><%= answer.title %></span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
19
app/views/polls/questions/_like_dislike.html.erb
Normal file
19
app/views/polls/questions/_like_dislike.html.erb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<%= link_to answer_question_path(question, answer: answer.title, positive: positive, token: token, page: page),
|
||||||
|
method: method.to_sym,
|
||||||
|
remote: true,
|
||||||
|
title: t("poll_questions.show.vote_answer", answer: answer.title),
|
||||||
|
class: "expand js-question-answer" do %>
|
||||||
|
<% if positive %>
|
||||||
|
<% if active %>
|
||||||
|
<span class="icon-like active-like"></span>
|
||||||
|
<% else %>
|
||||||
|
<span class="icon-like"></span>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% if active %>
|
||||||
|
<span class="icon-unlike active-unlike"></span>
|
||||||
|
<% else %>
|
||||||
|
<span class="icon-unlike"></span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
5
app/views/polls/questions/_new_answer.html.erb
Normal file
5
app/views/polls/questions/_new_answer.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<%= form_tag(create_answer_question_path(question, token: token), method: :post, remote: true) do %>
|
||||||
|
<label> You can add your own answer</label>
|
||||||
|
<input type="text" class="medium-10" name="answer">
|
||||||
|
<input class="button success" type="submit" value="<%= t("poll_questions.show.add_answer") %>">
|
||||||
|
<% end %>
|
||||||
@@ -3,7 +3,35 @@
|
|||||||
<%= question.title %>
|
<%= question.title %>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
|
<% unless question.votation_type.nil? %>
|
||||||
|
<strong>
|
||||||
|
<%= t("poll_questions.description.#{question.enum_type}",
|
||||||
|
maximum: question.votation_type.max_votes,
|
||||||
|
system: question.votation_type.prioritization_type) %>
|
||||||
|
</strong>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div id="<%= dom_id(question) %>_answers" class="padding">
|
<div id="<%= dom_id(question) %>_answers" class="padding">
|
||||||
<%= render "polls/questions/answers", question: question, token: token %>
|
<% answers = question.is_positive_negative? ? question.question_answers.visibles.page(1) : question.question_answers.visibles %>
|
||||||
|
<%= render "polls/questions/answers", question: question, token: token, answers: answers, page: 1 %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% if question.answers_with_read_more? %>
|
||||||
|
<div class="poll_question_read_more">
|
||||||
|
<p><%= t("poll_questions.read_more_about") %></p>
|
||||||
|
<p>
|
||||||
|
<% first = true %>
|
||||||
|
<% question.question_answers&.visibles&.each do |answer| %>
|
||||||
|
<% if answer.description.present? || answer.images.any? ||
|
||||||
|
answer.documents.present? || answer.videos.present? %>
|
||||||
|
<% unless first %>
|
||||||
|
<span>, </span>
|
||||||
|
<% end %>
|
||||||
|
<% first = false if first %>
|
||||||
|
<%= link_to answer.title, "#answer_description_#{answer.id}" %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
<% token = poll_voter_token(@question.poll, current_user) %>
|
<% token = poll_voter_token(@question.poll, current_user) %>
|
||||||
$("#<%= dom_id(@question) %>_answers").html("<%= j render("polls/questions/answers", question: @question, token: token) %>");
|
$("#<%= dom_id(@question) %>_answers").html("<%= j render("polls/questions/answers", question: @question, answers: @answers, token: token, page: @page) %>");
|
||||||
|
App.Sortable.initialize();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<% provide :title do %><%= @poll.name %><% end %>
|
<% provide :title do %><%= @poll.name %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="polls-results-stats">
|
<div class="polls-results-stats">
|
||||||
<%= render "poll_header" %>
|
<%= render "poll_header" %>
|
||||||
@@ -17,30 +18,25 @@
|
|||||||
|
|
||||||
<div class="small-12 medium-9 column" data-equalizer-watch>
|
<div class="small-12 medium-9 column" data-equalizer-watch>
|
||||||
<%- @poll.questions.each do |question| %>
|
<%- @poll.questions.each do |question| %>
|
||||||
<% most_voted_answer_id = question.most_voted_answer_id %>
|
|
||||||
<h3 id="<%= question.title.parameterize %>"><%= question.title %></h3>
|
<h3 id="<%= question.title.parameterize %>"><%= question.title %></h3>
|
||||||
<table id="question_<%= question.id %>_results_table">
|
<table id="question_<%= question.id %>_results_table">
|
||||||
<thead>
|
<tbody>
|
||||||
<tr>
|
<%- question.question_answers.visibles.each do |answer| %>
|
||||||
<%- question.question_answers.each do |answer| %>
|
<tr scope="col" <%= answer.most_voted? ? "class=win" : "" %>>
|
||||||
<th scope="col" <%= answer.id == most_voted_answer_id ? "class=win" : "" %>>
|
<td>
|
||||||
<% if answer.id == most_voted_answer_id %>
|
<% if answer.most_voted %>
|
||||||
<span class="show-for-sr"><%= t("polls.show.results.most_voted_answer") %></span>
|
<span class="show-for-sr"><%= t("polls.show.results.most_voted_answer") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= answer.title %>
|
<%= answer.title %>
|
||||||
</th>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<%- question.question_answers.each do |answer| %>
|
|
||||||
<td id="answer_<%= answer.id %>_result" <%= answer.id == most_voted_answer_id ? "class=win" : "" %>>
|
|
||||||
<%= answer.total_votes %>
|
|
||||||
(<%= answer.total_votes_percentage.round(2) %>%)
|
|
||||||
</td>
|
</td>
|
||||||
|
<td id="answer_<%= answer.id %>_result" <%= answer.most_voted? ? "class=win" : "" %>>
|
||||||
|
<%= answer.total_votes %>
|
||||||
|
<% unless question.enum_type == "positive_negative_open" || question.enum_type == "prioritized" %>
|
||||||
|
(<%= answer.total_votes_percentage.round(2) %>%)
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -55,36 +55,24 @@
|
|||||||
|
|
||||||
<div id="poll_more_info_answers" class="expanded poll-more-info-answers">
|
<div id="poll_more_info_answers" class="expanded poll-more-info-answers">
|
||||||
<div class="row padding">
|
<div class="row padding">
|
||||||
|
<% @questions.each do |question| %>
|
||||||
<% @poll_questions_answers.each do |answer| %>
|
<% if question.answers_with_read_more? %>
|
||||||
<div class="small-12 medium-6 column end answer <%= cycle("first", "") %>" id="answer_<%= answer.id %>">
|
<div class="row question-divider">
|
||||||
|
<h2><%= question.title %></h2>
|
||||||
<% if answer.description.present? %>
|
<% question.question_answers.visibles.each do |answer| %>
|
||||||
|
<% if answer.description.present? || answer.images.any? || answer.documents.present? || answer.videos.present? %>
|
||||||
|
<div class="small-12 medium-6 column margin-top margin-bottom" id="answer_<%= answer.id %>">
|
||||||
<h3><%= answer.title %></h3>
|
<h3><%= answer.title %></h3>
|
||||||
|
<div class="margin-top">
|
||||||
|
<div id="answer_description_<%= answer.id %>"
|
||||||
|
class="answer-description short answer-left-divider" data-toggler="short">
|
||||||
|
<% if answer.description.present? %>
|
||||||
|
<%= answer.description %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if answer.images.any? %>
|
<% if answer.images.any? %>
|
||||||
<%= render "gallery", answer: answer %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if answer.description.present? %>
|
|
||||||
<div class="margin-top">
|
<div class="margin-top">
|
||||||
<div id="answer_description_<%= answer.id %>" class="answer-description short" data-toggler="short">
|
<%= render "gallery", answer: answer %>
|
||||||
<%= safe_html_with_links simple_format(answer.description) %>
|
|
||||||
</div>
|
|
||||||
<div class="margin">
|
|
||||||
<a id="read_more_<%= answer.id %>"
|
|
||||||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
|
||||||
data-toggler="hide">
|
|
||||||
<%= t("polls.show.read_more", answer: answer.title) %>
|
|
||||||
</a>
|
|
||||||
<a id="read_less_<%= answer.id %>"
|
|
||||||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
|
||||||
data-toggler="hide"
|
|
||||||
class="hide">
|
|
||||||
<%= t("polls.show.read_less", answer: answer.title) %>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -94,12 +82,12 @@
|
|||||||
<span class="icon-document"></span>
|
<span class="icon-document"></span>
|
||||||
<strong><%= t("polls.show.documents") %></strong>
|
<strong><%= t("polls.show.documents") %></strong>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<% answer.documents.each do |document| %>
|
<% answer.documents.each do |document| %>
|
||||||
<%= link_to document.title,
|
<%= link_to document.title,
|
||||||
document.attachment.url,
|
document.attachment.url,
|
||||||
target: "_blank",
|
target: "_blank",
|
||||||
rel: "nofollow" %><br>
|
rel: "nofollow" %>
|
||||||
|
<br>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -115,11 +103,32 @@
|
|||||||
<%= link_to video.title,
|
<%= link_to video.title,
|
||||||
video.url,
|
video.url,
|
||||||
target: "_blank",
|
target: "_blank",
|
||||||
rel: "nofollow" %><br>
|
rel: "nofollow" %>
|
||||||
|
<br>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="margin-top margin-bottom">
|
||||||
|
<a id="read_more_<%= answer.id %>"
|
||||||
|
data-toggle="answer_description_<%= answer.id %>
|
||||||
|
read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
||||||
|
data-toggler="hide">
|
||||||
|
<%= t("polls.show.read_more", answer: answer.title) %>
|
||||||
|
</a>
|
||||||
|
<a id="read_less_<%= answer.id %>"
|
||||||
|
data-toggle="answer_description_<%= answer.id %>
|
||||||
|
read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
||||||
|
data-toggler="hide" class="hide">
|
||||||
|
<%= t("polls.show.read_less", answer: answer.title) %>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ resources :polls, only: [:show, :index] do
|
|||||||
end
|
end
|
||||||
|
|
||||||
resources :questions, controller: "polls/questions", shallow: true do
|
resources :questions, controller: "polls/questions", shallow: true do
|
||||||
post :answer, on: :member
|
member do
|
||||||
|
post :answer
|
||||||
|
post :prioritized_answers
|
||||||
|
delete :answer, to: "polls/answers#delete"
|
||||||
|
post :create_answer, to: "polls/answers#create"
|
||||||
|
get :load_answers
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -213,6 +213,18 @@ describe Abilities::Common do
|
|||||||
it { should_not be_able_to(:answer, expired_poll_question_from_all_geozones) }
|
it { should_not be_able_to(:answer, expired_poll_question_from_all_geozones) }
|
||||||
it { should_not be_able_to(:answer, expired_poll_question_from_other_geozone) }
|
it { should_not be_able_to(:answer, expired_poll_question_from_other_geozone) }
|
||||||
|
|
||||||
|
it { should be_able_to(:prioritized_answers, poll_question_from_own_geozone) }
|
||||||
|
it { should be_able_to(:prioritized_answers, poll_question_from_all_geozones) }
|
||||||
|
it { should_not be_able_to(:prioritized_answers, poll_question_from_other_geozone) }
|
||||||
|
|
||||||
|
it { should_not be_able_to(:prioritized_answers, expired_poll_question_from_own_geozone) }
|
||||||
|
it { should_not be_able_to(:prioritized_answers, expired_poll_question_from_all_geozones) }
|
||||||
|
it { should_not be_able_to(:prioritized_answers, expired_poll_question_from_other_geozone) }
|
||||||
|
|
||||||
|
context "Poll::Question" do
|
||||||
|
it { should be_able_to(:load_answers, Poll::Question) }
|
||||||
|
end
|
||||||
|
|
||||||
context "without geozone" do
|
context "without geozone" do
|
||||||
before { user.geozone = nil }
|
before { user.geozone = nil }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user