diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index d8e6d63ef..e22bcb7e0 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -13,6 +13,7 @@ module Abilities can :new, DirectMessage can [:read, :draft_publication, :allegations, :final_version_publication], Legislation::Process can [:read], Legislation::DraftVersion + can [:read], Legislation::Question end end end diff --git a/app/models/legislation/question.rb b/app/models/legislation/question.rb index d139d75b2..c7c123437 100644 --- a/app/models/legislation/question.rb +++ b/app/models/legislation/question.rb @@ -9,4 +9,8 @@ class Legislation::Question < ActiveRecord::Base validates :process, presence: true validates :title, presence: true + + def next_question_id + @next_question_id ||= process.questions.where("id > ?", id).order('id ASC').limit(1).pluck(:id).first + end end diff --git a/app/views/legislation/questions/show.html.erb b/app/views/legislation/questions/show.html.erb index ea3563c67..6686334a2 100644 --- a/app/views/legislation/questions/show.html.erb +++ b/app/views/legislation/questions/show.html.erb @@ -1,3 +1,56 @@ +
+
+
+
+

<%= t('.title') %>

+

<%= link_to @process.title, @process %>

+
+
+
+ <% if @question.next_question_id %> + <%= link_to legislation_process_question_path(@process, @question.next_question_id), class: "quiz-next-link" do %> + <%= content_tag :div, class: "quiz-next" do %> + <%= t('.next_question') %> +
+
+
+
+

<%= @question.title %>

+
+
+ <% @question.question_options.each do |question_option| %> + + <% end %> +
+
+
+ +
+ +
+ +
+
-

<%= @question.title %>

+
+ <%= t('.comments') %> +
diff --git a/config/locales/en.yml b/config/locales/en.yml index 4a7a46749..7538b308c 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -267,6 +267,11 @@ en: one: "%{count} comment" other: "%{count} comments" debate: Debate + show: + comments: COMMENTS + next_question: Next question + share: Share + title: Collaborative legislation process locale: English notifications: index: diff --git a/config/locales/es.yml b/config/locales/es.yml index f5ddb6476..a24fa253b 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -267,6 +267,11 @@ es: one: "%{count} comentario" other: "%{count} comentarios" debate: Debate + show: + comments: COMENTARIOS + next_question: Siguiente pregunta + share: Compartir + title: Proceso de legislación colaborativa locale: Español notifications: index: diff --git a/spec/features/legislation/debate_spec.rb b/spec/features/legislation/debate_spec.rb new file mode 100644 index 000000000..daba0177d --- /dev/null +++ b/spec/features/legislation/debate_spec.rb @@ -0,0 +1,36 @@ +require 'rails_helper' + +feature 'Legislation' do + + context 'process debate page' do + scenario 'shows question list' do + process = create(:legislation_process, debate_start_date: Date.current - 1.day, debate_end_date: Date.current + 2.days) + create(:legislation_question, process: process, title: "Question 1") + create(:legislation_question, process: process, title: "Question 2") + create(:legislation_question, process: process, title: "Question 3") + + visit legislation_process_path(process) + + expect(page).to have_content("Participate in the debate") + + expect(page).to have_content("Question 1") + expect(page).to have_content("Question 2") + expect(page).to have_content("Question 3") + + click_link "Question 1" + + expect(page).to have_content("Question 1") + expect(page).to have_content("Next question") + + click_link "Next question" + + expect(page).to have_content("Question 2") + expect(page).to have_content("Next question") + + click_link "Next question" + + expect(page).to have_content("Question 3") + expect(page).to_not have_content("Next question") + end + end +end diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb index 49e2f67ea..818717757 100644 --- a/spec/features/legislation/processes_spec.rb +++ b/spec/features/legislation/processes_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' feature 'Legislation' do - context 'processes#index' do + context 'processes home page' do scenario 'Processes can be listed' do processes = create_list(:legislation_process, 3)