Merge pull request #54 from medialab-prado/fix-small-issues
Fix small issues
This commit is contained in:
@@ -14,3 +14,10 @@ App.Legislation =
|
||||
$('form#draft_version_go_to_version select').on
|
||||
change: ->
|
||||
$('form#draft_version_go_to_version').submit()
|
||||
|
||||
$('#js-toggle-legislation-process-header').on
|
||||
click: ->
|
||||
$('[data-target="legislation-header-small"]').toggle()
|
||||
$('[data-target="legislation-header-full"]').toggle()
|
||||
|
||||
|
||||
|
||||
@@ -8,23 +8,25 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
|
||||
|
||||
def create
|
||||
if @draft_version.save
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.draft_versions.create.error')
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @draft_version.update(draft_version_params)
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: t('admin.legislation.draft_versions.update.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.draft_versions.update.error')
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@draft_version.destroy
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.destroy.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -9,23 +9,25 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
|
||||
def create
|
||||
if @process.save
|
||||
redirect_to admin_legislation_processes_path
|
||||
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice', link: legislation_process_path(@process).html_safe)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.processes.create.error')
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @process.update(process_params)
|
||||
redirect_to admin_legislation_processes_path
|
||||
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: legislation_process_path(@process).html_safe)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.processes.update.error')
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@process.destroy
|
||||
redirect_to admin_legislation_processes_path
|
||||
redirect_to admin_legislation_processes_path, notice: t('admin.legislation.processes.destroy.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -13,23 +13,25 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
|
||||
def create
|
||||
@question.author = current_user
|
||||
if @question.save
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.create.notice', link: legislation_process_question_path(@process, @question).html_safe)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.questions.create.error')
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @question.update(question_params)
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: t('admin.legislation.questions.update.notice', link: legislation_process_question_path(@process, @question).html_safe)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.questions.update.error')
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@question.destroy
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.destroy.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
9
app/helpers/text_helper.rb
Normal file
9
app/helpers/text_helper.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
module TextHelper
|
||||
def first_paragraph(text)
|
||||
if text.blank?
|
||||
""
|
||||
else
|
||||
text.strip.split("\n").first
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -56,15 +56,27 @@ class Legislation::Process < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def total_comments
|
||||
questions.map(&:comments_count).sum
|
||||
questions.sum(:comments_count)
|
||||
end
|
||||
|
||||
def status
|
||||
today = Date.current
|
||||
|
||||
if today < start_date
|
||||
:planned
|
||||
elsif end_date < today
|
||||
:closed
|
||||
else
|
||||
:open
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_date_ranges
|
||||
errors.add(:end_date, :invalid_date_range) if end_date < start_date
|
||||
errors.add(:debate_end_date, :invalid_date_range) if debate_end_date < debate_start_date
|
||||
errors.add(:allegations_end_date, :invalid_date_range) if allegations_end_date < allegations_start_date
|
||||
errors.add(:end_date, :invalid_date_range) if end_date && start_date && end_date < start_date
|
||||
errors.add(:debate_end_date, :invalid_date_range) if debate_end_date && debate_start_date && debate_end_date < debate_start_date
|
||||
errors.add(:allegations_end_date, :invalid_date_range) if allegations_end_date && allegations_start_date && allegations_end_date < allegations_start_date
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -14,8 +14,14 @@ class Legislation::Question < ActiveRecord::Base
|
||||
validates :process, presence: true
|
||||
validates :title, presence: true
|
||||
|
||||
scope :sorted, -> { order('id ASC') }
|
||||
|
||||
def next_question_id
|
||||
@next_question_id ||= process.questions.where("id > ?", id).order('id ASC').limit(1).pluck(:id).first
|
||||
@next_question_id ||= process.questions.where("id > ?", id).sorted.limit(1).pluck(:id).first
|
||||
end
|
||||
|
||||
def first_question_id
|
||||
@first_question_id ||= process.questions.sorted.limit(1).pluck(:id).first
|
||||
end
|
||||
|
||||
def answer_for_user(user)
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<div class="small-12 medium-8 column">
|
||||
<% ::Legislation::DraftVersion::VALID_STATUSES.each do |status| %>
|
||||
<%= f.radio_button :status, status, label: false %>
|
||||
<%= f.label t("admin.legislation.draft_versions.statuses.#{status}") %>
|
||||
<%= f.label "status_#{status}", t("admin.legislation.draft_versions.statuses.#{status}") %>
|
||||
<small><%= t("admin.legislation.draft_versions.form.hints.status.#{status}") %></small>
|
||||
<br/>
|
||||
<% end %>
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.legislation.processes.process.title") %></th>
|
||||
<th><%= t("admin.legislation.processes.process.status") %></th>
|
||||
<th><%= t("admin.legislation.processes.process.creation_date") %></th>
|
||||
<th><%= t("admin.legislation.processes.process.comments") %></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -30,6 +32,8 @@
|
||||
<td class="small-12 medium-8">
|
||||
<%= link_to process.title, edit_admin_legislation_process_path(process) %>
|
||||
</td>
|
||||
<td><%= t("admin.legislation.processes.process.status_#{process.status}") %></td>
|
||||
<td><%= I18n.l process.created_at.to_date %></td>
|
||||
<td><%= process.total_comments %></td>
|
||||
<td>
|
||||
<%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_path(process),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<div class="notice-text">
|
||||
<%= flash_message %>
|
||||
<%= flash_message.try(:html_safe) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<div class="legislation-hero legislation-allegation no-margin-top grey-heading">
|
||||
<div class="row headline">
|
||||
<div class="small-12 medium-7 column">
|
||||
<h3><%= process.title %></h3>
|
||||
</div>
|
||||
<div class="small-12 medium-4 column right">
|
||||
<a class="button-subscribed expanded button strong" title="Suscríbete al proceso" data-remote="true" rel="nofollow" data-method="post" href="#">
|
||||
<span class="icon-checkmark-circle" aria-hidden="true"></span>
|
||||
<h3>Suscrito</h3>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="center half-gradient">
|
||||
<a class="button big center button-circle" title="Ver info del proceso">
|
||||
<span class="icon-angle-down" aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<% provide :title do %><%= "#{@draft_version.title} - #{t('.title')} - #{@process.title}" %><% end %>
|
||||
|
||||
<%= render 'process_header', process: @process %>
|
||||
<%= render 'legislation/processes/header', process: @process, header: :small %>
|
||||
|
||||
<div class="column row">
|
||||
<%= render 'legislation/processes/key_dates', process: @process, phase: :allegations %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% provide :title do %><%= "#{@draft_version.title} - #{@process.title}" %><% end %>
|
||||
|
||||
<%= render 'process_header', process: @process %>
|
||||
<%= render 'legislation/processes/header', process: @process, header: :small %>
|
||||
|
||||
<div class="column row">
|
||||
<%= render 'legislation/processes/key_dates', process: @process, phase: :allegations %>
|
||||
|
||||
24
app/views/legislation/processes/_header.html.erb
Normal file
24
app/views/legislation/processes/_header.html.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
<% if header == :small %>
|
||||
<div class="legislation-hero legislation-allegation no-margin-top grey-heading" data-target="legislation-header-small">
|
||||
<div class="row headline">
|
||||
<div class="small-12 medium-7 column">
|
||||
<h3><%= process.title %></h3>
|
||||
</div>
|
||||
<div class="small-12 medium-4 column right">
|
||||
<a class="button-subscribed expanded button strong" title="Suscríbete al proceso" data-remote="true" rel="nofollow" data-method="post" href="#">
|
||||
<span class="icon-checkmark-circle" aria-hidden="true"></span>
|
||||
<h3>Suscrito</h3>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="center half-gradient">
|
||||
<a class="button big center button-circle" title="<%= t('.view_process_information') %>" id="js-toggle-legislation-process-header">
|
||||
<span class="icon-angle-down" aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render 'legislation/processes/header_full', process: @process, hidden: true %>
|
||||
<% else %>
|
||||
<%= render 'legislation/processes/header_full', process: @process, hidden: false %>
|
||||
<% end %>
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="legislation-hero no-margin-top grey-heading">
|
||||
<div class="legislation-hero no-margin-top grey-heading" style="display:<%= hidden ? 'none' : 'block' %>" data-target="legislation-header-full">
|
||||
<div class="row headline">
|
||||
<div class="small-12 medium-7 column">
|
||||
<p class="grey"><%= t('.title') %></p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="small-12 medium-8 column">
|
||||
<div class="legislation-text">
|
||||
<h3><%= link_to process.title, process %></h3>
|
||||
<p><%= process.description %></p>
|
||||
<%= markdown(first_paragraph(process.description)) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -19,8 +19,12 @@
|
||||
|
||||
<div id="legislation" class="legislation-list small-12 medium-9 column">
|
||||
<div id="legislation-list">
|
||||
<%= render @processes %>
|
||||
<%= paginate @processes %>
|
||||
<% if @processes.any? %>
|
||||
<%= render @processes %>
|
||||
<%= paginate @processes %>
|
||||
<% else %>
|
||||
<%= t(".no_#{@current_filter}_processes") %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% provide :title do %><%= @process.title %><% end %>
|
||||
|
||||
<%= render 'legislation/processes/header_full', process: @process %>
|
||||
<%= render 'legislation/processes/header', process: @process, header: :full %>
|
||||
|
||||
<div class="row">
|
||||
<%= render 'legislation/processes/key_dates', process: @process, phase: @phase %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% provide :title do %><%= @process.title %><% end %>
|
||||
|
||||
<%= render 'legislation/processes/header_full', process: @process %>
|
||||
<%= render 'legislation/processes/header', process: @process, header: :full %>
|
||||
|
||||
<div class="row">
|
||||
<%= render 'legislation/processes/key_dates', process: @process, phase: @phase %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% provide :title do %><%= @process.title %><% end %>
|
||||
|
||||
<%= render 'header_full', process: @process %>
|
||||
<%= render 'legislation/processes/header', process: @process, header: :full %>
|
||||
|
||||
<div class="row">
|
||||
<%= render 'key_dates', process: @process, phase: :debate %>
|
||||
|
||||
@@ -17,4 +17,8 @@
|
||||
signin: link_to(t("legislation.questions.participation.signin"), new_user_session_path),
|
||||
signup: link_to(t("legislation.questions.participation.signup"), new_user_registration_path)).html_safe %>
|
||||
</div>
|
||||
<% elsif !@process.open_phase?(:debate) %>
|
||||
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
|
||||
<%= t("legislation.questions.participation.debate_phase_not_open") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
<span class="icon-angle-right" aria-hidden="true">
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% elsif @question.first_question_id %>
|
||||
<%= link_to legislation_process_question_path(@process, @question.first_question_id), class: "quiz-next-link" do %>
|
||||
<%= content_tag :div, class: "quiz-next" do %>
|
||||
<%= t('.first_question') %>
|
||||
<span class="icon-angle-right" aria-hidden="true">
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,7 +39,7 @@
|
||||
<div id="social-share" class="sidebar-divider"></div>
|
||||
<h3><%= t('.share') %></h3>
|
||||
<div class="social-share-full">
|
||||
<div class="social-share-button" data-title="<%= @question.title %>" data-img="" data-url="" data-desc="" data-via="">
|
||||
<div class="social-share-button" data-title="<%= @question.title.truncate(115) %>" 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="<%= t('.share_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="<%= t('.share_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="<%= t('.share_gplus') %>" href="#"><span class="sr-only">google_plus</span></a>
|
||||
|
||||
@@ -149,6 +149,8 @@ ignore_unused:
|
||||
- 'views.pagination.*' # kaminari
|
||||
- 'shared.suggest.*'
|
||||
- 'invisible_captcha.*'
|
||||
- 'admin.legislation.processes.process.*'
|
||||
- 'legislation.processes.index.*'
|
||||
# - '{devise,kaminari,will_paginate}.*'
|
||||
# - 'simple_form.{yes,no}'
|
||||
# - 'simple_form.{placeholders,hints,labels}.*'
|
||||
|
||||
@@ -84,6 +84,14 @@ en:
|
||||
title: Hidden debates
|
||||
legislation:
|
||||
processes:
|
||||
create:
|
||||
notice: 'Process created successfully. <a href="%{link}">Click to visit</a>'
|
||||
error: Process couldn't be created
|
||||
update:
|
||||
notice: 'Process updated successfully. <a href="%{link}">Click to visit</a>'
|
||||
error: Process couldn't be updated
|
||||
destroy:
|
||||
notice: Process deleted successfully
|
||||
edit:
|
||||
back: Back
|
||||
submit_button: Save changes
|
||||
@@ -113,11 +121,24 @@ en:
|
||||
process:
|
||||
title: Process
|
||||
comments: Comments
|
||||
status: Status
|
||||
creation_date: Creation date
|
||||
status_open: Open
|
||||
status_closed: Closed
|
||||
status_planned: Planned
|
||||
subnav:
|
||||
info: Information
|
||||
draft_texts: Text
|
||||
questions: Debate
|
||||
draft_versions:
|
||||
create:
|
||||
notice: 'Draft created successfully. <a href="%{link}">Click to visit</a>'
|
||||
error: Draft couldn't be created
|
||||
update:
|
||||
notice: 'Draft updated successfully. <a href="%{link}">Click to visit</a>'
|
||||
error: Draft couldn't be updated
|
||||
destroy:
|
||||
notice: Draft deleted successfully
|
||||
edit:
|
||||
back: Back
|
||||
submit_button: Save changes
|
||||
@@ -152,6 +173,14 @@ en:
|
||||
final_version: Final version
|
||||
status: Status
|
||||
questions:
|
||||
create:
|
||||
notice: 'Question created successfully. <a href="%{link}">Click to visit</a>'
|
||||
error: Question couldn't be created
|
||||
update:
|
||||
notice: 'Question updated successfully. <a href="%{link}">Click to visit</a>'
|
||||
error: Question couldn't be updated
|
||||
destroy:
|
||||
notice: Question deleted successfully
|
||||
edit:
|
||||
back: Back
|
||||
title: "Edit “%{question_title}”"
|
||||
|
||||
@@ -82,6 +82,14 @@ es:
|
||||
title: Debates ocultos
|
||||
legislation:
|
||||
processes:
|
||||
create:
|
||||
notice: 'Proceso creado correctamente. <a href="%{link}">Haz click para verlo</a>'
|
||||
error: No se ha podido crear el proceso
|
||||
update:
|
||||
notice: 'Proceso actualizado correctamente. <a href="%{link}">Haz click para verlo</a>'
|
||||
error: No se ha podido actualizar el proceso
|
||||
destroy:
|
||||
notice: Proceso eliminado correctamente
|
||||
edit:
|
||||
back: Volver
|
||||
submit_button: Guardar cambios
|
||||
@@ -111,11 +119,24 @@ es:
|
||||
process:
|
||||
title: Proceso
|
||||
comments: Comentarios
|
||||
status: Estado
|
||||
creation_date: Fecha creación
|
||||
status_open: Abierto
|
||||
status_closed: Cerrado
|
||||
status_planned: Próximamente
|
||||
subnav:
|
||||
info: Información
|
||||
draft_texts: Texto
|
||||
questions: Debate
|
||||
draft_versions:
|
||||
create:
|
||||
notice: 'Borrador creado correctamente. <a href="%{link}">Haz click para verlo</a>'
|
||||
error: No se ha podido crear el borrador
|
||||
update:
|
||||
notice: 'Borrador actualizado correctamente. <a href="%{link}">Haz click para verlo</a>'
|
||||
error: No se ha podido actualizar el borrador
|
||||
destroy:
|
||||
notice: Borrador eliminado correctamente
|
||||
edit:
|
||||
back: Volver
|
||||
submit_button: Guardar cambios
|
||||
@@ -150,6 +171,14 @@ es:
|
||||
final_version: Versión final
|
||||
status: Estado
|
||||
questions:
|
||||
create:
|
||||
notice: 'Pregunta creada correctamente. <a href="%{link}">Haz click para verla</a>'
|
||||
error: No se ha podido crear la pregunta
|
||||
update:
|
||||
notice: 'Pregunta actualizada correctamente. <a href="%{link}">Haz click para verla</a>'
|
||||
error: No se ha podido actualizar la pregunta
|
||||
destroy:
|
||||
notice: Pregunta eliminada correctamente
|
||||
edit:
|
||||
back: Volver
|
||||
title: "Editar “%{question_title}”"
|
||||
|
||||
@@ -239,6 +239,8 @@ en:
|
||||
text_body: Text
|
||||
text_comments: Comments
|
||||
processes:
|
||||
header:
|
||||
view_process_information: View process information
|
||||
debate:
|
||||
empty_questions: There aren't any questions
|
||||
participate: Participate in the debate
|
||||
@@ -254,6 +256,9 @@ en:
|
||||
open: Open processes
|
||||
next: Next
|
||||
past: Past
|
||||
no_open_processes: There aren't open processes
|
||||
no_next_processes: There aren't planned processes
|
||||
no_past_processes: There aren't past processes
|
||||
phase_not_open:
|
||||
not_open: This phase is not open yet
|
||||
phase_empty:
|
||||
@@ -278,6 +283,7 @@ en:
|
||||
answer_question: Submit answer
|
||||
comments: Comments
|
||||
next_question: Next question
|
||||
first_question: First question
|
||||
share: Share
|
||||
share_twitter: Share on Twitter
|
||||
share_facebook: Share on Facebook
|
||||
@@ -291,6 +297,7 @@ en:
|
||||
unauthenticated: You must %{signin} or %{signup} to participate.
|
||||
verified_only: Only verified users can participate, %{verify_account}.
|
||||
verify_account: verify your account
|
||||
debate_phase_not_open: Debate phase has finished and answers are not accepted anymore
|
||||
locale: English
|
||||
notifications:
|
||||
index:
|
||||
|
||||
@@ -239,6 +239,8 @@ es:
|
||||
text_body: Texto
|
||||
text_comments: Comentarios
|
||||
processes:
|
||||
header:
|
||||
view_process_information: Ver información del proceso
|
||||
debate:
|
||||
empty_questions: No hay preguntas
|
||||
participate: Realiza tus aportaciones al debate previo participando en los siguientes temas.
|
||||
@@ -254,6 +256,9 @@ es:
|
||||
open: Procesos activos
|
||||
next: Próximamente
|
||||
past: Terminados
|
||||
no_open_processes: No hay procesos activos
|
||||
no_next_processes: No hay procesos planeados
|
||||
no_past_processes: No hay procesos terminados
|
||||
phase_not_open:
|
||||
not_open: Esta fase del proceso todavía no está abierta
|
||||
phase_empty:
|
||||
@@ -278,6 +283,7 @@ es:
|
||||
answer_question: Enviar respuesta
|
||||
comments: Comentarios
|
||||
next_question: Siguiente pregunta
|
||||
first_question: Primera pregunta
|
||||
share: Compartir
|
||||
share_twitter: Compartir en Twitter
|
||||
share_facebook: Compartir en Facebook
|
||||
@@ -291,6 +297,7 @@ es:
|
||||
unauthenticated: Necesitas %{signin} o %{signup} para participar en el debate.
|
||||
verified_only: Solo los usuarios verificados pueden participar en el debate, %{verify_account}.
|
||||
verify_account: verifica tu cuenta
|
||||
debate_phase_not_open: La fase de debate previo ya ha finalizado y en este momento no se aceptan respuestas
|
||||
locale: Español
|
||||
notifications:
|
||||
index:
|
||||
|
||||
@@ -4,6 +4,17 @@ feature 'Legislation' do
|
||||
|
||||
context 'processes home page' do
|
||||
|
||||
scenario 'Processes can be listed' do
|
||||
visit legislation_processes_path
|
||||
expect(page).to have_text "There aren't open processes"
|
||||
|
||||
visit legislation_processes_path(filter: 'next')
|
||||
expect(page).to have_text "There aren't planned processes"
|
||||
|
||||
visit legislation_processes_path(filter: 'past')
|
||||
expect(page).to have_text "There aren't past processes"
|
||||
end
|
||||
|
||||
scenario 'Processes can be listed' do
|
||||
processes = create_list(:legislation_process, 3)
|
||||
|
||||
|
||||
17
spec/helpers/text_helper_spec.rb
Normal file
17
spec/helpers/text_helper_spec.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe TextHelper do
|
||||
|
||||
describe "#first_paragraph" do
|
||||
it "should return the first paragraph of a text" do
|
||||
text = "\n\nThis is the first paragraph\n\nThis is the second paragraph\n"
|
||||
expect(first_paragraph(text)).to eq("This is the first paragraph")
|
||||
end
|
||||
|
||||
it "should return blank if the text is blank" do
|
||||
expect(first_paragraph("")).to eq("")
|
||||
expect(first_paragraph(nil)).to eq("")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,10 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Legislation::Process, type: :model do
|
||||
let(:legislation_process) { build(:legislation_process) }
|
||||
let(:process) { create(:legislation_process) }
|
||||
|
||||
it "should be valid" do
|
||||
expect(legislation_process).to be_valid
|
||||
expect(process).to be_valid
|
||||
end
|
||||
|
||||
describe "date ranges validations" do
|
||||
@@ -76,8 +76,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
|
||||
describe "#open_phase?" do
|
||||
it "checks debate phase" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
# future
|
||||
process.update_attributes(debate_start_date: Date.current + 2.days, debate_end_date: Date.current + 3.days)
|
||||
expect(process.open_phase?(:debate)).to be false
|
||||
@@ -96,7 +94,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
end
|
||||
|
||||
it "checks allegations phase" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
# future
|
||||
process.update_attributes(allegations_start_date: Date.current + 2.days, allegations_end_date: Date.current + 3.days)
|
||||
@@ -116,8 +113,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
end
|
||||
|
||||
it "checks draft publication phase" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
# future
|
||||
process.update_attributes(draft_publication_date: Date.current + 2.days)
|
||||
expect(process.open_phase?(:draft_publication)).to be false
|
||||
@@ -132,8 +127,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
end
|
||||
|
||||
it "checks final version publication phase" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
# future
|
||||
process.update_attributes(final_publication_date: Date.current + 2.days)
|
||||
expect(process.open_phase?(:final_version_publication)).to be false
|
||||
@@ -150,8 +143,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
|
||||
describe "#show_phase?" do
|
||||
it "checks debate phase" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
# future
|
||||
process.update_attributes(debate_start_date: Date.current + 2.days, debate_end_date: Date.current + 3.days)
|
||||
expect(process.show_phase?(:debate)).to be false
|
||||
@@ -170,8 +161,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
end
|
||||
|
||||
it "checks allegations phase" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
# future
|
||||
process.update_attributes(allegations_start_date: Date.current + 2.days, allegations_end_date: Date.current + 3.days)
|
||||
expect(process.show_phase?(:allegations)).to be false
|
||||
@@ -190,8 +179,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
end
|
||||
|
||||
it "checks draft publication phase" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
# future
|
||||
process.update_attributes(draft_publication_date: Date.current + 2.days)
|
||||
expect(process.show_phase?(:draft_publication)).to be false
|
||||
@@ -206,8 +193,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
end
|
||||
|
||||
it "checks final version publication phase" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
# future
|
||||
process.update_attributes(final_publication_date: Date.current + 2.days)
|
||||
expect(process.show_phase?(:final_version_publication)).to be false
|
||||
@@ -221,4 +206,20 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
expect(process.show_phase?(:final_version_publication)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#status" do
|
||||
it "should detect planned phase" do
|
||||
process.update_attributes(start_date: Date.current + 2.days)
|
||||
expect(process.status).to eq(:planned)
|
||||
end
|
||||
|
||||
it "should detect closed phase" do
|
||||
process.update_attributes(end_date: Date.current - 2.days)
|
||||
expect(process.status).to eq(:closed)
|
||||
end
|
||||
|
||||
it "should detect open phase" do
|
||||
expect(process.status).to eq(:open)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Legislation::Question, type: :model do
|
||||
let(:legislation_question) { build(:legislation_question) }
|
||||
let(:question) { create(:legislation_question) }
|
||||
|
||||
it "should be valid" do
|
||||
expect(legislation_question).to be_valid
|
||||
expect(question).to be_valid
|
||||
end
|
||||
|
||||
context "can be deleted" do
|
||||
@@ -17,7 +17,6 @@ RSpec.describe Legislation::Question, type: :model do
|
||||
end
|
||||
|
||||
example "when it has options but no answers" do
|
||||
question = create(:legislation_question)
|
||||
create(:legislation_question_option, question: question, value: "Yes")
|
||||
create(:legislation_question_option, question: question, value: "No")
|
||||
|
||||
@@ -27,7 +26,6 @@ RSpec.describe Legislation::Question, type: :model do
|
||||
end
|
||||
|
||||
example "when it has options and answers" do
|
||||
question = create(:legislation_question)
|
||||
option_1 = create(:legislation_question_option, question: question, value: "Yes")
|
||||
option_2 = create(:legislation_question_option, question: question, value: "No")
|
||||
create(:legislation_answer, question: question, question_option: option_1)
|
||||
@@ -38,4 +36,27 @@ RSpec.describe Legislation::Question, type: :model do
|
||||
end.to change { Legislation::Question.count }.by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#next_question_id" do
|
||||
let!(:question1) { create(:legislation_question) }
|
||||
let!(:question2) { create(:legislation_question, legislation_process_id: question1.legislation_process_id) }
|
||||
|
||||
it "should return the next question" do
|
||||
expect(question1.next_question_id).to eq(question2.id)
|
||||
end
|
||||
|
||||
it "should return nil" do
|
||||
expect(question2.next_question_id).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#first_question_id" do
|
||||
let!(:question1) { create(:legislation_question) }
|
||||
let!(:question2) { create(:legislation_question, legislation_process_id: question1.legislation_process_id) }
|
||||
|
||||
it "should return the first question" do
|
||||
expect(question1.first_question_id).to eq(question1.id)
|
||||
expect(question2.first_question_id).to eq(question1.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user