From d9351b123df64d68d46d6348349ceb97d8b48355 Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 25 Jan 2017 17:58:09 +0100 Subject: [PATCH 1/3] prints a button to redirect to the poll when a question is answerable --- app/views/polls/questions/show.html.erb | 29 +++++++++++++++---------- config/locales/en.yml | 1 + config/locales/es.yml | 1 + db/dev_seeds.rb | 13 ++++++++++- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/views/polls/questions/show.html.erb b/app/views/polls/questions/show.html.erb index 04d4a3372..c04490f7d 100644 --- a/app/views/polls/questions/show.html.erb +++ b/app/views/polls/questions/show.html.erb @@ -46,9 +46,23 @@
- <% if @question.poll.current? %> - - <% if current_user.nil? %> + <% if can? :answer, @question %> +
+ <%= link_to t('poll_questions.show.answer_this_question'), + @question.poll, + class: 'large button' + %> +
+ <% else %> + <% if @question.poll.incoming? %> +
+ <%= t('poll_questions.show.cant_answer_incoming') %> +
+ <% elsif @question.poll.expired? %> +
+ <%= t('poll_questions.show.cant_answer_expired') %> +
+ <% elsif current_user.nil? %>
<%= t("poll_questions.show.not_logged_in", signin: link_to(t("poll_questions.show.signin"), new_user_session_path, class: "probe-message"), @@ -70,15 +84,6 @@ <%= render "answers", question: @question %>
- - <% elsif @question.poll.incoming? %> -
- <%= t('poll_questions.show.cant_answer_expired') %> -
- <% elsif @question.poll.expired? %> -
- <%= t('poll_questions.show.cant_answer_incoming') %> -
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 2697fb396..b778c4166 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -416,6 +416,7 @@ en: create_question: "Create question" default_valid_answers: "Yes, No" show: + answer_this_question: "Answer this question" original_proposal: "Original proposal" author: "Created by" dates_title: "Participation dates" diff --git a/config/locales/es.yml b/config/locales/es.yml index 2ae41a5ce..abbe23ddf 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -416,6 +416,7 @@ 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" diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 066603e3c..6f10ca891 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -467,7 +467,14 @@ end puts "Creating 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}", starts_at: 1.month.ago, ends_at: 1.month.from_now, @@ -477,6 +484,10 @@ puts "Active Polls" puts " #{poll.name}" end + + + + puts "Upcoming Poll" poll = Poll.create(name: "Upcoming Poll", starts_at: 1.month.from_now, From d8b54d2adc2028c0f6a8086844a9dd043722fca1 Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 25 Jan 2017 18:43:30 +0100 Subject: [PATCH 2/3] fixes question specs --- spec/features/polls/questions_spec.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/spec/features/polls/questions_spec.rb b/spec/features/polls/questions_spec.rb index af4c1058c..961fb4e46 100644 --- a/spec/features/polls/questions_spec.rb +++ b/spec/features/polls/questions_spec.rb @@ -62,8 +62,7 @@ feature 'Poll Questions' do login_as(create(:user, :level_two, geozone: geozone)) visit question_path(question) - expect(page).to have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).to have_link('Answer this question') end scenario 'Level 2 users who have already answered' do @@ -75,9 +74,7 @@ feature 'Poll Questions' do login_as user visit question_path(question) - expect(page).to have_link('Han Solo') - expect(page).to_not have_link('Chewbacca') - expect(page).to have_content('Chewbacca') + expect(page).to have_link('Answer this question') end scenario 'Level 2 users answering', :js do @@ -87,10 +84,7 @@ feature 'Poll Questions' do login_as user visit question_path(question) - click_link 'Han Solo' - - expect(page).to_not have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).to have_link('Answer this question') end end From 47abeff7faa68ae5829f8f4b0e36b34f19805a23 Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 26 Jan 2017 11:39:25 +0100 Subject: [PATCH 3/3] fixes specs --- spec/features/polls/questions_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/polls/questions_spec.rb b/spec/features/polls/questions_spec.rb index dd89be1cb..7b8c3495a 100644 --- a/spec/features/polls/questions_spec.rb +++ b/spec/features/polls/questions_spec.rb @@ -94,6 +94,7 @@ feature 'Poll Questions' do login_as user visit question_path(question) + click_link 'Answer this question' click_link 'Han Solo' expect(page).to_not have_link('Han Solo')