Merge pull request #35 from medialab-prado/30-legislation-question-page-details
Legislation Question page
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,56 @@
|
||||
<div class="row">
|
||||
<p><%= @question.title %></p>
|
||||
<section class="debate-quiz">
|
||||
<div class="quiz-header row small-collapse">
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="quiz-title">
|
||||
<p class="quiz-header-title"><%= t('.title') %></p>
|
||||
<h4><%= link_to @process.title, @process %></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="small-12 medium-3 column">
|
||||
<% 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') %>
|
||||
<span class="icon-angle-right" aria-hidden="true">
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column">
|
||||
<h3 class="quiz-question"><%= @question.title %></h3>
|
||||
<div class="debate-questions">
|
||||
<form class="controls-stacked">
|
||||
<% @question.question_options.each do |question_option| %>
|
||||
<label class="control radio">
|
||||
<input id="quiz-1" name="radio" type="radio">
|
||||
<span class="control-indicator"></span>
|
||||
<%= question_option.value %>
|
||||
</label>
|
||||
<% end %>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside class="small-12 medium-3 column">
|
||||
<div id="social-share" class="sidebar-divider"></div>
|
||||
<h3><%= t('.share') %></h3>
|
||||
<div class="social-share-full">
|
||||
<div class="social-share-button" data-title="Soluta sed sapiente dolores. #consul_dev" data-img="" data-url="" data-desc="" data-via="">
|
||||
<a rel="nofollow " data-site="twitter" class="ssb-icon ssb-twitter" onclick="return SocialShareButton.share(this);" title="Compartir en Twitter" href="#"><span class="sr-only">twitter</span></a>
|
||||
<a rel="nofollow " data-site="facebook" class="ssb-icon ssb-facebook" onclick="return SocialShareButton.share(this);" title="Compartir en Facebook" href="#"><span class="sr-only">facebook</span></a>
|
||||
<a rel="nofollow " data-site="google_plus" class="ssb-icon ssb-google_plus" onclick="return SocialShareButton.share(this);" title="Compartir en Google+" href="#"><span class="sr-only">google_plus</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%= t('.comments') %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
36
spec/features/legislation/debate_spec.rb
Normal file
36
spec/features/legislation/debate_spec.rb
Normal file
@@ -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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user