Legislation Process page
This commit is contained in:
@@ -9,4 +9,24 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def draft_publication
|
||||
phase :draft_publication
|
||||
end
|
||||
|
||||
def allegations
|
||||
phase :allegations
|
||||
end
|
||||
|
||||
def final_version_publication
|
||||
phase :final_version_publication
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def phase(phase)
|
||||
@process = ::Legislation::Process.find(params[:process_id])
|
||||
@phase = phase
|
||||
render :phase
|
||||
end
|
||||
end
|
||||
|
||||
7
app/controllers/legislation/questions_controller.rb
Normal file
7
app/controllers/legislation/questions_controller.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Legislation::QuestionsController < Legislation::BaseController
|
||||
load_and_authorize_resource :process
|
||||
load_and_authorize_resource :question, through: :process
|
||||
|
||||
def show
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
module LegislationHelper
|
||||
def format_date(date)
|
||||
l(date, format: "%d %b %Y")
|
||||
l(date, format: "%d %b %Y") if date
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ module Abilities
|
||||
can :read, User
|
||||
can [:search, :read], Annotation
|
||||
can :new, DirectMessage
|
||||
can [:read], Legislation::Process
|
||||
can [:read, :draft_version_publication, :allegations, :final_version_publication], Legislation::Process
|
||||
can [:read], Legislation::DraftVersion
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@ class Legislation::Process < ActiveRecord::Base
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
has_many :draft_versions, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id'
|
||||
has_one :final_draft_version, -> { where final_version: true }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id'
|
||||
has_many :questions, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id'
|
||||
|
||||
validates :title, presence: true
|
||||
@@ -18,7 +19,38 @@ class Legislation::Process < ActiveRecord::Base
|
||||
validates :allegations_end_date, presence: true
|
||||
validates :final_publication_date, presence: true
|
||||
|
||||
scope :open, -> {where("start_date <= ? and end_date >= ?", Time.current, Time.current) }
|
||||
scope :next, -> {where("start_date > ?", Time.current) }
|
||||
scope :past, -> {where("end_date < ?", Time.current) }
|
||||
scope :open, -> {where("start_date <= ? and end_date >= ?", Date.current, Date.current) }
|
||||
scope :next, -> {where("start_date > ?", Date.current) }
|
||||
scope :past, -> {where("end_date < ?", Date.current) }
|
||||
|
||||
def open_phase?(phase)
|
||||
today = Date.current
|
||||
|
||||
case phase
|
||||
when :debate
|
||||
today >= debate_start_date && today <= debate_end_date
|
||||
when :draft_publication
|
||||
today >= draft_publication_date
|
||||
when :allegations
|
||||
today >= allegations_start_date && today <= allegations_end_date
|
||||
when :final_version_publication
|
||||
today >= final_publication_date
|
||||
end
|
||||
end
|
||||
|
||||
def show_phase?(phase)
|
||||
# show past phases even if they're finished
|
||||
today = Date.current
|
||||
|
||||
case phase
|
||||
when :debate
|
||||
today >= debate_start_date
|
||||
when :draft_publication
|
||||
today >= draft_publication_date
|
||||
when :allegations
|
||||
today >= allegations_start_date
|
||||
when :final_version_publication
|
||||
today >= final_publication_date
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
14
app/views/legislation/processes/_debate.html.erb
Normal file
14
app/views/legislation/processes/_debate.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="debate-list">
|
||||
<% if process.questions.empty? %>
|
||||
<p><%= t('.empty_questions') %></p>
|
||||
<% else %>
|
||||
<%= render process.questions %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<div class="debate-info"><%= t('.participate') %></div>
|
||||
</div>
|
||||
|
||||
37
app/views/legislation/processes/_header_full.html.erb
Normal file
37
app/views/legislation/processes/_header_full.html.erb
Normal file
@@ -0,0 +1,37 @@
|
||||
<div class="legislation-hero no-margin-top grey-heading">
|
||||
<div class="row headline">
|
||||
<div class="small-12 medium-7 column">
|
||||
<p class="grey"><%= t('.title') %></p>
|
||||
<h2>
|
||||
<%= process.title %>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="small-12 medium-4 column right">
|
||||
<a class="button-subscribe expanded button strong" title="Suscríbete al proceso" data-remote="true" rel="nofollow" data-method="post" href="/proposals/6-soluta-sed-sapiente-dolores/vote?value=yes">
|
||||
<h3>Suscríbete al proceso</h3>
|
||||
<p>Recibe notificaciones clave sobre el proceso</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row description">
|
||||
<div class="small-12 medium-4 column">
|
||||
<h4><%= t('.description') %></h4>
|
||||
<%= markdown process.description %>
|
||||
</div>
|
||||
<div class="small-12 medium-4 column">
|
||||
<h4><%= t('.target') %></h4>
|
||||
<%= markdown process.target %>
|
||||
</div>
|
||||
<div class="small-12 medium-4 column">
|
||||
<h4><%= t('.how_to_participate') %></h4>
|
||||
<%= markdown process.how_to_participate %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="center half-gradient">
|
||||
<a class="button big center strong" title="<%= t('.more_info') %>">
|
||||
<%= t('.more_info') %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
29
app/views/legislation/processes/_key_dates.html.erb
Normal file
29
app/views/legislation/processes/_key_dates.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<nav class="legislation-process-categories">
|
||||
<%= render 'legislation/processes/key_dates_svg' %>
|
||||
<ul>
|
||||
<li <%= "class=active" if phase == :debate %>>
|
||||
<%= link_to process do %>
|
||||
<h4><%= t('legislation.processes.shared.debate_dates') %></h4>
|
||||
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
||||
<% end %>
|
||||
</li>
|
||||
<li <%= "class=active" if phase == :draft_publication %>>
|
||||
<%= link_to legislation_process_draft_publication_path(process) do %>
|
||||
<h4><%= t('legislation.processes.shared.draft_publication_date') %></h4>
|
||||
<p><%= format_date(process.draft_publication_date) %></p>
|
||||
<% end %>
|
||||
</li>
|
||||
<li <%= "class=active" if phase == :allegations %>>
|
||||
<%= link_to legislation_process_allegations_path(process) do %>
|
||||
<h4><%= t('legislation.processes.shared.allegations_dates') %></h4>
|
||||
<p><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %></p>
|
||||
<% end %>
|
||||
</li>
|
||||
<li <%= "class=active" if phase == :final_version_publication %>>
|
||||
<%= link_to legislation_process_final_version_publication_path(process) do %>
|
||||
<h4><%= t('legislation.processes.shared.final_publication_date') %></h4>
|
||||
<p><%= format_date(process.final_publication_date) %></p>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
5
app/views/legislation/processes/_key_dates_svg.html.erb
Normal file
5
app/views/legislation/processes/_key_dates_svg.html.erb
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 59 KiB |
@@ -0,0 +1,9 @@
|
||||
<% if process.draft_versions.any? %>
|
||||
<ul>
|
||||
<% process.draft_versions.each do |draft_version| %>
|
||||
<li><%= link_to draft_version.title, legislation_process_draft_version_path(process, draft_version) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p><%= t('.empty') %></p>
|
||||
<% end %>
|
||||
@@ -0,0 +1,9 @@
|
||||
<% if process.draft_versions.any? %>
|
||||
<ul>
|
||||
<% process.draft_versions.each do |draft_version| %>
|
||||
<li><%= link_to draft_version.title, legislation_process_draft_version_path(process, draft_version) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p><%= t('.empty') %></p>
|
||||
<% end %>
|
||||
@@ -0,0 +1,5 @@
|
||||
<% if process.final_draft_version %>
|
||||
<p><%= legislation_process_draft_version_path(process.final_draft_version) %></p>
|
||||
<% else %>
|
||||
<p><%= t('.empty') %></p>
|
||||
<% end %>
|
||||
13
app/views/legislation/processes/_phase_not_open.html.erb
Normal file
13
app/views/legislation/processes/_phase_not_open.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="debate-draft">
|
||||
<div class="small-12 medium-7 column">
|
||||
<h3><%= t('.not_open') %></h3>
|
||||
<p>Suscríbete al proceso para recibir un aviso en el momento en que se abra.</p>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-5 column">
|
||||
<button class="button-subscribe expanded button strong" title="Suscríbete al proceso" data-remote="true" rel="nofollow" data-method="post" href="/proposals/6-soluta-sed-sapiente-dolores/vote?value=yes">
|
||||
<h3>Suscríbete al proceso</h3>
|
||||
<p>Recibe notificaciones clave sobre el proceso</p>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -16,25 +16,25 @@
|
||||
|
||||
<div class="column row">
|
||||
<div class="small-12 column legislation-calendar-info">
|
||||
<p><%= t('legislation.processes.common.key_dates') %></p>
|
||||
<p><%= t('legislation.processes.shared.key_dates') %></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column row small-collapse medium-uncollapse legislation-calendar">
|
||||
<div class="small-6 medium-3 column">
|
||||
<h5><%= t('legislation.processes.common.debate_dates') %></h5>
|
||||
<h5><%= t('legislation.processes.shared.debate_dates') %></h5>
|
||||
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
||||
</div>
|
||||
<div class="small-6 medium-3 column">
|
||||
<h5><%= t('legislation.processes.common.draft_publication_date') %></h5>
|
||||
<h5><%= t('legislation.processes.shared.draft_publication_date') %></h5>
|
||||
<p><%= format_date(process.draft_publication_date) %></p>
|
||||
</div>
|
||||
<div class="small-6 medium-3 column">
|
||||
<h5><%= t('legislation.processes.common.allegations_dates') %></h5>
|
||||
<h5><%= t('legislation.processes.shared.allegations_dates') %></h5>
|
||||
<p><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %></p>
|
||||
</div>
|
||||
<div class="small-6 medium-3 column">
|
||||
<h5><%= t('legislation.processes.common.final_publication_date') %></h5>
|
||||
<h5><%= t('legislation.processes.shared.final_publication_date') %></h5>
|
||||
<p><%= format_date(process.final_publication_date) %></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
15
app/views/legislation/processes/phase.html.erb
Normal file
15
app/views/legislation/processes/phase.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<%= render 'legislation/processes/header_full', process: @process %>
|
||||
|
||||
<div class="row">
|
||||
<%= render 'legislation/processes/key_dates', process: @process, phase: @phase %>
|
||||
|
||||
<div class="debate-chooser">
|
||||
<div class="row">
|
||||
<% if @process.show_phase?(@phase) %>
|
||||
<%= render "phase_#{@phase}", process: @process %>
|
||||
<% else %>
|
||||
<%= render 'legislation/processes/phase_not_open' %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,9 +1,16 @@
|
||||
|
||||
<%= render 'header_full', process: @process %>
|
||||
|
||||
<div class="row">
|
||||
<%= render 'key_dates', process: @process, phase: :debate %>
|
||||
|
||||
<h1><%= @process.title %></h1>
|
||||
|
||||
<% @process.draft_versions.each do |draft_version| %>
|
||||
<%= link_to draft_version.title, legislation_process_draft_version_path(@process, draft_version) %>
|
||||
<div class="debate-chooser">
|
||||
<div class="row">
|
||||
<% if @process.show_phase?(:debate) %>
|
||||
<%= render 'debate', process: @process %>
|
||||
<% else %>
|
||||
<%= render 'phase_not_open' %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
11
app/views/legislation/questions/_question.html.erb
Normal file
11
app/views/legislation/questions/_question.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<div class="debate-block">
|
||||
<div class="debate-type">
|
||||
<%= t('.debate') %> <span class="icon-debates" aria-hidden="true"></span>
|
||||
</div>
|
||||
<div class="debate-title">
|
||||
<h4><%= link_to question.title, legislation_process_question_path(question.process, question) %></h4>
|
||||
</div>
|
||||
<div class="debate-meta">
|
||||
<span class="icon-comments" aria-hidden="true"></span> <span class="debate-comments"><%= link_to t('.comments', count: question.comments.count), legislation_process_question_path(question.process, question) %></span> · <span class="debate-date"><%= format_date question.created_at %></span>
|
||||
</div>
|
||||
</div>
|
||||
3
app/views/legislation/questions/show.html.erb
Normal file
3
app/views/legislation/questions/show.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="row">
|
||||
<p><%= @question.title %></p>
|
||||
</div>
|
||||
@@ -227,21 +227,45 @@ en:
|
||||
show:
|
||||
see_changes: See changes
|
||||
processes:
|
||||
common:
|
||||
key_dates: "Key dates:"
|
||||
debate_dates: Debate
|
||||
draft_publication_date: Draft publication
|
||||
allegations_dates: Allegations
|
||||
final_publication_date: Final result publication
|
||||
debate:
|
||||
empty_questions: There aren't any questions
|
||||
participate: Participate in the debate
|
||||
header_full:
|
||||
title: Participate
|
||||
description: Description
|
||||
target: Target
|
||||
how_to_participate: How to participate
|
||||
more_info: More information and context
|
||||
index:
|
||||
hightlighted_processes: HIGHLIGHTED PROCESSES
|
||||
filters:
|
||||
open: Open processes
|
||||
next: Next
|
||||
past: Past
|
||||
phase_not_open:
|
||||
not_open: This phase is not open yet
|
||||
phase_draft_publication:
|
||||
empty: There are no drafts published
|
||||
phase_allegations:
|
||||
empty: There are no drafts published
|
||||
phase_final_version_publication:
|
||||
empty: Results have not been published yet
|
||||
process:
|
||||
see_latest_comments: See latest comments
|
||||
see_latest_comments_title: Comment on this process
|
||||
shared:
|
||||
key_dates: "Key dates:"
|
||||
debate_dates: Debate
|
||||
draft_publication_date: Draft publication
|
||||
allegations_dates: Allegations
|
||||
final_publication_date: Final result publication
|
||||
questions:
|
||||
question:
|
||||
comments:
|
||||
zero: No comments
|
||||
one: "%{count} comment"
|
||||
other: "%{count} comments"
|
||||
debate: Debate
|
||||
locale: English
|
||||
notifications:
|
||||
index:
|
||||
|
||||
@@ -227,21 +227,45 @@ es:
|
||||
show:
|
||||
see_changes: Ver cambios
|
||||
processes:
|
||||
common:
|
||||
key_dates: "Fechas clave:"
|
||||
debate_dates: Debate previo
|
||||
draft_publication_date: Publicación borrador
|
||||
allegations_dates: Alegaciones
|
||||
final_publication_date: Publicación resultados
|
||||
debate:
|
||||
empty_questions: No hay preguntas
|
||||
participate: Realiza tus aportaciones al debate previo participando en los siguientes temas.
|
||||
header_full:
|
||||
title: Colabora en la elaboración de la normativa sobre
|
||||
description: En qué consiste
|
||||
target: A quién va dirigido
|
||||
how_to_participate: Cómo puedes participar
|
||||
more_info: Más información y contexto
|
||||
index:
|
||||
hightlighted_processes: PROCESOS DESTACADOS
|
||||
filters:
|
||||
open: Procesos activos
|
||||
next: Próximamente
|
||||
past: Terminados
|
||||
phase_not_open:
|
||||
not_open: Esta fase del proceso todavía no está abierta
|
||||
phase_draft_publication:
|
||||
empty: No se ha publicado ningún borrador
|
||||
phase_allegations:
|
||||
empty: No se ha publicado ningún borrador
|
||||
phase_final_version_publication:
|
||||
empty: No se ha publicado el resultado todavía
|
||||
process:
|
||||
see_latest_comments: Ver últimas aportaciones
|
||||
see_latest_comments_title: Aportar a este proceso
|
||||
shared:
|
||||
key_dates: "Fechas clave:"
|
||||
debate_dates: Debate previo
|
||||
draft_publication_date: Publicación borrador
|
||||
allegations_dates: Alegaciones
|
||||
final_publication_date: Publicación resultados
|
||||
questions:
|
||||
question:
|
||||
comments:
|
||||
zero: Sin comentarios
|
||||
one: "%{count} comentario"
|
||||
other: "%{count} comentarios"
|
||||
debate: Debate
|
||||
locale: Español
|
||||
notifications:
|
||||
index:
|
||||
|
||||
@@ -92,6 +92,12 @@ Rails.application.routes.draw do
|
||||
|
||||
namespace :legislation do
|
||||
resources :processes, only: [:index, :show] do
|
||||
get :draft_publication
|
||||
get :allegations
|
||||
get :final_version_publication
|
||||
resources :questions, only: [:show] do
|
||||
resources :answers, only: [:create]
|
||||
end
|
||||
resources :draft_versions, only: [:show] do
|
||||
get :changes
|
||||
resources :annotations
|
||||
|
||||
@@ -35,4 +35,24 @@ feature 'Legislation' do
|
||||
expect(page).to have_content('Process past')
|
||||
end
|
||||
end
|
||||
|
||||
context 'processes#show' do
|
||||
scenario 'Debate phase not open' do
|
||||
process = create(:legislation_process, title: "Process open",
|
||||
debate_start_date: Date.current + 1.day, debate_end_date: Date.current + 2.days)
|
||||
|
||||
visit legislation_process_path(process)
|
||||
|
||||
expect(page).to have_content("This phase is not open yet")
|
||||
end
|
||||
|
||||
scenario 'Debate phase open' do
|
||||
process = create(:legislation_process, title: "Process open",
|
||||
debate_start_date: Date.current - 1.day, debate_end_date: Date.current + 2.days)
|
||||
|
||||
visit legislation_process_path(process)
|
||||
|
||||
expect(page).to have_content("Participate in the debate")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
@process_3 = create(:legislation_process, start_date: Date.current - 4.days, end_date: Date.current - 3.days)
|
||||
end
|
||||
|
||||
it "filter open" do
|
||||
it "filters open" do
|
||||
open_processes = ::Legislation::Process.open
|
||||
|
||||
expect(open_processes).to include(@process_1)
|
||||
@@ -22,7 +22,7 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
expect(open_processes).to_not include(@process_3)
|
||||
end
|
||||
|
||||
it "filter next" do
|
||||
it "filters next" do
|
||||
next_processes = ::Legislation::Process.next
|
||||
|
||||
expect(next_processes).to include(@process_2)
|
||||
@@ -30,7 +30,7 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
expect(next_processes).to_not include(@process_3)
|
||||
end
|
||||
|
||||
it "filter past" do
|
||||
it "filters past" do
|
||||
past_processes = ::Legislation::Process.past
|
||||
|
||||
expect(past_processes).to include(@process_3)
|
||||
@@ -38,4 +38,152 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
expect(past_processes).to_not include(@process_1)
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
# started
|
||||
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current + 1.day)
|
||||
expect(process.open_phase?(:debate)).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(debate_start_date: Date.current, debate_end_date: Date.current + 1.day)
|
||||
expect(process.open_phase?(:debate)).to be true
|
||||
|
||||
# past
|
||||
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.day)
|
||||
expect(process.open_phase?(:debate)).to be false
|
||||
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.open_phase?(:allegations)).to be false
|
||||
|
||||
# started
|
||||
process.update_attributes(allegations_start_date: Date.current - 2.days, allegations_end_date: Date.current + 1.day)
|
||||
expect(process.open_phase?(:allegations)).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(allegations_start_date: Date.current, allegations_end_date: Date.current + 1.day)
|
||||
expect(process.open_phase?(:allegations)).to be true
|
||||
|
||||
# past
|
||||
process.update_attributes(allegations_start_date: Date.current - 2.days, allegations_end_date: Date.current - 1.day)
|
||||
expect(process.open_phase?(:allegations)).to be false
|
||||
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
|
||||
|
||||
# past
|
||||
process.update_attributes(draft_publication_date: Date.current - 2.days)
|
||||
expect(process.open_phase?(:draft_publication)).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(draft_publication_date: Date.current)
|
||||
expect(process.open_phase?(:draft_publication)).to be true
|
||||
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
|
||||
|
||||
# past
|
||||
process.update_attributes(final_publication_date: Date.current - 2.days)
|
||||
expect(process.open_phase?(:final_version_publication)).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(final_publication_date: Date.current)
|
||||
expect(process.open_phase?(:final_version_publication)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
# started
|
||||
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current + 1.day)
|
||||
expect(process.show_phase?(:debate)).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(debate_start_date: Date.current, debate_end_date: Date.current + 1.day)
|
||||
expect(process.show_phase?(:debate)).to be true
|
||||
|
||||
# past
|
||||
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.day)
|
||||
expect(process.show_phase?(:debate)).to be true
|
||||
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
|
||||
|
||||
# started
|
||||
process.update_attributes(allegations_start_date: Date.current - 2.days, allegations_end_date: Date.current + 1.day)
|
||||
expect(process.show_phase?(:allegations)).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(allegations_start_date: Date.current, allegations_end_date: Date.current + 1.day)
|
||||
expect(process.show_phase?(:allegations)).to be true
|
||||
|
||||
# past
|
||||
process.update_attributes(allegations_start_date: Date.current - 2.days, allegations_end_date: Date.current - 1.day)
|
||||
expect(process.show_phase?(:allegations)).to be true
|
||||
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
|
||||
|
||||
# past
|
||||
process.update_attributes(draft_publication_date: Date.current - 2.days)
|
||||
expect(process.show_phase?(:draft_publication)).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(draft_publication_date: Date.current)
|
||||
expect(process.show_phase?(:draft_publication)).to be true
|
||||
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
|
||||
|
||||
# past
|
||||
process.update_attributes(final_publication_date: Date.current - 2.days)
|
||||
expect(process.show_phase?(:final_version_publication)).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(final_publication_date: Date.current)
|
||||
expect(process.show_phase?(:final_version_publication)).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user