Merge pull request #1368 from consul/polls-question-show

Polls question show
This commit is contained in:
Juanjo Bazán
2017-01-26 11:56:56 +01:00
committed by GitHub
5 changed files with 35 additions and 22 deletions

View File

@@ -46,9 +46,23 @@
<div class="row margin-top"> <div class="row margin-top">
<div class="small-12 column"> <div class="small-12 column">
<% if @question.poll.current? %> <% if can? :answer, @question %>
<div class="text-center">
<% if current_user.nil? %> <%= link_to t('poll_questions.show.answer_this_question'),
@question.poll,
class: 'large button'
%>
</div>
<% else %>
<% if @question.poll.incoming? %>
<div class="callout alert">
<%= t('poll_questions.show.cant_answer_incoming') %>
</div>
<% elsif @question.poll.expired? %>
<div class="callout primary">
<%= t('poll_questions.show.cant_answer_expired') %>
</div>
<% elsif current_user.nil? %>
<div class="callout primary"> <div class="callout primary">
<%= t("poll_questions.show.not_logged_in", <%= t("poll_questions.show.not_logged_in",
signin: link_to(t("poll_questions.show.signin"), new_user_session_path, class: "probe-message"), signin: link_to(t("poll_questions.show.signin"), new_user_session_path, class: "probe-message"),
@@ -70,15 +84,6 @@
<%= render "answers", question: @question %> <%= render "answers", question: @question %>
</div> </div>
</div> </div>
<% elsif @question.poll.incoming? %>
<div class="callout alert">
<%= t('poll_questions.show.cant_answer_expired') %>
</div>
<% elsif @question.poll.expired? %>
<div class="callout primary">
<%= t('poll_questions.show.cant_answer_incoming') %>
</div>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@@ -416,6 +416,7 @@ en:
create_question: "Create question" create_question: "Create question"
default_valid_answers: "Yes, No" default_valid_answers: "Yes, No"
show: show:
answer_this_question: "Answer this question"
original_proposal: "Original proposal" original_proposal: "Original proposal"
author: "Created by" author: "Created by"
dates_title: "Participation dates" dates_title: "Participation dates"

View File

@@ -416,6 +416,7 @@ es:
create_question: "Crear pregunta para votación" create_question: "Crear pregunta para votación"
default_valid_answers: "Sí, No" default_valid_answers: "Sí, No"
show: show:
answer_this_question: "Responder a esta pregunta"
original_proposal: "Propuesta original" original_proposal: "Propuesta original"
author: "Creado por" author: "Creado por"
dates_title: "Fechas de participación" dates_title: "Fechas de participación"

View File

@@ -467,7 +467,14 @@ end
puts "Creating polls" puts "Creating polls"
puts "Active Polls" puts "Active Polls"
(1..5).each do |i| (1..3).each do |i|
poll = Poll.create(name: "Active Poll #{i}",
starts_at: 1.month.ago,
ends_at: 1.month.from_now,
geozone_restricted: false)
puts " #{poll.name}"
end
(4..5).each do |i|
poll = Poll.create(name: "Active Poll #{i}", poll = Poll.create(name: "Active Poll #{i}",
starts_at: 1.month.ago, starts_at: 1.month.ago,
ends_at: 1.month.from_now, ends_at: 1.month.from_now,
@@ -477,6 +484,10 @@ puts "Active Polls"
puts " #{poll.name}" puts " #{poll.name}"
end end
puts "Upcoming Poll" puts "Upcoming Poll"
poll = Poll.create(name: "Upcoming Poll", poll = Poll.create(name: "Upcoming Poll",
starts_at: 1.month.from_now, starts_at: 1.month.from_now,

View File

@@ -62,8 +62,7 @@ feature 'Poll Questions' do
login_as(create(:user, :level_two, geozone: geozone)) login_as(create(:user, :level_two, geozone: geozone))
visit question_path(question) visit question_path(question)
expect(page).to have_link('Han Solo') expect(page).to have_link('Answer this question')
expect(page).to have_link('Chewbacca')
end end
scenario 'Level 2 users who have already answered' do scenario 'Level 2 users who have already answered' do
@@ -75,9 +74,7 @@ feature 'Poll Questions' do
login_as user login_as user
visit question_path(question) visit question_path(question)
expect(page).to have_link('Han Solo') expect(page).to have_link('Answer this question')
expect(page).to_not have_link('Chewbacca')
expect(page).to have_content('Chewbacca')
end end
scenario 'Level 2 users answering', :js do scenario 'Level 2 users answering', :js do
@@ -87,10 +84,7 @@ feature 'Poll Questions' do
login_as user login_as user
visit question_path(question) visit question_path(question)
click_link 'Han Solo' expect(page).to have_link('Answer this question')
expect(page).to_not have_link('Han Solo')
expect(page).to have_link('Chewbacca')
end end
scenario 'Records participarion', :js do scenario 'Records participarion', :js do
@@ -100,6 +94,7 @@ feature 'Poll Questions' do
login_as user login_as user
visit question_path(question) visit question_path(question)
click_link 'Answer this question'
click_link 'Han Solo' click_link 'Han Solo'
expect(page).to_not have_link('Han Solo') expect(page).to_not have_link('Han Solo')