Merge branch 'master' into amiedes-api-dev-PRs-2
This commit is contained in:
@@ -45,7 +45,11 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
:draft_publication_date,
|
||||
:allegations_start_date,
|
||||
:allegations_end_date,
|
||||
:final_publication_date
|
||||
:result_publication_date,
|
||||
:debate_phase_enabled,
|
||||
:allegations_phase_enabled,
|
||||
:draft_publication_enabled,
|
||||
:result_publication_enabled
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ class Legislation::AnnotationsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
if !@process.open_phase?(:allegations) || @draft_version.final_version?
|
||||
if !@process.allegations_phase.open? || @draft_version.final_version?
|
||||
render json: {}, status: :not_found and return
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class Legislation::AnswersController < Legislation::BaseController
|
||||
respond_to :html, :js
|
||||
|
||||
def create
|
||||
if @process.open_phase?(:debate)
|
||||
if @process.debate_phase.open?
|
||||
@answer.user = current_user
|
||||
@answer.save
|
||||
track_event
|
||||
|
||||
@@ -8,9 +8,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def show
|
||||
if @process.active_phase?(:allegations) && @process.show_phase?(:allegations) && draft_version = @process.draft_versions.published.last
|
||||
if @process.allegations_phase.enabled? && @process.allegations_phase.started? && draft_version = @process.draft_versions.published.last
|
||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||
elsif @process.active_phase?(:debate)
|
||||
elsif @process.debate_phase.enabled?
|
||||
redirect_to legislation_process_debate_path(@process)
|
||||
else
|
||||
redirect_to legislation_process_allegations_path(@process)
|
||||
@@ -18,9 +18,10 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def debate
|
||||
phase :debate
|
||||
set_process
|
||||
@phase = :debate_phase
|
||||
|
||||
if @process.show_phase?(:debate)
|
||||
if @process.debate_phase.started?
|
||||
render :debate
|
||||
else
|
||||
render :phase_not_open
|
||||
@@ -28,9 +29,10 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def draft_publication
|
||||
phase :draft_publication
|
||||
set_process
|
||||
@phase = :draft_publication
|
||||
|
||||
if @process.show_phase?(@phase)
|
||||
if @process.draft_publication.started?
|
||||
if draft_version = @process.draft_versions.published.last
|
||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||
else
|
||||
@@ -42,9 +44,10 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def allegations
|
||||
phase :allegations
|
||||
set_process
|
||||
@phase = :allegations_phase
|
||||
|
||||
if @process.show_phase?(@phase)
|
||||
if @process.allegations_phase.started?
|
||||
if draft_version = @process.draft_versions.published.last
|
||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||
else
|
||||
@@ -55,10 +58,11 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
end
|
||||
|
||||
def final_version_publication
|
||||
phase :final_version_publication
|
||||
def result_publication
|
||||
set_process
|
||||
@phase = :result_publication
|
||||
|
||||
if @process.show_phase?(@phase)
|
||||
if @process.result_publication.started?
|
||||
if final_version = @process.final_draft_version
|
||||
redirect_to legislation_process_draft_version_path(@process, final_version)
|
||||
else
|
||||
@@ -71,8 +75,7 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
|
||||
private
|
||||
|
||||
def phase(phase)
|
||||
def set_process
|
||||
@process = ::Legislation::Process.find(params[:process_id])
|
||||
@phase = phase
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ module Abilities
|
||||
can [:read, :print], Budget::Investment
|
||||
can :read_results, Budget, phase: "finished"
|
||||
can :new, DirectMessage
|
||||
can [:read, :debate, :draft_publication, :allegations, :final_version_publication], Legislation::Process
|
||||
can [:read, :debate, :draft_publication, :allegations, :result_publication], Legislation::Process
|
||||
can [:read, :changes, :go_to_version], Legislation::DraftVersion
|
||||
can [:read], Legislation::Question
|
||||
can [:create], Legislation::Answer
|
||||
|
||||
@@ -8,7 +8,7 @@ class DirectMessage < ActiveRecord::Base
|
||||
validates :receiver, presence: true
|
||||
validate :max_per_day
|
||||
|
||||
scope :today, lambda { where('DATE(created_at) = ?', Date.current) }
|
||||
scope :today, lambda { where('DATE(created_at) = DATE(?)', Time.current) }
|
||||
|
||||
def max_per_day
|
||||
return if errors.any?
|
||||
|
||||
@@ -2,6 +2,8 @@ class Legislation::Process < ActiveRecord::Base
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase draft_publication result_publication).freeze
|
||||
|
||||
has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
has_one :final_draft_version, -> { where final_version: true, status: 'published' }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id'
|
||||
has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
@@ -19,48 +21,24 @@ class Legislation::Process < ActiveRecord::Base
|
||||
scope :next, -> { where("start_date > ?", Date.current).order('id DESC') }
|
||||
scope :past, -> { where("end_date < ?", Date.current).order('id DESC') }
|
||||
|
||||
def open_phase?(phase)
|
||||
today = Date.current
|
||||
|
||||
case phase
|
||||
when :debate
|
||||
active_phase?(:debate) && today >= debate_start_date && today <= debate_end_date
|
||||
when :draft_publication
|
||||
active_phase?(:draft_publication) && today >= draft_publication_date
|
||||
when :allegations
|
||||
active_phase?(:allegations) && today >= allegations_start_date && today <= allegations_end_date
|
||||
when :final_version_publication
|
||||
active_phase?(:final_version_publication) && today >= final_publication_date
|
||||
end
|
||||
def debate_phase
|
||||
Legislation::Process::Phase.new(debate_start_date, debate_end_date, debate_phase_enabled)
|
||||
end
|
||||
|
||||
def show_phase?(phase)
|
||||
# show past phases even if they're finished
|
||||
today = Date.current
|
||||
|
||||
case phase
|
||||
when :debate
|
||||
active_phase?(:debate) && today >= debate_start_date
|
||||
when :draft_publication
|
||||
active_phase?(:draft_publication) && today >= draft_publication_date
|
||||
when :allegations
|
||||
active_phase?(:allegations) && today >= allegations_start_date
|
||||
when :final_version_publication
|
||||
active_phase?(:final_version_publication) && today >= final_publication_date
|
||||
end
|
||||
def allegations_phase
|
||||
Legislation::Process::Phase.new(allegations_start_date, allegations_end_date, allegations_phase_enabled)
|
||||
end
|
||||
|
||||
def active_phase?(phase)
|
||||
case phase
|
||||
when :debate
|
||||
debate_start_date.present? && debate_end_date.present?
|
||||
when :draft_publication
|
||||
draft_publication_date.present?
|
||||
when :allegations
|
||||
allegations_start_date.present? && allegations_end_date.present?
|
||||
when :final_version_publication
|
||||
final_publication_date.present?
|
||||
end
|
||||
def draft_publication
|
||||
Legislation::Process::Publication.new(draft_publication_date, draft_publication_enabled)
|
||||
end
|
||||
|
||||
def result_publication
|
||||
Legislation::Process::Publication.new(result_publication_date, result_publication_enabled)
|
||||
end
|
||||
|
||||
def enabled_phases_and_publications_count
|
||||
PHASES_AND_PUBLICATIONS.count { |process| send(process).enabled? }
|
||||
end
|
||||
|
||||
def total_comments
|
||||
|
||||
23
app/models/legislation/process/phase.rb
Normal file
23
app/models/legislation/process/phase.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Legislation::Process::Phase
|
||||
|
||||
def initialize(start_date, end_date, enabled)
|
||||
@start_date = start_date
|
||||
@end_date = end_date
|
||||
@enabled = enabled
|
||||
end
|
||||
|
||||
def enabled?
|
||||
@enabled
|
||||
end
|
||||
|
||||
def started?
|
||||
enabled? && Date.current >= @start_date
|
||||
end
|
||||
|
||||
def open?
|
||||
started? && Date.current <= @end_date
|
||||
end
|
||||
|
||||
end
|
||||
22
app/models/legislation/process/publication.rb
Normal file
22
app/models/legislation/process/publication.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Legislation::Process::Publication
|
||||
|
||||
def initialize(publication_date, enabled)
|
||||
@publication_date = publication_date
|
||||
@enabled = enabled
|
||||
end
|
||||
|
||||
def enabled?
|
||||
@enabled
|
||||
end
|
||||
|
||||
def started?
|
||||
enabled? && Date.current >= @publication_date
|
||||
end
|
||||
|
||||
def open?
|
||||
started?
|
||||
end
|
||||
|
||||
end
|
||||
@@ -37,6 +37,6 @@ class Legislation::Question < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def comments_open?
|
||||
process.open_phase?(:debate)
|
||||
process.debate_phase.open?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,8 +70,7 @@
|
||||
id: "debate_end_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column">
|
||||
<%= check_box_tag :debate_phase_active, @process.active_phase?(:debate), @process.new_record? || @process.active_phase?(:debate), data: {disable_date: "debate"} %>
|
||||
<%= label_tag :debate_phase_active, t('admin.legislation.processes.form.active') %>
|
||||
<%= f.check_box :debate_phase_enabled, checked: @process.debate_phase.enabled?, label: t('admin.legislation.processes.form.enabled') %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
@@ -104,8 +103,7 @@
|
||||
id: "allegations_end_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column">
|
||||
<%= check_box_tag :allegations_phase_active, @process.active_phase?(:allegations), @process.new_record? || @process.active_phase?(:allegations), data: {disable_date: "allegations"} %>
|
||||
<%= label_tag :allegations_phase_active, t('admin.legislation.processes.form.active') %>
|
||||
<%= f.check_box :allegations_phase_enabled, checked: @process.allegations_phase.enabled?, label: t('admin.legislation.processes.form.enabled') %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
@@ -125,8 +123,7 @@
|
||||
id: "draft_publication_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column">
|
||||
<%= check_box_tag :draft_publication_phase_active, @process.active_phase?(:draft_publication), @process.new_record? || @process.active_phase?(:draft_publication), data: {disable_date: "draft_publication"} %>
|
||||
<%= label_tag :draft_publication_phase_active, t('admin.legislation.processes.form.active') %>
|
||||
<%= f.check_box :draft_publication_enabled, checked: @process.draft_publication.enabled?, label: t('admin.legislation.processes.form.enabled') %>
|
||||
</div>
|
||||
<div class="small-12 column">
|
||||
<hr>
|
||||
@@ -135,18 +132,17 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :final_publication_date %>
|
||||
<%= f.label :result_publication_date %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column end">
|
||||
<%= f.text_field :final_publication_date,
|
||||
<%= f.text_field :result_publication_date,
|
||||
label: false,
|
||||
value: format_date_for_calendar_form(@process.final_publication_date),
|
||||
value: format_date_for_calendar_form(@process.result_publication_date),
|
||||
class: "js-calendar-full",
|
||||
id: "final_publication_date" %>
|
||||
id: "result_publication_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column">
|
||||
<%= check_box_tag :final_version_publication_phase_active, @process.active_phase?(:final_version_publication), @process.new_record? || @process.active_phase?(:final_version_publication), data: {disable_date: "final_publication"} %>
|
||||
<%= label_tag :final_version_publication_phase_active, t('admin.legislation.processes.form.active') %>
|
||||
<%= f.check_box :result_publication_enabled, checked: @process.result_publication.enabled?, label: t('admin.legislation.processes.form.enabled') %>
|
||||
</div>
|
||||
<div class="small-12 column">
|
||||
<hr>
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @process.open_phase?(:allegations) %>
|
||||
<% if @process.allegations_phase.open? %>
|
||||
<a class="button publish-comment" href="#"><strong><%= t('legislation.annotations.comments.publish_comment') %></strong></a>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% if @process.open_phase?(:allegations) %>
|
||||
<% if @process.allegations_phase.open? %>
|
||||
<% if user_signed_in? %>
|
||||
<% css_id = parent_or_commentable_dom_id(nil, annotation) %>
|
||||
<div id="js-comment-form-annotation-<%= annotation.id %>" style="display:none" class="comment-form js-comment-form-annotation">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<div class="comments-wrapper">
|
||||
<div class="comment-input">
|
||||
<% if !@process.open_phase?(:allegations) %>
|
||||
<% if !@process.allegations_phase.open? %>
|
||||
<div data-alert class="callout primary">
|
||||
<%= t("legislation.annotations.form.phase_not_open") %>
|
||||
</div>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<section class="legislation-annotatable"
|
||||
data-legislation-draft-version-id="<%= @draft_version.id %>"
|
||||
data-legislation-annotatable-base-url="<%= legislation_process_draft_version_path(@process, @draft_version) %>"
|
||||
data-legislation-open-phase="<%= @process.open_phase?(:allegations) %>"
|
||||
data-legislation-open-phase="<%= @process.allegations_phase.open? %>"
|
||||
>
|
||||
<% end %>
|
||||
<%= @draft_version.body_html.html_safe %>
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<% if process.active_phase?(:debate) %>
|
||||
<li <%= "class=active" if phase == :debate %>>
|
||||
<% if process.debate_phase.enabled? %>
|
||||
<li <%= "class=active" if phase == :debate_phase %>>
|
||||
<%= link_to legislation_process_debate_path(process) do %>
|
||||
<h4><%= t('legislation.processes.shared.debate_dates') %></h4>
|
||||
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
||||
@@ -16,7 +16,7 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if process.active_phase?(:draft_publication) %>
|
||||
<% if process.draft_publication.enabled? %>
|
||||
<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>
|
||||
@@ -25,8 +25,8 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if process.active_phase?(:allegations) %>
|
||||
<li <%= "class=active" if phase == :allegations %>>
|
||||
<% if process.allegations_phase.enabled? %>
|
||||
<li <%= "class=active" if phase == :allegations_phase %>>
|
||||
<%= 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>
|
||||
@@ -34,11 +34,11 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if process.active_phase?(:final_version_publication) %>
|
||||
<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>
|
||||
<% if process.result_publication.enabled? %>
|
||||
<li <%= "class=active" if phase == :result_publication %>>
|
||||
<%= link_to legislation_process_result_publication_path(process) do %>
|
||||
<h4><%= t('legislation.processes.shared.result_publication_date') %></h4>
|
||||
<p><%= format_date(process.result_publication_date) %></p>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
@@ -17,28 +17,42 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column row">
|
||||
<div class="small-12 column legislation-calendar-info">
|
||||
<p><%= t('legislation.processes.shared.key_dates') %></p>
|
||||
<% if process.enabled_phases_and_publications_count.positive? %>
|
||||
<% column_width = 12 / process.enabled_phases_and_publications_count %>
|
||||
<div class="column row">
|
||||
<div class="small-12 column legislation-calendar-info">
|
||||
<p><%= t('legislation.processes.shared.key_dates') %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column row small-collapse medium-uncollapse legislation-calendar">
|
||||
<div class="small-6 medium-3 column">
|
||||
<h5><%= t('legislation.processes.shared.debate_dates') %></h5>
|
||||
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
||||
<div class="column row small-collapse medium-uncollapse legislation-calendar">
|
||||
<% if process.debate_phase.enabled? %>
|
||||
<div class="small-6 medium-<%= column_width %> column">
|
||||
<h5><%= t('legislation.processes.shared.debate_dates') %></h5>
|
||||
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if process.draft_publication.enabled? %>
|
||||
<div class="small-6 medium-<%= column_width %> column">
|
||||
<h5><%= t('legislation.processes.shared.draft_publication_date') %></h5>
|
||||
<p><%= format_date(process.draft_publication_date) %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if process.allegations_phase.enabled? %>
|
||||
<div class="small-6 medium-<%= column_width %> column">
|
||||
<h5><%= t('legislation.processes.shared.allegations_dates') %></h5>
|
||||
<p><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if process.result_publication.enabled? %>
|
||||
<div class="small-6 medium-<%= column_width %> column">
|
||||
<h5><%= t('legislation.processes.shared.result_publication_date') %></h5>
|
||||
<p><%= format_date(process.result_publication_date) %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="small-6 medium-3 column">
|
||||
<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.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.shared.final_publication_date') %></h5>
|
||||
<p><%= format_date(process.final_publication_date) %></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if question.question_options.any? %>
|
||||
<% if process.open_phase?(:debate) && !answer.persisted? %>
|
||||
<% if process.debate_phase.open? && !answer.persisted? %>
|
||||
|
||||
<%= form_for answer, url: legislation_process_question_answers_path(process, question, answer), remote: true , html: { class: "controls-stacked"} do |f| %>
|
||||
<% question.question_options.each do |question_option| %>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
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) %>
|
||||
<% elsif !@process.debate_phase.open? %>
|
||||
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
|
||||
<%= t("legislation.questions.participation.debate_phase_not_open") %>
|
||||
</div>
|
||||
|
||||
@@ -71,10 +71,10 @@
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<label for="legislation_process_final_publication_date">Publicación de resultados</label>
|
||||
<label for="legislation_process_result_publication_date">Publicación de resultados</label>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column end">
|
||||
<input class="js-calendar-full" id="final_publication_date" type="text" value="2016-12-30" name="legislation_process[final_publication_date]" />
|
||||
<input class="js-calendar-full" id="result_publication_date" type="text" value="2016-12-30" name="legislation_process[result_publication_date]" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ en:
|
||||
draft_publication_date: Draft publication date
|
||||
allegations_start_date: Allegations start date
|
||||
allegations_end_date: Allegations end date
|
||||
final_publication_date: Final result publication date
|
||||
result_publication_date: Final result publication date
|
||||
legislation/draft_version:
|
||||
title: Version title
|
||||
body: Text
|
||||
|
||||
@@ -171,7 +171,7 @@ es:
|
||||
draft_publication_date: Fecha de publicación del borrador
|
||||
allegations_start_date: Fecha de inicio de alegaciones
|
||||
allegations_end_date: Fecha de fin de alegaciones
|
||||
final_publication_date: Fecha de publicación del resultado final
|
||||
result_publication_date: Fecha de publicación del resultado final
|
||||
legislation/draft_version:
|
||||
title: Título de la version
|
||||
body: Texto
|
||||
|
||||
@@ -211,7 +211,7 @@ en:
|
||||
form:
|
||||
error: Error
|
||||
form:
|
||||
active: Active
|
||||
enabled: Enabled
|
||||
process: Process
|
||||
debate_phase: Debate phase
|
||||
allegations_phase: Allegations phase
|
||||
|
||||
@@ -211,7 +211,7 @@ es:
|
||||
form:
|
||||
error: Error
|
||||
form:
|
||||
active: Activa
|
||||
enabled: Habilitado
|
||||
process: Proceso
|
||||
debate_phase: Fase previa
|
||||
allegations_phase: Fase de alegaciones
|
||||
|
||||
@@ -76,7 +76,7 @@ en:
|
||||
debate_dates: Debate
|
||||
draft_publication_date: Draft publication
|
||||
allegations_dates: Allegations
|
||||
final_publication_date: Final result publication
|
||||
result_publication_date: Final result publication
|
||||
questions:
|
||||
comments:
|
||||
comment_button: Publish answer
|
||||
|
||||
@@ -76,7 +76,7 @@ es:
|
||||
debate_dates: Debate previo
|
||||
draft_publication_date: Publicación borrador
|
||||
allegations_dates: Alegaciones
|
||||
final_publication_date: Publicación resultados
|
||||
result_publication_date: Publicación resultados
|
||||
questions:
|
||||
comments:
|
||||
comment_button: Publicar respuesta
|
||||
|
||||
@@ -112,7 +112,7 @@ Rails.application.routes.draw do
|
||||
get :debate
|
||||
get :draft_publication
|
||||
get :allegations
|
||||
get :final_version_publication
|
||||
get :result_publication
|
||||
resources :questions, only: [:show] do
|
||||
resources :answers, only: [:create]
|
||||
end
|
||||
|
||||
178
db/dev_seeds.rb
178
db/dev_seeds.rb
@@ -89,7 +89,7 @@ poll_officer = create_user('poll_officer@consul.dev', 'Paul O. Fisher')
|
||||
poll_officer.create_poll_officer
|
||||
|
||||
level_2 = create_user('leveltwo@consul.dev', 'level 2')
|
||||
level_2.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_number: "2222222222", document_type: "1" )
|
||||
level_2.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_number: "2222222222", document_type: "1")
|
||||
|
||||
verified = create_user('verified@consul.dev', 'verified')
|
||||
verified.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")
|
||||
@@ -101,7 +101,7 @@ verified.update(residence_verified_at: Time.current, confirmed_phone: Faker::Pho
|
||||
org = org_user.create_organization(name: org_name, responsible_name: org_responsible_name)
|
||||
|
||||
verified = [true, false].sample
|
||||
if verified then
|
||||
if verified
|
||||
org.verify
|
||||
else
|
||||
org.reject
|
||||
@@ -120,7 +120,7 @@ end
|
||||
user.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_number: Faker::Number.number(10), document_type: "1", geozone: Geozone.reorder("RANDOM()").first)
|
||||
end
|
||||
if level == 3
|
||||
user.update(verified_at: Time.current, document_number: Faker::Number.number(10) )
|
||||
user.update(verified_at: Time.current, document_number: Faker::Number.number(10))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -141,7 +141,7 @@ ActsAsTaggableOn::Tag.create!(name: "Sostenibilidad", featured: true, kind: "ca
|
||||
ActsAsTaggableOn::Tag.create!(name: "Participación", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Movilidad", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Medios", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Salud", featured: true , kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Salud", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Transparencia", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Seguridad y Emergencias", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Medio Ambiente", featured: true, kind: "category")
|
||||
@@ -150,38 +150,36 @@ puts " ✅"
|
||||
print "Creating Debates"
|
||||
|
||||
tags = Faker::Lorem.words(25)
|
||||
(1..30).each do
|
||||
30.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
debate = Debate.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
created_at: rand((Time.current - 1.week) .. Time.current),
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
description: description,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1")
|
||||
end
|
||||
|
||||
|
||||
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||
(1..30).each do
|
||||
30.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
debate = Debate.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
created_at: rand((Time.current - 1.week) .. Time.current),
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
description: description,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1")
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Creating Proposals"
|
||||
|
||||
tags = Faker::Lorem.words(25)
|
||||
(1..30).each do |i|
|
||||
30.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
proposal = Proposal.create!(author: author,
|
||||
@@ -191,7 +189,7 @@ tags = Faker::Lorem.words(25)
|
||||
responsible_name: Faker::Name.name,
|
||||
external_url: Faker::Internet.url,
|
||||
description: description,
|
||||
created_at: rand((Time.current - 1.week) .. Time.current),
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1")
|
||||
@@ -201,7 +199,7 @@ puts " ✅"
|
||||
print "Creating Archived Proposals"
|
||||
|
||||
tags = Faker::Lorem.words(25)
|
||||
(1..5).each do
|
||||
5.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
proposal = Proposal.create!(author: author,
|
||||
@@ -221,7 +219,7 @@ puts " ✅"
|
||||
print "Creating Successful Proposals"
|
||||
|
||||
tags = Faker::Lorem.words(25)
|
||||
(1..10).each do |i|
|
||||
10.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
proposal = Proposal.create!(author: author,
|
||||
@@ -231,16 +229,15 @@ tags = Faker::Lorem.words(25)
|
||||
responsible_name: Faker::Name.name,
|
||||
external_url: Faker::Internet.url,
|
||||
description: description,
|
||||
created_at: rand((Time.current - 1.week) .. Time.current),
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1",
|
||||
cached_votes_up: Setting["votes_for_proposal_success"])
|
||||
end
|
||||
|
||||
|
||||
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||
(1..30).each do
|
||||
30.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
proposal = Proposal.create!(author: author,
|
||||
@@ -250,94 +247,89 @@ tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||
responsible_name: Faker::Name.name,
|
||||
external_url: Faker::Internet.url,
|
||||
description: description,
|
||||
created_at: rand((Time.current - 1.week) .. Time.current),
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
tag_list: tags.sample(3).join(','),
|
||||
geozone: Geozone.reorder("RANDOM()").first,
|
||||
terms_of_service: "1")
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Commenting Debates"
|
||||
|
||||
(1..100).each do
|
||||
100.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
debate = Debate.reorder("RANDOM()").first
|
||||
Comment.create!(user: author,
|
||||
created_at: rand(debate.created_at .. Time.current),
|
||||
created_at: rand(debate.created_at..Time.current),
|
||||
commentable: debate,
|
||||
body: Faker::Lorem.sentence)
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Commenting Proposals"
|
||||
|
||||
(1..100).each do |i|
|
||||
100.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
proposal = Proposal.reorder("RANDOM()").first
|
||||
Comment.create!(user: author,
|
||||
created_at: rand(proposal.created_at .. Time.current),
|
||||
created_at: rand(proposal.created_at..Time.current),
|
||||
commentable: proposal,
|
||||
body: Faker::Lorem.sentence)
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Commenting Comments"
|
||||
|
||||
(1..200).each do
|
||||
200.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
parent = Comment.reorder("RANDOM()").first
|
||||
Comment.create!(user: author,
|
||||
created_at: rand(parent.created_at .. Time.current),
|
||||
created_at: rand(parent.created_at..Time.current),
|
||||
commentable_id: parent.commentable_id,
|
||||
commentable_type: parent.commentable_type,
|
||||
body: Faker::Lorem.sentence,
|
||||
parent: parent)
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Voting Debates, Proposals & Comments"
|
||||
|
||||
(1..100).each do
|
||||
100.times do
|
||||
voter = not_org_users.level_two_or_three_verified.reorder("RANDOM()").first
|
||||
vote = [true, false].sample
|
||||
debate = Debate.reorder("RANDOM()").first
|
||||
debate.vote_by(voter: voter, vote: vote)
|
||||
end
|
||||
|
||||
(1..100).each do |i|
|
||||
100.times do
|
||||
voter = not_org_users.reorder("RANDOM()").first
|
||||
vote = [true, false].sample
|
||||
comment = Comment.reorder("RANDOM()").first
|
||||
comment.vote_by(voter: voter, vote: vote)
|
||||
end
|
||||
|
||||
(1..100).each do
|
||||
100.times do
|
||||
voter = not_org_users.level_two_or_three_verified.reorder("RANDOM()").first
|
||||
proposal = Proposal.reorder("RANDOM()").first
|
||||
proposal.vote_by(voter: voter, vote: true)
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Flagging Debates & Comments"
|
||||
|
||||
(1..40).each do
|
||||
40.times do
|
||||
debate = Debate.reorder("RANDOM()").first
|
||||
flagger = User.where(["users.id <> ?", debate.author_id]).reorder("RANDOM()").first
|
||||
Flag.flag(flagger, debate)
|
||||
end
|
||||
|
||||
(1..40).each do
|
||||
40.times do
|
||||
comment = Comment.reorder("RANDOM()").first
|
||||
flagger = User.where(["users.id <> ?", comment.user_id]).reorder("RANDOM()").first
|
||||
Flag.flag(flagger, comment)
|
||||
end
|
||||
|
||||
(1..40).each do
|
||||
40.times do
|
||||
proposal = Proposal.reorder("RANDOM()").first
|
||||
flagger = User.where(["users.id <> ?", proposal.author_id]).reorder("RANDOM()").first
|
||||
Flag.flag(flagger, proposal)
|
||||
@@ -348,7 +340,7 @@ print "Creating Spending Proposals"
|
||||
|
||||
tags = Faker::Lorem.words(10)
|
||||
|
||||
(1..60).each do
|
||||
60.times do
|
||||
geozone = Geozone.reorder("RANDOM()").first
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
@@ -356,17 +348,17 @@ tags = Faker::Lorem.words(10)
|
||||
valuation_finished = [true, false].sample
|
||||
feasible = [true, false].sample
|
||||
spending_proposal = SpendingProposal.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
external_url: Faker::Internet.url,
|
||||
description: description,
|
||||
created_at: rand((Time.current - 1.week) .. Time.current),
|
||||
geozone: [geozone, nil].sample,
|
||||
feasible: feasible,
|
||||
feasible_explanation: feasible_explanation,
|
||||
valuation_finished: valuation_finished,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
price: rand(1000000),
|
||||
terms_of_service: "1")
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
external_url: Faker::Internet.url,
|
||||
description: description,
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
geozone: [geozone, nil].sample,
|
||||
feasible: feasible,
|
||||
feasible_explanation: feasible_explanation,
|
||||
valuation_finished: valuation_finished,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
price: rand(1000000),
|
||||
terms_of_service: "1")
|
||||
end
|
||||
|
||||
puts " ✅"
|
||||
@@ -376,13 +368,14 @@ print "Creating Valuation Assignments"
|
||||
SpendingProposal.reorder("RANDOM()").first.valuators << valuator.valuator
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Creating Budgets"
|
||||
|
||||
Budget::PHASES.each_with_index do |phase, i|
|
||||
descriptions = Hash[Budget::PHASES.map{ |p| ["description_#{p}",
|
||||
"<p>#{Faker::Lorem.paragraphs(2).join('</p><p>')}</p>"] }]
|
||||
descriptions = Hash[Budget::PHASES.map do |p|
|
||||
["description_#{p}",
|
||||
"<p>#{Faker::Lorem.paragraphs(2).join('</p><p>')}</p>"]
|
||||
end]
|
||||
budget = Budget.create!(
|
||||
descriptions.merge(
|
||||
name: (Date.current - 10 + i).to_s,
|
||||
@@ -397,18 +390,15 @@ Budget::PHASES.each_with_index do |phase, i|
|
||||
geozones = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample)
|
||||
geozones.each do |geozone|
|
||||
group.headings << group.headings.create!(name: geozone.name,
|
||||
#geozone: geozone,
|
||||
price: rand(1 .. 100) * 100000)
|
||||
|
||||
price: rand(1..100) * 100000)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Creating Investments"
|
||||
tags = Faker::Lorem.words(10)
|
||||
(1..100).each do |i|
|
||||
100.times do
|
||||
heading = Budget::Heading.reorder("RANDOM()").first
|
||||
|
||||
investment = Budget::Investment.create!(
|
||||
@@ -419,13 +409,14 @@ tags = Faker::Lorem.words(10)
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
external_url: Faker::Internet.url,
|
||||
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
|
||||
created_at: rand((Time.current - 1.week) .. Time.current),
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
feasibility: %w{undecided unfeasible feasible feasible feasible feasible}.sample,
|
||||
unfeasibility_explanation: Faker::Lorem.paragraph,
|
||||
valuation_finished: [false, true].sample,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
price: rand(1 .. 100) * 100000,
|
||||
terms_of_service: "1")
|
||||
price: rand(1..100) * 100000,
|
||||
terms_of_service: "1"
|
||||
)
|
||||
end
|
||||
|
||||
puts " ✅"
|
||||
@@ -438,7 +429,7 @@ puts " ✅"
|
||||
print "Winner Investments"
|
||||
|
||||
budget = Budget.where(phase: "finished").last
|
||||
(1..100).each do |i|
|
||||
100.times do
|
||||
heading = budget.headings.reorder("RANDOM()").first
|
||||
investment = Budget::Investment.create!(
|
||||
author: User.reorder("RANDOM()").first,
|
||||
@@ -448,12 +439,13 @@ budget = Budget.where(phase: "finished").last
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
external_url: Faker::Internet.url,
|
||||
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
|
||||
created_at: rand((Time.current - 1.week) .. Time.current),
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
feasibility: "feasible",
|
||||
valuation_finished: true,
|
||||
selected: true,
|
||||
price: rand(10000 .. heading.price),
|
||||
terms_of_service: "1")
|
||||
price: rand(10000..heading.price),
|
||||
terms_of_service: "1"
|
||||
)
|
||||
end
|
||||
budget.headings.each do |heading|
|
||||
Budget::Result.new(budget, heading).calculate_winners
|
||||
@@ -466,16 +458,13 @@ print "Creating Valuation Assignments"
|
||||
Budget::Investment.reorder("RANDOM()").first.valuators << valuator.valuator
|
||||
end
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Ignoring flags in Debates, comments & proposals"
|
||||
|
||||
|
||||
Debate.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag)
|
||||
Comment.flagged.reorder("RANDOM()").limit(30).each(&:ignore_flag)
|
||||
Proposal.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag)
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Hiding debates, comments & proposals"
|
||||
|
||||
@@ -483,7 +472,6 @@ Comment.with_hidden.flagged.reorder("RANDOM()").limit(30).each(&:hide)
|
||||
Debate.with_hidden.flagged.reorder("RANDOM()").limit(5).each(&:hide)
|
||||
Proposal.with_hidden.flagged.reorder("RANDOM()").limit(10).each(&:hide)
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Confirming hiding in debates, comments & proposals"
|
||||
|
||||
@@ -504,9 +492,9 @@ Proposal.last(3).each do |proposal|
|
||||
image: ["banner-img banner-img-one", "banner-img banner-img-two",
|
||||
"banner-img banner-img-three"].sample,
|
||||
target_url: Rails.application.routes.url_helpers.proposal_path(proposal),
|
||||
post_started_at: rand((Time.current - 1.week) .. (Time.current - 1.day)),
|
||||
post_ended_at: rand((Time.current - 1.day) .. (Time.current + 1.week)),
|
||||
created_at: rand((Time.current - 1.week) .. Time.current))
|
||||
post_started_at: rand((Time.current - 1.week)..(Time.current - 1.day)),
|
||||
post_ended_at: rand((Time.current - 1.day)..(Time.current + 1.week)),
|
||||
created_at: rand((Time.current - 1.week)..Time.current))
|
||||
end
|
||||
|
||||
puts " ✅"
|
||||
@@ -530,19 +518,14 @@ print "Active Polls"
|
||||
ends_at: 1.month.from_now,
|
||||
geozone_restricted: false)
|
||||
end
|
||||
(4..5).each do |i|
|
||||
(1..5).each do |i|
|
||||
poll = Poll.create(name: "Active Poll #{i}",
|
||||
starts_at: 1.month.ago,
|
||||
ends_at: 1.month.from_now,
|
||||
geozone_restricted: true,
|
||||
geozones: Geozone.reorder("RANDOM()").limit(3)
|
||||
)
|
||||
geozones: Geozone.reorder("RANDOM()").limit(3))
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
puts " ✅"
|
||||
print "Upcoming Poll"
|
||||
poll = Poll.create(name: "Upcoming Poll",
|
||||
@@ -552,17 +535,17 @@ poll = Poll.create(name: "Upcoming Poll",
|
||||
puts " ✅"
|
||||
print "Expired Poll"
|
||||
poll = Poll.create(name: "Expired Poll",
|
||||
starts_at: 2.months.ago,
|
||||
ends_at: 1.months.ago)
|
||||
starts_at: 2.months.ago,
|
||||
ends_at: 1.month.ago)
|
||||
|
||||
puts " ✅"
|
||||
print "Creating Poll Questions"
|
||||
|
||||
(1..50).each do |i|
|
||||
50.times do
|
||||
poll = Poll.reorder("RANDOM()").first
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
open_at = rand(2.months.ago .. 2.months.from_now)
|
||||
open_at = rand(2.months.ago..2.months.from_now)
|
||||
question = Poll::Question.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
description: description,
|
||||
@@ -594,21 +577,21 @@ end
|
||||
|
||||
puts " ✅"
|
||||
print "Creating Poll Recounts" do
|
||||
(1..15).to_a.sample.times do |i|
|
||||
poll_officer.poll_officer.officer_assignments.all.sample(i).each do |officer_assignment|
|
||||
Poll::Recount.create(officer_assignment: officer_assignment,
|
||||
booth_assignment: officer_assignment.booth_assignment,
|
||||
date: officer_assignment.date,
|
||||
count: (1..5000).to_a.sample)
|
||||
(1..15).to_a.sample.times do |i|
|
||||
poll_officer.poll_officer.officer_assignments.all.sample(i).each do |officer_assignment|
|
||||
Poll::Recount.create(officer_assignment: officer_assignment,
|
||||
booth_assignment: officer_assignment.booth_assignment,
|
||||
date: officer_assignment.date,
|
||||
count: (1..5000).to_a.sample)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
puts " ✅"
|
||||
print "Creating Poll Questions from Proposals"
|
||||
|
||||
(1..3).each do
|
||||
3.times do
|
||||
proposal = Proposal.reorder("RANDOM()").first
|
||||
poll = Poll.current.first
|
||||
question = Poll::Question.create(valid_answers: "Yes, No")
|
||||
@@ -619,7 +602,7 @@ end
|
||||
puts " ✅"
|
||||
print "Creating Successful Proposals"
|
||||
|
||||
(1..10).each do
|
||||
10.times do
|
||||
proposal = Proposal.reorder("RANDOM()").first
|
||||
poll = Poll.current.first
|
||||
question = Poll::Question.create(valid_answers: "Yes, No")
|
||||
@@ -630,11 +613,11 @@ end
|
||||
puts " ✅"
|
||||
print "Commenting Poll Questions"
|
||||
|
||||
(1..30).each do
|
||||
30.times do
|
||||
author = User.reorder("RANDOM()").first
|
||||
question = Poll::Question.reorder("RANDOM()").first
|
||||
Comment.create!(user: author,
|
||||
created_at: rand(question.created_at .. Time.current),
|
||||
created_at: rand(question.created_at..Time.current),
|
||||
commentable: question,
|
||||
body: Faker::Lorem.sentence)
|
||||
end
|
||||
@@ -642,7 +625,7 @@ end
|
||||
puts " ✅"
|
||||
print "Creating Poll Voters"
|
||||
|
||||
(1..10).each do
|
||||
10.times do
|
||||
poll = Poll.all.sample
|
||||
user = User.level_two_verified.sample
|
||||
Poll::Voter.create(poll: poll, user: user)
|
||||
@@ -651,7 +634,7 @@ end
|
||||
puts " ✅"
|
||||
print "Creating legislation processes"
|
||||
|
||||
(1..5).each do |i|
|
||||
5.times do
|
||||
process = ::Legislation::Process.create!(title: Faker::Lorem.sentence(3).truncate(60),
|
||||
description: Faker::Lorem.paragraphs.join("\n\n"),
|
||||
summary: Faker::Lorem.paragraph,
|
||||
@@ -663,15 +646,18 @@ print "Creating legislation processes"
|
||||
draft_publication_date: Date.current + 1.day,
|
||||
allegations_start_date: Date.current + 2.days,
|
||||
allegations_end_date: Date.current + 3.days,
|
||||
final_publication_date: Date.current + 4.days
|
||||
result_publication_date: Date.current + 4.days,
|
||||
debate_phase_enabled: true,
|
||||
allegations_phase_enabled: true,
|
||||
draft_publication_enabled: true,
|
||||
result_publication_enabled: true
|
||||
)
|
||||
end
|
||||
|
||||
::Legislation::Process.all.each do |process|
|
||||
(1..3).each do |i|
|
||||
version = process.draft_versions.create!(title: "Version #{i}",
|
||||
body: Faker::Lorem.paragraphs.join("\n\n")
|
||||
)
|
||||
body: Faker::Lorem.paragraphs.join("\n\n"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class RenameLegislationProcessFinalPubToResultPub < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :legislation_processes, :final_publication_date, :result_publication_date
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
class AddPhasePubEnabledStatusToLegislativeProcess < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :legislation_processes, :debate_phase_enabled, :boolean, default: false
|
||||
add_column :legislation_processes, :allegations_phase_enabled, :boolean, default: false
|
||||
add_column :legislation_processes, :draft_publication_enabled, :boolean, default: false
|
||||
add_column :legislation_processes, :result_publication_enabled, :boolean, default: false
|
||||
end
|
||||
end
|
||||
10
db/schema.rb
10
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170610211027) do
|
||||
ActiveRecord::Schema.define(version: 20170613203256) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -411,11 +411,15 @@ ActiveRecord::Schema.define(version: 20170610211027) do
|
||||
t.date "draft_publication_date"
|
||||
t.date "allegations_start_date"
|
||||
t.date "allegations_end_date"
|
||||
t.date "final_publication_date"
|
||||
t.date "result_publication_date"
|
||||
t.datetime "hidden_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.text "summary"
|
||||
t.boolean "debate_phase_enabled", default: false
|
||||
t.boolean "allegations_phase_enabled", default: false
|
||||
t.boolean "draft_publication_enabled", default: false
|
||||
t.boolean "result_publication_enabled", default: false
|
||||
end
|
||||
|
||||
add_index "legislation_processes", ["allegations_end_date"], name: "index_legislation_processes_on_allegations_end_date", using: :btree
|
||||
@@ -424,8 +428,8 @@ ActiveRecord::Schema.define(version: 20170610211027) do
|
||||
add_index "legislation_processes", ["debate_start_date"], name: "index_legislation_processes_on_debate_start_date", using: :btree
|
||||
add_index "legislation_processes", ["draft_publication_date"], name: "index_legislation_processes_on_draft_publication_date", using: :btree
|
||||
add_index "legislation_processes", ["end_date"], name: "index_legislation_processes_on_end_date", using: :btree
|
||||
add_index "legislation_processes", ["final_publication_date"], name: "index_legislation_processes_on_final_publication_date", using: :btree
|
||||
add_index "legislation_processes", ["hidden_at"], name: "index_legislation_processes_on_hidden_at", using: :btree
|
||||
add_index "legislation_processes", ["result_publication_date"], name: "index_legislation_processes_on_result_publication_date", using: :btree
|
||||
add_index "legislation_processes", ["start_date"], name: "index_legislation_processes_on_start_date", using: :btree
|
||||
|
||||
create_table "legislation_question_options", force: :cascade do |t|
|
||||
|
||||
@@ -612,7 +612,11 @@ FactoryGirl.define do
|
||||
draft_publication_date Date.current - 1.day
|
||||
allegations_start_date Date.current
|
||||
allegations_end_date Date.current + 3.days
|
||||
final_publication_date Date.current + 5.days
|
||||
result_publication_date Date.current + 5.days
|
||||
debate_phase_enabled true
|
||||
allegations_phase_enabled true
|
||||
draft_publication_enabled true
|
||||
result_publication_enabled true
|
||||
|
||||
trait :next do
|
||||
start_date Date.current + 2.days
|
||||
@@ -622,7 +626,7 @@ FactoryGirl.define do
|
||||
draft_publication_date Date.current + 5.day
|
||||
allegations_start_date Date.current + 5.days
|
||||
allegations_end_date Date.current + 7.days
|
||||
final_publication_date Date.current + 8.days
|
||||
result_publication_date Date.current + 8.days
|
||||
end
|
||||
|
||||
trait :past do
|
||||
@@ -633,7 +637,7 @@ FactoryGirl.define do
|
||||
draft_publication_date Date.current - 8.day
|
||||
allegations_start_date Date.current - 8.days
|
||||
allegations_end_date Date.current - 4.days
|
||||
final_publication_date Date.current - 2.days
|
||||
result_publication_date Date.current - 2.days
|
||||
end
|
||||
|
||||
trait :in_debate_phase do
|
||||
@@ -644,7 +648,7 @@ FactoryGirl.define do
|
||||
draft_publication_date Date.current + 1.day
|
||||
allegations_start_date Date.current + 2.days
|
||||
allegations_end_date Date.current + 3.days
|
||||
final_publication_date Date.current + 5.days
|
||||
result_publication_date Date.current + 5.days
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ feature 'Admin legislation processes' do
|
||||
fill_in 'legislation_process[draft_publication_date]', with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[allegations_start_date]', with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[allegations_end_date]', with: (base_date + 5.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[final_publication_date]', with: (base_date + 7.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[result_publication_date]', with: (base_date + 7.days).strftime("%d/%m/%Y")
|
||||
|
||||
click_button 'Create process'
|
||||
|
||||
@@ -73,7 +73,7 @@ feature 'Admin legislation processes' do
|
||||
end
|
||||
|
||||
context 'Update' do
|
||||
scenario 'Deactivate debate phase', js: true do
|
||||
scenario 'Remove summary text', js: true do
|
||||
process = create(:legislation_process,
|
||||
title: 'An example legislation process',
|
||||
summary: 'Summarizing the process',
|
||||
@@ -87,19 +87,43 @@ feature 'Admin legislation processes' do
|
||||
click_link "An example legislation process"
|
||||
|
||||
expect(page).to have_selector("h2", text: "An example legislation process")
|
||||
expect(find("#debate_phase_active")).to be_checked
|
||||
expect(find("#legislation_process_debate_phase_enabled")).to be_checked
|
||||
|
||||
uncheck "debate_phase_active"
|
||||
fill_in 'legislation_process_summary', with: ''
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Process updated successfully"
|
||||
expect(find("#debate_start_date").value).to be_blank
|
||||
expect(find("#debate_end_date").value).to be_blank
|
||||
|
||||
visit legislation_processes_path
|
||||
expect(page).not_to have_content 'Summarizing the process'
|
||||
expect(page).to have_content 'Description of the process'
|
||||
end
|
||||
|
||||
scenario 'Deactivate draft publication', js: true do
|
||||
process = create(:legislation_process,
|
||||
title: 'An example legislation process',
|
||||
summary: 'Summarizing the process',
|
||||
description: 'Description of the process')
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
click_link "An example legislation process"
|
||||
|
||||
expect(find("#legislation_process_draft_publication_enabled")).to be_checked
|
||||
|
||||
uncheck "legislation_process_draft_publication_enabled"
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Process updated successfully"
|
||||
expect(find("#debate_start_date").value).not_to be_blank
|
||||
expect(find("#debate_end_date").value).not_to be_blank
|
||||
|
||||
click_link 'Click to visit'
|
||||
|
||||
expect(page).not_to have_content 'Draft publication'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -104,17 +104,17 @@ feature 'Legislation' do
|
||||
|
||||
context 'final version publication phase' do
|
||||
scenario 'not open' do
|
||||
process = create(:legislation_process, final_publication_date: Date.current + 1.day)
|
||||
process = create(:legislation_process, result_publication_date: Date.current + 1.day)
|
||||
|
||||
visit legislation_process_final_version_publication_path(process)
|
||||
visit legislation_process_result_publication_path(process)
|
||||
|
||||
expect(page).to have_content("This phase is not open yet")
|
||||
end
|
||||
|
||||
scenario 'open' do
|
||||
process = create(:legislation_process, final_publication_date: Date.current)
|
||||
process = create(:legislation_process, result_publication_date: Date.current)
|
||||
|
||||
visit legislation_process_final_version_publication_path(process)
|
||||
visit legislation_process_result_publication_path(process)
|
||||
|
||||
expect(page).to have_content("Nothing published yet")
|
||||
end
|
||||
|
||||
@@ -65,9 +65,9 @@ describe DirectMessage do
|
||||
|
||||
describe "today" do
|
||||
it "should return direct messages created today" do
|
||||
direct_message1 = create(:direct_message, created_at: Time.current.beginning_of_day + 3.hours)
|
||||
direct_message2 = create(:direct_message, created_at: Time.current)
|
||||
direct_message3 = create(:direct_message, created_at: Time.current.end_of_day)
|
||||
direct_message1 = create(:direct_message, created_at: Time.now.utc.beginning_of_day + 3.hours)
|
||||
direct_message2 = create(:direct_message, created_at: Time.now.utc)
|
||||
direct_message3 = create(:direct_message, created_at: Time.now.utc.end_of_day)
|
||||
|
||||
expect(DirectMessage.today.count).to eq 3
|
||||
end
|
||||
|
||||
99
spec/models/legislation/process/phase_spec.rb
Normal file
99
spec/models/legislation/process/phase_spec.rb
Normal file
@@ -0,0 +1,99 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Legislation::Process::Phase, type: :model do
|
||||
let(:process) { create(:legislation_process) }
|
||||
|
||||
describe "#enabled?" do
|
||||
it "checks debate phase" do
|
||||
expect(process.debate_phase.enabled?).to be true
|
||||
|
||||
process.update_attributes(debate_phase_enabled: false)
|
||||
expect(process.debate_phase.enabled?).to be false
|
||||
end
|
||||
|
||||
it "checks allegations phase" do
|
||||
expect(process.allegations_phase.enabled?).to be true
|
||||
|
||||
process.update_attributes(allegations_phase_enabled: false)
|
||||
expect(process.allegations_phase.enabled?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#started?" do
|
||||
it "checks debate phase" do
|
||||
# future
|
||||
process.update_attributes(debate_start_date: Date.current + 2.days, debate_end_date: Date.current + 3.days)
|
||||
expect(process.debate_phase.started?).to be false
|
||||
|
||||
# started
|
||||
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current + 1.day)
|
||||
expect(process.debate_phase.started?).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(debate_start_date: Date.current, debate_end_date: Date.current + 1.day)
|
||||
expect(process.debate_phase.started?).to be true
|
||||
|
||||
# past
|
||||
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.day)
|
||||
expect(process.debate_phase.started?).to be true
|
||||
end
|
||||
|
||||
it "checks allegations phase" do
|
||||
# future
|
||||
process.update_attributes(allegations_start_date: Date.current + 2.days, allegations_end_date: Date.current + 3.days)
|
||||
expect(process.allegations_phase.started?).to be false
|
||||
|
||||
# started
|
||||
process.update_attributes(allegations_start_date: Date.current - 2.days, allegations_end_date: Date.current + 1.day)
|
||||
expect(process.allegations_phase.started?).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(allegations_start_date: Date.current, allegations_end_date: Date.current + 1.day)
|
||||
expect(process.allegations_phase.started?).to be true
|
||||
|
||||
# past
|
||||
process.update_attributes(allegations_start_date: Date.current - 2.days, allegations_end_date: Date.current - 1.day)
|
||||
expect(process.allegations_phase.started?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#open?" do
|
||||
it "checks debate phase" do
|
||||
# future
|
||||
process.update_attributes(debate_start_date: Date.current + 2.days, debate_end_date: Date.current + 3.days)
|
||||
expect(process.debate_phase.open?).to be false
|
||||
|
||||
# started
|
||||
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current + 1.day)
|
||||
expect(process.debate_phase.open?).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(debate_start_date: Date.current, debate_end_date: Date.current + 1.day)
|
||||
expect(process.debate_phase.open?).to be true
|
||||
|
||||
# past
|
||||
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.day)
|
||||
expect(process.debate_phase.open?).to be false
|
||||
end
|
||||
|
||||
it "checks allegations phase" do
|
||||
|
||||
# future
|
||||
process.update_attributes(allegations_start_date: Date.current + 2.days, allegations_end_date: Date.current + 3.days)
|
||||
expect(process.allegations_phase.open?).to be false
|
||||
|
||||
# started
|
||||
process.update_attributes(allegations_start_date: Date.current - 2.days, allegations_end_date: Date.current + 1.day)
|
||||
expect(process.allegations_phase.open?).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(allegations_start_date: Date.current, allegations_end_date: Date.current + 1.day)
|
||||
expect(process.allegations_phase.open?).to be true
|
||||
|
||||
# past
|
||||
process.update_attributes(allegations_start_date: Date.current - 2.days, allegations_end_date: Date.current - 1.day)
|
||||
expect(process.allegations_phase.open?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
81
spec/models/legislation/process/publication_spec.rb
Normal file
81
spec/models/legislation/process/publication_spec.rb
Normal file
@@ -0,0 +1,81 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Legislation::Process::Publication, type: :model do
|
||||
let(:process) { create(:legislation_process) }
|
||||
|
||||
describe "#enabled?" do
|
||||
it "checks draft publication" do
|
||||
expect(process.draft_publication.enabled?).to be true
|
||||
|
||||
process.update_attributes(draft_publication_enabled: false)
|
||||
expect(process.draft_publication.enabled?).to be false
|
||||
end
|
||||
|
||||
it "checks result publication" do
|
||||
expect(process.result_publication.enabled?).to be true
|
||||
|
||||
process.update_attributes(result_publication_enabled: false)
|
||||
expect(process.result_publication.enabled?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#started?" do
|
||||
it "checks draft publication" do
|
||||
# future
|
||||
process.update_attributes(draft_publication_date: Date.current + 2.days)
|
||||
expect(process.draft_publication.started?).to be false
|
||||
|
||||
# past
|
||||
process.update_attributes(draft_publication_date: Date.current - 2.days)
|
||||
expect(process.draft_publication.started?).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(draft_publication_date: Date.current)
|
||||
expect(process.draft_publication.started?).to be true
|
||||
end
|
||||
|
||||
it "checks result publication" do
|
||||
# future
|
||||
process.update_attributes(result_publication_date: Date.current + 2.days)
|
||||
expect(process.result_publication.started?).to be false
|
||||
|
||||
# past
|
||||
process.update_attributes(result_publication_date: Date.current - 2.days)
|
||||
expect(process.result_publication.started?).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(result_publication_date: Date.current)
|
||||
expect(process.result_publication.started?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#open?" do
|
||||
it "checks draft publication" do
|
||||
# future
|
||||
process.update_attributes(draft_publication_date: Date.current + 2.days)
|
||||
expect(process.draft_publication.open?).to be false
|
||||
|
||||
# past
|
||||
process.update_attributes(draft_publication_date: Date.current - 2.days)
|
||||
expect(process.draft_publication.open?).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(draft_publication_date: Date.current)
|
||||
expect(process.draft_publication.open?).to be true
|
||||
end
|
||||
|
||||
it "checks result publication" do
|
||||
# future
|
||||
process.update_attributes(result_publication_date: Date.current + 2.days)
|
||||
expect(process.result_publication.open?).to be false
|
||||
|
||||
# past
|
||||
process.update_attributes(result_publication_date: Date.current - 2.days)
|
||||
expect(process.result_publication.open?).to be true
|
||||
|
||||
# starts today
|
||||
process.update_attributes(result_publication_date: Date.current)
|
||||
expect(process.result_publication.open?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -100,139 +100,6 @@ RSpec.describe Legislation::Process, type: :model do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#open_phase?" do
|
||||
it "checks debate phase" do
|
||||
# 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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
|
||||
describe "#status" do
|
||||
it "should detect planned phase" do
|
||||
process.update_attributes(start_date: Date.current + 2.days)
|
||||
|
||||
Reference in New Issue
Block a user