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,
|
:draft_publication_date,
|
||||||
:allegations_start_date,
|
:allegations_start_date,
|
||||||
:allegations_end_date,
|
:allegations_end_date,
|
||||||
:final_publication_date
|
:result_publication_date,
|
||||||
|
:debate_phase_enabled,
|
||||||
|
:allegations_phase_enabled,
|
||||||
|
:draft_publication_enabled,
|
||||||
|
:result_publication_enabled
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Legislation::AnnotationsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
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
|
render json: {}, status: :not_found and return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Legislation::AnswersController < Legislation::BaseController
|
|||||||
respond_to :html, :js
|
respond_to :html, :js
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if @process.open_phase?(:debate)
|
if @process.debate_phase.open?
|
||||||
@answer.user = current_user
|
@answer.user = current_user
|
||||||
@answer.save
|
@answer.save
|
||||||
track_event
|
track_event
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
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)
|
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)
|
redirect_to legislation_process_debate_path(@process)
|
||||||
else
|
else
|
||||||
redirect_to legislation_process_allegations_path(@process)
|
redirect_to legislation_process_allegations_path(@process)
|
||||||
@@ -18,9 +18,10 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def debate
|
def debate
|
||||||
phase :debate
|
set_process
|
||||||
|
@phase = :debate_phase
|
||||||
|
|
||||||
if @process.show_phase?(:debate)
|
if @process.debate_phase.started?
|
||||||
render :debate
|
render :debate
|
||||||
else
|
else
|
||||||
render :phase_not_open
|
render :phase_not_open
|
||||||
@@ -28,9 +29,10 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def draft_publication
|
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
|
if draft_version = @process.draft_versions.published.last
|
||||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||||
else
|
else
|
||||||
@@ -42,9 +44,10 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def allegations
|
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
|
if draft_version = @process.draft_versions.published.last
|
||||||
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
redirect_to legislation_process_draft_version_path(@process, draft_version)
|
||||||
else
|
else
|
||||||
@@ -55,10 +58,11 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def final_version_publication
|
def result_publication
|
||||||
phase :final_version_publication
|
set_process
|
||||||
|
@phase = :result_publication
|
||||||
|
|
||||||
if @process.show_phase?(@phase)
|
if @process.result_publication.started?
|
||||||
if final_version = @process.final_draft_version
|
if final_version = @process.final_draft_version
|
||||||
redirect_to legislation_process_draft_version_path(@process, final_version)
|
redirect_to legislation_process_draft_version_path(@process, final_version)
|
||||||
else
|
else
|
||||||
@@ -71,8 +75,7 @@ class Legislation::ProcessesController < Legislation::BaseController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def phase(phase)
|
def set_process
|
||||||
@process = ::Legislation::Process.find(params[:process_id])
|
@process = ::Legislation::Process.find(params[:process_id])
|
||||||
@phase = phase
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module Abilities
|
|||||||
can [:read, :print], Budget::Investment
|
can [:read, :print], Budget::Investment
|
||||||
can :read_results, Budget, phase: "finished"
|
can :read_results, Budget, phase: "finished"
|
||||||
can :new, DirectMessage
|
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, :changes, :go_to_version], Legislation::DraftVersion
|
||||||
can [:read], Legislation::Question
|
can [:read], Legislation::Question
|
||||||
can [:create], Legislation::Answer
|
can [:create], Legislation::Answer
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class DirectMessage < ActiveRecord::Base
|
|||||||
validates :receiver, presence: true
|
validates :receiver, presence: true
|
||||||
validate :max_per_day
|
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
|
def max_per_day
|
||||||
return if errors.any?
|
return if errors.any?
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ class Legislation::Process < ActiveRecord::Base
|
|||||||
acts_as_paranoid column: :hidden_at
|
acts_as_paranoid column: :hidden_at
|
||||||
include ActsAsParanoidAliases
|
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_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_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
|
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 :next, -> { where("start_date > ?", Date.current).order('id DESC') }
|
||||||
scope :past, -> { where("end_date < ?", Date.current).order('id DESC') }
|
scope :past, -> { where("end_date < ?", Date.current).order('id DESC') }
|
||||||
|
|
||||||
def open_phase?(phase)
|
def debate_phase
|
||||||
today = Date.current
|
Legislation::Process::Phase.new(debate_start_date, debate_end_date, debate_phase_enabled)
|
||||||
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_phase?(phase)
|
def allegations_phase
|
||||||
# show past phases even if they're finished
|
Legislation::Process::Phase.new(allegations_start_date, allegations_end_date, allegations_phase_enabled)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_phase?(phase)
|
def draft_publication
|
||||||
case phase
|
Legislation::Process::Publication.new(draft_publication_date, draft_publication_enabled)
|
||||||
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
|
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
|
end
|
||||||
|
|
||||||
def total_comments
|
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
|
end
|
||||||
|
|
||||||
def comments_open?
|
def comments_open?
|
||||||
process.open_phase?(:debate)
|
process.debate_phase.open?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -70,8 +70,7 @@
|
|||||||
id: "debate_end_date" %>
|
id: "debate_end_date" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-2 column">
|
<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"} %>
|
<%= f.check_box :debate_phase_enabled, checked: @process.debate_phase.enabled?, label: t('admin.legislation.processes.form.enabled') %>
|
||||||
<%= label_tag :debate_phase_active, t('admin.legislation.processes.form.active') %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
@@ -104,8 +103,7 @@
|
|||||||
id: "allegations_end_date" %>
|
id: "allegations_end_date" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-2 column">
|
<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"} %>
|
<%= f.check_box :allegations_phase_enabled, checked: @process.allegations_phase.enabled?, label: t('admin.legislation.processes.form.enabled') %>
|
||||||
<%= label_tag :allegations_phase_active, t('admin.legislation.processes.form.active') %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
@@ -125,8 +123,7 @@
|
|||||||
id: "draft_publication_date" %>
|
id: "draft_publication_date" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-2 column">
|
<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"} %>
|
<%= f.check_box :draft_publication_enabled, checked: @process.draft_publication.enabled?, label: t('admin.legislation.processes.form.enabled') %>
|
||||||
<%= label_tag :draft_publication_phase_active, t('admin.legislation.processes.form.active') %>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<hr>
|
<hr>
|
||||||
@@ -135,18 +132,17 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 medium-4 column">
|
<div class="small-12 medium-4 column">
|
||||||
<%= f.label :final_publication_date %>
|
<%= f.label :result_publication_date %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-2 column end">
|
<div class="small-12 medium-2 column end">
|
||||||
<%= f.text_field :final_publication_date,
|
<%= f.text_field :result_publication_date,
|
||||||
label: false,
|
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",
|
class: "js-calendar-full",
|
||||||
id: "final_publication_date" %>
|
id: "result_publication_date" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-2 column">
|
<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"} %>
|
<%= f.check_box :result_publication_enabled, checked: @process.result_publication.enabled?, label: t('admin.legislation.processes.form.enabled') %>
|
||||||
<%= label_tag :final_version_publication_phase_active, t('admin.legislation.processes.form.active') %>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<hr>
|
<hr>
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% 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>
|
<a class="button publish-comment" href="#"><strong><%= t('legislation.annotations.comments.publish_comment') %></strong></a>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @process.open_phase?(:allegations) %>
|
<% if @process.allegations_phase.open? %>
|
||||||
<% if user_signed_in? %>
|
<% if user_signed_in? %>
|
||||||
<% css_id = parent_or_commentable_dom_id(nil, annotation) %>
|
<% 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">
|
<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="comments-wrapper">
|
||||||
<div class="comment-input">
|
<div class="comment-input">
|
||||||
<% if !@process.open_phase?(:allegations) %>
|
<% if !@process.allegations_phase.open? %>
|
||||||
<div data-alert class="callout primary">
|
<div data-alert class="callout primary">
|
||||||
<%= t("legislation.annotations.form.phase_not_open") %>
|
<%= t("legislation.annotations.form.phase_not_open") %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<section class="legislation-annotatable"
|
<section class="legislation-annotatable"
|
||||||
data-legislation-draft-version-id="<%= @draft_version.id %>"
|
data-legislation-draft-version-id="<%= @draft_version.id %>"
|
||||||
data-legislation-annotatable-base-url="<%= legislation_process_draft_version_path(@process, @draft_version) %>"
|
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 %>
|
<% end %>
|
||||||
<%= @draft_version.body_html.html_safe %>
|
<%= @draft_version.body_html.html_safe %>
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<% if process.active_phase?(:debate) %>
|
<% if process.debate_phase.enabled? %>
|
||||||
<li <%= "class=active" if phase == :debate %>>
|
<li <%= "class=active" if phase == :debate_phase %>>
|
||||||
<%= link_to legislation_process_debate_path(process) do %>
|
<%= link_to legislation_process_debate_path(process) do %>
|
||||||
<h4><%= t('legislation.processes.shared.debate_dates') %></h4>
|
<h4><%= t('legislation.processes.shared.debate_dates') %></h4>
|
||||||
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if process.active_phase?(:draft_publication) %>
|
<% if process.draft_publication.enabled? %>
|
||||||
<li <%= "class=active" if phase == :draft_publication %>>
|
<li <%= "class=active" if phase == :draft_publication %>>
|
||||||
<%= link_to legislation_process_draft_publication_path(process) do %>
|
<%= link_to legislation_process_draft_publication_path(process) do %>
|
||||||
<h4><%= t('legislation.processes.shared.draft_publication_date') %></h4>
|
<h4><%= t('legislation.processes.shared.draft_publication_date') %></h4>
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if process.active_phase?(:allegations) %>
|
<% if process.allegations_phase.enabled? %>
|
||||||
<li <%= "class=active" if phase == :allegations %>>
|
<li <%= "class=active" if phase == :allegations_phase %>>
|
||||||
<%= link_to legislation_process_allegations_path(process) do %>
|
<%= link_to legislation_process_allegations_path(process) do %>
|
||||||
<h4><%= t('legislation.processes.shared.allegations_dates') %></h4>
|
<h4><%= t('legislation.processes.shared.allegations_dates') %></h4>
|
||||||
<p><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %></p>
|
<p><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %></p>
|
||||||
@@ -34,11 +34,11 @@
|
|||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if process.active_phase?(:final_version_publication) %>
|
<% if process.result_publication.enabled? %>
|
||||||
<li <%= "class=active" if phase == :final_version_publication %>>
|
<li <%= "class=active" if phase == :result_publication %>>
|
||||||
<%= link_to legislation_process_final_version_publication_path(process) do %>
|
<%= link_to legislation_process_result_publication_path(process) do %>
|
||||||
<h4><%= t('legislation.processes.shared.final_publication_date') %></h4>
|
<h4><%= t('legislation.processes.shared.result_publication_date') %></h4>
|
||||||
<p><%= format_date(process.final_publication_date) %></p>
|
<p><%= format_date(process.result_publication_date) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% if process.enabled_phases_and_publications_count.positive? %>
|
||||||
|
<% column_width = 12 / process.enabled_phases_and_publications_count %>
|
||||||
<div class="column row">
|
<div class="column row">
|
||||||
<div class="small-12 column legislation-calendar-info">
|
<div class="small-12 column legislation-calendar-info">
|
||||||
<p><%= t('legislation.processes.shared.key_dates') %></p>
|
<p><%= t('legislation.processes.shared.key_dates') %></p>
|
||||||
@@ -24,21 +26,33 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column row small-collapse medium-uncollapse legislation-calendar">
|
<div class="column row small-collapse medium-uncollapse legislation-calendar">
|
||||||
<div class="small-6 medium-3 column">
|
<% if process.debate_phase.enabled? %>
|
||||||
|
<div class="small-6 medium-<%= column_width %> column">
|
||||||
<h5><%= t('legislation.processes.shared.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>
|
<p><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-6 medium-3 column">
|
<% end %>
|
||||||
|
|
||||||
|
<% if process.draft_publication.enabled? %>
|
||||||
|
<div class="small-6 medium-<%= column_width %> column">
|
||||||
<h5><%= t('legislation.processes.shared.draft_publication_date') %></h5>
|
<h5><%= t('legislation.processes.shared.draft_publication_date') %></h5>
|
||||||
<p><%= format_date(process.draft_publication_date) %></p>
|
<p><%= format_date(process.draft_publication_date) %></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-6 medium-3 column">
|
<% end %>
|
||||||
|
|
||||||
|
<% if process.allegations_phase.enabled? %>
|
||||||
|
<div class="small-6 medium-<%= column_width %> column">
|
||||||
<h5><%= t('legislation.processes.shared.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>
|
<p><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-6 medium-3 column">
|
<% end %>
|
||||||
<h5><%= t('legislation.processes.shared.final_publication_date') %></h5>
|
|
||||||
<p><%= format_date(process.final_publication_date) %></p>
|
<% 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>
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<% if question.question_options.any? %>
|
<% 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| %>
|
<%= 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| %>
|
<% question.question_options.each do |question_option| %>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
signin: link_to(t("legislation.questions.participation.signin"), new_user_session_path),
|
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 %>
|
signup: link_to(t("legislation.questions.participation.signup"), new_user_registration_path)).html_safe %>
|
||||||
</div>
|
</div>
|
||||||
<% elsif !@process.open_phase?(:debate) %>
|
<% elsif !@process.debate_phase.open? %>
|
||||||
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
|
<div class="participation-not-allowed" style='display:none' aria-hidden="false">
|
||||||
<%= t("legislation.questions.participation.debate_phase_not_open") %>
|
<%= t("legislation.questions.participation.debate_phase_not_open") %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -71,10 +71,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-4 column">
|
<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>
|
||||||
<div class="small-12 medium-2 column end">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ en:
|
|||||||
draft_publication_date: Draft publication date
|
draft_publication_date: Draft publication date
|
||||||
allegations_start_date: Allegations start date
|
allegations_start_date: Allegations start date
|
||||||
allegations_end_date: Allegations end date
|
allegations_end_date: Allegations end date
|
||||||
final_publication_date: Final result publication date
|
result_publication_date: Final result publication date
|
||||||
legislation/draft_version:
|
legislation/draft_version:
|
||||||
title: Version title
|
title: Version title
|
||||||
body: Text
|
body: Text
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ es:
|
|||||||
draft_publication_date: Fecha de publicación del borrador
|
draft_publication_date: Fecha de publicación del borrador
|
||||||
allegations_start_date: Fecha de inicio de alegaciones
|
allegations_start_date: Fecha de inicio de alegaciones
|
||||||
allegations_end_date: Fecha de fin 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:
|
legislation/draft_version:
|
||||||
title: Título de la version
|
title: Título de la version
|
||||||
body: Texto
|
body: Texto
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ en:
|
|||||||
form:
|
form:
|
||||||
error: Error
|
error: Error
|
||||||
form:
|
form:
|
||||||
active: Active
|
enabled: Enabled
|
||||||
process: Process
|
process: Process
|
||||||
debate_phase: Debate phase
|
debate_phase: Debate phase
|
||||||
allegations_phase: Allegations phase
|
allegations_phase: Allegations phase
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ es:
|
|||||||
form:
|
form:
|
||||||
error: Error
|
error: Error
|
||||||
form:
|
form:
|
||||||
active: Activa
|
enabled: Habilitado
|
||||||
process: Proceso
|
process: Proceso
|
||||||
debate_phase: Fase previa
|
debate_phase: Fase previa
|
||||||
allegations_phase: Fase de alegaciones
|
allegations_phase: Fase de alegaciones
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ en:
|
|||||||
debate_dates: Debate
|
debate_dates: Debate
|
||||||
draft_publication_date: Draft publication
|
draft_publication_date: Draft publication
|
||||||
allegations_dates: Allegations
|
allegations_dates: Allegations
|
||||||
final_publication_date: Final result publication
|
result_publication_date: Final result publication
|
||||||
questions:
|
questions:
|
||||||
comments:
|
comments:
|
||||||
comment_button: Publish answer
|
comment_button: Publish answer
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ es:
|
|||||||
debate_dates: Debate previo
|
debate_dates: Debate previo
|
||||||
draft_publication_date: Publicación borrador
|
draft_publication_date: Publicación borrador
|
||||||
allegations_dates: Alegaciones
|
allegations_dates: Alegaciones
|
||||||
final_publication_date: Publicación resultados
|
result_publication_date: Publicación resultados
|
||||||
questions:
|
questions:
|
||||||
comments:
|
comments:
|
||||||
comment_button: Publicar respuesta
|
comment_button: Publicar respuesta
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ Rails.application.routes.draw do
|
|||||||
get :debate
|
get :debate
|
||||||
get :draft_publication
|
get :draft_publication
|
||||||
get :allegations
|
get :allegations
|
||||||
get :final_version_publication
|
get :result_publication
|
||||||
resources :questions, only: [:show] do
|
resources :questions, only: [:show] do
|
||||||
resources :answers, only: [:create]
|
resources :answers, only: [:create]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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)
|
org = org_user.create_organization(name: org_name, responsible_name: org_responsible_name)
|
||||||
|
|
||||||
verified = [true, false].sample
|
verified = [true, false].sample
|
||||||
if verified then
|
if verified
|
||||||
org.verify
|
org.verify
|
||||||
else
|
else
|
||||||
org.reject
|
org.reject
|
||||||
@@ -150,7 +150,7 @@ puts " ✅"
|
|||||||
print "Creating Debates"
|
print "Creating Debates"
|
||||||
|
|
||||||
tags = Faker::Lorem.words(25)
|
tags = Faker::Lorem.words(25)
|
||||||
(1..30).each do
|
30.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||||
debate = Debate.create!(author: author,
|
debate = Debate.create!(author: author,
|
||||||
@@ -162,9 +162,8 @@ tags = Faker::Lorem.words(25)
|
|||||||
terms_of_service: "1")
|
terms_of_service: "1")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||||
(1..30).each do
|
30.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||||
debate = Debate.create!(author: author,
|
debate = Debate.create!(author: author,
|
||||||
@@ -176,12 +175,11 @@ tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
|||||||
terms_of_service: "1")
|
terms_of_service: "1")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Creating Proposals"
|
print "Creating Proposals"
|
||||||
|
|
||||||
tags = Faker::Lorem.words(25)
|
tags = Faker::Lorem.words(25)
|
||||||
(1..30).each do |i|
|
30.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||||
proposal = Proposal.create!(author: author,
|
proposal = Proposal.create!(author: author,
|
||||||
@@ -201,7 +199,7 @@ puts " ✅"
|
|||||||
print "Creating Archived Proposals"
|
print "Creating Archived Proposals"
|
||||||
|
|
||||||
tags = Faker::Lorem.words(25)
|
tags = Faker::Lorem.words(25)
|
||||||
(1..5).each do
|
5.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||||
proposal = Proposal.create!(author: author,
|
proposal = Proposal.create!(author: author,
|
||||||
@@ -221,7 +219,7 @@ puts " ✅"
|
|||||||
print "Creating Successful Proposals"
|
print "Creating Successful Proposals"
|
||||||
|
|
||||||
tags = Faker::Lorem.words(25)
|
tags = Faker::Lorem.words(25)
|
||||||
(1..10).each do |i|
|
10.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||||
proposal = Proposal.create!(author: author,
|
proposal = Proposal.create!(author: author,
|
||||||
@@ -238,9 +236,8 @@ tags = Faker::Lorem.words(25)
|
|||||||
cached_votes_up: Setting["votes_for_proposal_success"])
|
cached_votes_up: Setting["votes_for_proposal_success"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||||
(1..30).each do
|
30.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||||
proposal = Proposal.create!(author: author,
|
proposal = Proposal.create!(author: author,
|
||||||
@@ -256,11 +253,10 @@ tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
|||||||
terms_of_service: "1")
|
terms_of_service: "1")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Commenting Debates"
|
print "Commenting Debates"
|
||||||
|
|
||||||
(1..100).each do
|
100.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
debate = Debate.reorder("RANDOM()").first
|
debate = Debate.reorder("RANDOM()").first
|
||||||
Comment.create!(user: author,
|
Comment.create!(user: author,
|
||||||
@@ -269,11 +265,10 @@ print "Commenting Debates"
|
|||||||
body: Faker::Lorem.sentence)
|
body: Faker::Lorem.sentence)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Commenting Proposals"
|
print "Commenting Proposals"
|
||||||
|
|
||||||
(1..100).each do |i|
|
100.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
proposal = Proposal.reorder("RANDOM()").first
|
proposal = Proposal.reorder("RANDOM()").first
|
||||||
Comment.create!(user: author,
|
Comment.create!(user: author,
|
||||||
@@ -282,11 +277,10 @@ print "Commenting Proposals"
|
|||||||
body: Faker::Lorem.sentence)
|
body: Faker::Lorem.sentence)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Commenting Comments"
|
print "Commenting Comments"
|
||||||
|
|
||||||
(1..200).each do
|
200.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
parent = Comment.reorder("RANDOM()").first
|
parent = Comment.reorder("RANDOM()").first
|
||||||
Comment.create!(user: author,
|
Comment.create!(user: author,
|
||||||
@@ -297,47 +291,45 @@ print "Commenting Comments"
|
|||||||
parent: parent)
|
parent: parent)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Voting Debates, Proposals & Comments"
|
print "Voting Debates, Proposals & Comments"
|
||||||
|
|
||||||
(1..100).each do
|
100.times do
|
||||||
voter = not_org_users.level_two_or_three_verified.reorder("RANDOM()").first
|
voter = not_org_users.level_two_or_three_verified.reorder("RANDOM()").first
|
||||||
vote = [true, false].sample
|
vote = [true, false].sample
|
||||||
debate = Debate.reorder("RANDOM()").first
|
debate = Debate.reorder("RANDOM()").first
|
||||||
debate.vote_by(voter: voter, vote: vote)
|
debate.vote_by(voter: voter, vote: vote)
|
||||||
end
|
end
|
||||||
|
|
||||||
(1..100).each do |i|
|
100.times do
|
||||||
voter = not_org_users.reorder("RANDOM()").first
|
voter = not_org_users.reorder("RANDOM()").first
|
||||||
vote = [true, false].sample
|
vote = [true, false].sample
|
||||||
comment = Comment.reorder("RANDOM()").first
|
comment = Comment.reorder("RANDOM()").first
|
||||||
comment.vote_by(voter: voter, vote: vote)
|
comment.vote_by(voter: voter, vote: vote)
|
||||||
end
|
end
|
||||||
|
|
||||||
(1..100).each do
|
100.times do
|
||||||
voter = not_org_users.level_two_or_three_verified.reorder("RANDOM()").first
|
voter = not_org_users.level_two_or_three_verified.reorder("RANDOM()").first
|
||||||
proposal = Proposal.reorder("RANDOM()").first
|
proposal = Proposal.reorder("RANDOM()").first
|
||||||
proposal.vote_by(voter: voter, vote: true)
|
proposal.vote_by(voter: voter, vote: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Flagging Debates & Comments"
|
print "Flagging Debates & Comments"
|
||||||
|
|
||||||
(1..40).each do
|
40.times do
|
||||||
debate = Debate.reorder("RANDOM()").first
|
debate = Debate.reorder("RANDOM()").first
|
||||||
flagger = User.where(["users.id <> ?", debate.author_id]).reorder("RANDOM()").first
|
flagger = User.where(["users.id <> ?", debate.author_id]).reorder("RANDOM()").first
|
||||||
Flag.flag(flagger, debate)
|
Flag.flag(flagger, debate)
|
||||||
end
|
end
|
||||||
|
|
||||||
(1..40).each do
|
40.times do
|
||||||
comment = Comment.reorder("RANDOM()").first
|
comment = Comment.reorder("RANDOM()").first
|
||||||
flagger = User.where(["users.id <> ?", comment.user_id]).reorder("RANDOM()").first
|
flagger = User.where(["users.id <> ?", comment.user_id]).reorder("RANDOM()").first
|
||||||
Flag.flag(flagger, comment)
|
Flag.flag(flagger, comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
(1..40).each do
|
40.times do
|
||||||
proposal = Proposal.reorder("RANDOM()").first
|
proposal = Proposal.reorder("RANDOM()").first
|
||||||
flagger = User.where(["users.id <> ?", proposal.author_id]).reorder("RANDOM()").first
|
flagger = User.where(["users.id <> ?", proposal.author_id]).reorder("RANDOM()").first
|
||||||
Flag.flag(flagger, proposal)
|
Flag.flag(flagger, proposal)
|
||||||
@@ -348,7 +340,7 @@ print "Creating Spending Proposals"
|
|||||||
|
|
||||||
tags = Faker::Lorem.words(10)
|
tags = Faker::Lorem.words(10)
|
||||||
|
|
||||||
(1..60).each do
|
60.times do
|
||||||
geozone = Geozone.reorder("RANDOM()").first
|
geozone = Geozone.reorder("RANDOM()").first
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||||
@@ -376,13 +368,14 @@ print "Creating Valuation Assignments"
|
|||||||
SpendingProposal.reorder("RANDOM()").first.valuators << valuator.valuator
|
SpendingProposal.reorder("RANDOM()").first.valuators << valuator.valuator
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Creating Budgets"
|
print "Creating Budgets"
|
||||||
|
|
||||||
Budget::PHASES.each_with_index do |phase, i|
|
Budget::PHASES.each_with_index do |phase, i|
|
||||||
descriptions = Hash[Budget::PHASES.map{ |p| ["description_#{p}",
|
descriptions = Hash[Budget::PHASES.map do |p|
|
||||||
"<p>#{Faker::Lorem.paragraphs(2).join('</p><p>')}</p>"] }]
|
["description_#{p}",
|
||||||
|
"<p>#{Faker::Lorem.paragraphs(2).join('</p><p>')}</p>"]
|
||||||
|
end]
|
||||||
budget = Budget.create!(
|
budget = Budget.create!(
|
||||||
descriptions.merge(
|
descriptions.merge(
|
||||||
name: (Date.current - 10 + i).to_s,
|
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 = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample)
|
||||||
geozones.each do |geozone|
|
geozones.each do |geozone|
|
||||||
group.headings << group.headings.create!(name: geozone.name,
|
group.headings << group.headings.create!(name: geozone.name,
|
||||||
#geozone: geozone,
|
|
||||||
price: rand(1..100) * 100000)
|
price: rand(1..100) * 100000)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Creating Investments"
|
print "Creating Investments"
|
||||||
tags = Faker::Lorem.words(10)
|
tags = Faker::Lorem.words(10)
|
||||||
(1..100).each do |i|
|
100.times do
|
||||||
heading = Budget::Heading.reorder("RANDOM()").first
|
heading = Budget::Heading.reorder("RANDOM()").first
|
||||||
|
|
||||||
investment = Budget::Investment.create!(
|
investment = Budget::Investment.create!(
|
||||||
@@ -425,7 +415,8 @@ tags = Faker::Lorem.words(10)
|
|||||||
valuation_finished: [false, true].sample,
|
valuation_finished: [false, true].sample,
|
||||||
tag_list: tags.sample(3).join(','),
|
tag_list: tags.sample(3).join(','),
|
||||||
price: rand(1..100) * 100000,
|
price: rand(1..100) * 100000,
|
||||||
terms_of_service: "1")
|
terms_of_service: "1"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
@@ -438,7 +429,7 @@ puts " ✅"
|
|||||||
print "Winner Investments"
|
print "Winner Investments"
|
||||||
|
|
||||||
budget = Budget.where(phase: "finished").last
|
budget = Budget.where(phase: "finished").last
|
||||||
(1..100).each do |i|
|
100.times do
|
||||||
heading = budget.headings.reorder("RANDOM()").first
|
heading = budget.headings.reorder("RANDOM()").first
|
||||||
investment = Budget::Investment.create!(
|
investment = Budget::Investment.create!(
|
||||||
author: User.reorder("RANDOM()").first,
|
author: User.reorder("RANDOM()").first,
|
||||||
@@ -453,7 +444,8 @@ budget = Budget.where(phase: "finished").last
|
|||||||
valuation_finished: true,
|
valuation_finished: true,
|
||||||
selected: true,
|
selected: true,
|
||||||
price: rand(10000..heading.price),
|
price: rand(10000..heading.price),
|
||||||
terms_of_service: "1")
|
terms_of_service: "1"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
budget.headings.each do |heading|
|
budget.headings.each do |heading|
|
||||||
Budget::Result.new(budget, heading).calculate_winners
|
Budget::Result.new(budget, heading).calculate_winners
|
||||||
@@ -466,16 +458,13 @@ print "Creating Valuation Assignments"
|
|||||||
Budget::Investment.reorder("RANDOM()").first.valuators << valuator.valuator
|
Budget::Investment.reorder("RANDOM()").first.valuators << valuator.valuator
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Ignoring flags in Debates, comments & proposals"
|
print "Ignoring flags in Debates, comments & proposals"
|
||||||
|
|
||||||
|
|
||||||
Debate.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag)
|
Debate.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag)
|
||||||
Comment.flagged.reorder("RANDOM()").limit(30).each(&:ignore_flag)
|
Comment.flagged.reorder("RANDOM()").limit(30).each(&:ignore_flag)
|
||||||
Proposal.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag)
|
Proposal.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag)
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Hiding debates, comments & proposals"
|
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)
|
Debate.with_hidden.flagged.reorder("RANDOM()").limit(5).each(&:hide)
|
||||||
Proposal.with_hidden.flagged.reorder("RANDOM()").limit(10).each(&:hide)
|
Proposal.with_hidden.flagged.reorder("RANDOM()").limit(10).each(&:hide)
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Confirming hiding in debates, comments & proposals"
|
print "Confirming hiding in debates, comments & proposals"
|
||||||
|
|
||||||
@@ -530,19 +518,14 @@ print "Active Polls"
|
|||||||
ends_at: 1.month.from_now,
|
ends_at: 1.month.from_now,
|
||||||
geozone_restricted: false)
|
geozone_restricted: false)
|
||||||
end
|
end
|
||||||
(4..5).each do |i|
|
(1..5).each do |i|
|
||||||
poll = Poll.create(name: "Active Poll #{i}",
|
poll = Poll.create(name: "Active Poll #{i}",
|
||||||
starts_at: 1.month.ago,
|
starts_at: 1.month.ago,
|
||||||
ends_at: 1.month.from_now,
|
ends_at: 1.month.from_now,
|
||||||
geozone_restricted: true,
|
geozone_restricted: true,
|
||||||
geozones: Geozone.reorder("RANDOM()").limit(3)
|
geozones: Geozone.reorder("RANDOM()").limit(3))
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Upcoming Poll"
|
print "Upcoming Poll"
|
||||||
poll = Poll.create(name: "Upcoming Poll",
|
poll = Poll.create(name: "Upcoming Poll",
|
||||||
@@ -553,12 +536,12 @@ puts " ✅"
|
|||||||
print "Expired Poll"
|
print "Expired Poll"
|
||||||
poll = Poll.create(name: "Expired Poll",
|
poll = Poll.create(name: "Expired Poll",
|
||||||
starts_at: 2.months.ago,
|
starts_at: 2.months.ago,
|
||||||
ends_at: 1.months.ago)
|
ends_at: 1.month.ago)
|
||||||
|
|
||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Creating Poll Questions"
|
print "Creating Poll Questions"
|
||||||
|
|
||||||
(1..50).each do |i|
|
50.times do
|
||||||
poll = Poll.reorder("RANDOM()").first
|
poll = Poll.reorder("RANDOM()").first
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||||
@@ -608,7 +591,7 @@ end
|
|||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Creating Poll Questions from Proposals"
|
print "Creating Poll Questions from Proposals"
|
||||||
|
|
||||||
(1..3).each do
|
3.times do
|
||||||
proposal = Proposal.reorder("RANDOM()").first
|
proposal = Proposal.reorder("RANDOM()").first
|
||||||
poll = Poll.current.first
|
poll = Poll.current.first
|
||||||
question = Poll::Question.create(valid_answers: "Yes, No")
|
question = Poll::Question.create(valid_answers: "Yes, No")
|
||||||
@@ -619,7 +602,7 @@ end
|
|||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Creating Successful Proposals"
|
print "Creating Successful Proposals"
|
||||||
|
|
||||||
(1..10).each do
|
10.times do
|
||||||
proposal = Proposal.reorder("RANDOM()").first
|
proposal = Proposal.reorder("RANDOM()").first
|
||||||
poll = Poll.current.first
|
poll = Poll.current.first
|
||||||
question = Poll::Question.create(valid_answers: "Yes, No")
|
question = Poll::Question.create(valid_answers: "Yes, No")
|
||||||
@@ -630,7 +613,7 @@ end
|
|||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Commenting Poll Questions"
|
print "Commenting Poll Questions"
|
||||||
|
|
||||||
(1..30).each do
|
30.times do
|
||||||
author = User.reorder("RANDOM()").first
|
author = User.reorder("RANDOM()").first
|
||||||
question = Poll::Question.reorder("RANDOM()").first
|
question = Poll::Question.reorder("RANDOM()").first
|
||||||
Comment.create!(user: author,
|
Comment.create!(user: author,
|
||||||
@@ -642,7 +625,7 @@ end
|
|||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Creating Poll Voters"
|
print "Creating Poll Voters"
|
||||||
|
|
||||||
(1..10).each do
|
10.times do
|
||||||
poll = Poll.all.sample
|
poll = Poll.all.sample
|
||||||
user = User.level_two_verified.sample
|
user = User.level_two_verified.sample
|
||||||
Poll::Voter.create(poll: poll, user: user)
|
Poll::Voter.create(poll: poll, user: user)
|
||||||
@@ -651,7 +634,7 @@ end
|
|||||||
puts " ✅"
|
puts " ✅"
|
||||||
print "Creating legislation processes"
|
print "Creating legislation processes"
|
||||||
|
|
||||||
(1..5).each do |i|
|
5.times do
|
||||||
process = ::Legislation::Process.create!(title: Faker::Lorem.sentence(3).truncate(60),
|
process = ::Legislation::Process.create!(title: Faker::Lorem.sentence(3).truncate(60),
|
||||||
description: Faker::Lorem.paragraphs.join("\n\n"),
|
description: Faker::Lorem.paragraphs.join("\n\n"),
|
||||||
summary: Faker::Lorem.paragraph,
|
summary: Faker::Lorem.paragraph,
|
||||||
@@ -663,15 +646,18 @@ print "Creating legislation processes"
|
|||||||
draft_publication_date: Date.current + 1.day,
|
draft_publication_date: Date.current + 1.day,
|
||||||
allegations_start_date: Date.current + 2.days,
|
allegations_start_date: Date.current + 2.days,
|
||||||
allegations_end_date: Date.current + 3.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
|
end
|
||||||
|
|
||||||
::Legislation::Process.all.each do |process|
|
::Legislation::Process.all.each do |process|
|
||||||
(1..3).each do |i|
|
(1..3).each do |i|
|
||||||
version = process.draft_versions.create!(title: "Version #{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
|
||||||
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.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -411,11 +411,15 @@ ActiveRecord::Schema.define(version: 20170610211027) do
|
|||||||
t.date "draft_publication_date"
|
t.date "draft_publication_date"
|
||||||
t.date "allegations_start_date"
|
t.date "allegations_start_date"
|
||||||
t.date "allegations_end_date"
|
t.date "allegations_end_date"
|
||||||
t.date "final_publication_date"
|
t.date "result_publication_date"
|
||||||
t.datetime "hidden_at"
|
t.datetime "hidden_at"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.text "summary"
|
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
|
end
|
||||||
|
|
||||||
add_index "legislation_processes", ["allegations_end_date"], name: "index_legislation_processes_on_allegations_end_date", using: :btree
|
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", ["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", ["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", ["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", ["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
|
add_index "legislation_processes", ["start_date"], name: "index_legislation_processes_on_start_date", using: :btree
|
||||||
|
|
||||||
create_table "legislation_question_options", force: :cascade do |t|
|
create_table "legislation_question_options", force: :cascade do |t|
|
||||||
|
|||||||
@@ -612,7 +612,11 @@ FactoryGirl.define do
|
|||||||
draft_publication_date Date.current - 1.day
|
draft_publication_date Date.current - 1.day
|
||||||
allegations_start_date Date.current
|
allegations_start_date Date.current
|
||||||
allegations_end_date Date.current + 3.days
|
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
|
trait :next do
|
||||||
start_date Date.current + 2.days
|
start_date Date.current + 2.days
|
||||||
@@ -622,7 +626,7 @@ FactoryGirl.define do
|
|||||||
draft_publication_date Date.current + 5.day
|
draft_publication_date Date.current + 5.day
|
||||||
allegations_start_date Date.current + 5.days
|
allegations_start_date Date.current + 5.days
|
||||||
allegations_end_date Date.current + 7.days
|
allegations_end_date Date.current + 7.days
|
||||||
final_publication_date Date.current + 8.days
|
result_publication_date Date.current + 8.days
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :past do
|
trait :past do
|
||||||
@@ -633,7 +637,7 @@ FactoryGirl.define do
|
|||||||
draft_publication_date Date.current - 8.day
|
draft_publication_date Date.current - 8.day
|
||||||
allegations_start_date Date.current - 8.days
|
allegations_start_date Date.current - 8.days
|
||||||
allegations_end_date Date.current - 4.days
|
allegations_end_date Date.current - 4.days
|
||||||
final_publication_date Date.current - 2.days
|
result_publication_date Date.current - 2.days
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :in_debate_phase do
|
trait :in_debate_phase do
|
||||||
@@ -644,7 +648,7 @@ FactoryGirl.define do
|
|||||||
draft_publication_date Date.current + 1.day
|
draft_publication_date Date.current + 1.day
|
||||||
allegations_start_date Date.current + 2.days
|
allegations_start_date Date.current + 2.days
|
||||||
allegations_end_date Date.current + 3.days
|
allegations_end_date Date.current + 3.days
|
||||||
final_publication_date Date.current + 5.days
|
result_publication_date Date.current + 5.days
|
||||||
end
|
end
|
||||||
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[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_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[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'
|
click_button 'Create process'
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ feature 'Admin legislation processes' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'Update' do
|
context 'Update' do
|
||||||
scenario 'Deactivate debate phase', js: true do
|
scenario 'Remove summary text', js: true do
|
||||||
process = create(:legislation_process,
|
process = create(:legislation_process,
|
||||||
title: 'An example legislation process',
|
title: 'An example legislation process',
|
||||||
summary: 'Summarizing the process',
|
summary: 'Summarizing the process',
|
||||||
@@ -87,19 +87,43 @@ feature 'Admin legislation processes' do
|
|||||||
click_link "An example legislation process"
|
click_link "An example legislation process"
|
||||||
|
|
||||||
expect(page).to have_selector("h2", text: "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: ''
|
fill_in 'legislation_process_summary', with: ''
|
||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
|
|
||||||
expect(page).to have_content "Process updated successfully"
|
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
|
visit legislation_processes_path
|
||||||
expect(page).not_to have_content 'Summarizing the process'
|
expect(page).not_to have_content 'Summarizing the process'
|
||||||
expect(page).to have_content 'Description of the process'
|
expect(page).to have_content 'Description of the process'
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -104,17 +104,17 @@ feature 'Legislation' do
|
|||||||
|
|
||||||
context 'final version publication phase' do
|
context 'final version publication phase' do
|
||||||
scenario 'not open' 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")
|
expect(page).to have_content("This phase is not open yet")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'open' do
|
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")
|
expect(page).to have_content("Nothing published yet")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,9 +65,9 @@ describe DirectMessage do
|
|||||||
|
|
||||||
describe "today" do
|
describe "today" do
|
||||||
it "should return direct messages created 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_message1 = create(:direct_message, created_at: Time.now.utc.beginning_of_day + 3.hours)
|
||||||
direct_message2 = create(:direct_message, created_at: Time.current)
|
direct_message2 = create(:direct_message, created_at: Time.now.utc)
|
||||||
direct_message3 = create(:direct_message, created_at: Time.current.end_of_day)
|
direct_message3 = create(:direct_message, created_at: Time.now.utc.end_of_day)
|
||||||
|
|
||||||
expect(DirectMessage.today.count).to eq 3
|
expect(DirectMessage.today.count).to eq 3
|
||||||
end
|
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
|
||||||
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
|
describe "#status" do
|
||||||
it "should detect planned phase" do
|
it "should detect planned phase" do
|
||||||
process.update_attributes(start_date: Date.current + 2.days)
|
process.update_attributes(start_date: Date.current + 2.days)
|
||||||
|
|||||||
Reference in New Issue
Block a user