Shows participation phases only if there is a phase enabled
This commit is contained in:
@@ -80,6 +80,10 @@ class Legislation::Process < ActiveRecord::Base
|
|||||||
Legislation::Process::Publication.new(result_publication_date, result_publication_enabled)
|
Legislation::Process::Publication.new(result_publication_date, result_publication_enabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def enabled_phases?
|
||||||
|
PHASES_AND_PUBLICATIONS.any? { |process| send(process).enabled? }
|
||||||
|
end
|
||||||
|
|
||||||
def enabled_phases_and_publications_count
|
def enabled_phases_and_publications_count
|
||||||
PHASES_AND_PUBLICATIONS.count { |process| send(process).enabled? }
|
PHASES_AND_PUBLICATIONS.count { |process| send(process).enabled? }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,65 +1,65 @@
|
|||||||
<nav class="legislation-process-categories">
|
<nav class="<%= 'legislation-process-list' if process.enabled_phases? %>">
|
||||||
<div class="legislation-process-list">
|
<div class="row">
|
||||||
<div class="row">
|
<div class="small-12 column">
|
||||||
<div class="small-12 column">
|
<% if process.enabled_phases? %>
|
||||||
<h3><%= t("legislation.processes.shared.key_dates") %></h3>
|
<h3><%= t("legislation.processes.shared.key_dates") %></h3>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<ul>
|
<ul class="key-dates">
|
||||||
<% if process.debate_phase.enabled? %>
|
<% if process.debate_phase.enabled? %>
|
||||||
<li <%= 'class=is-active' if phase.to_sym == :debate_phase %>>
|
<li <%= 'class=is-active' if phase.to_sym == :debate_phase %>>
|
||||||
<%= link_to debate_legislation_process_path(process) do %>
|
<%= link_to debate_legislation_process_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>
|
<span><%= format_date(process.debate_start_date) %> - <%= format_date(process.debate_end_date) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if process.proposals_phase.enabled? %>
|
<% if process.proposals_phase.enabled? %>
|
||||||
<li <%= 'class=is-active' if phase.to_sym == :proposals %>>
|
<li <%= 'class=is-active' if phase.to_sym == :proposals %>>
|
||||||
<%= link_to proposals_legislation_process_path(process) do %>
|
<%= link_to proposals_legislation_process_path(process) do %>
|
||||||
<h4><%= t('legislation.processes.shared.proposals_dates') %></h4>
|
<h4><%= t("legislation.processes.shared.proposals_dates") %></h4>
|
||||||
<p><%= format_date(process.proposals_phase_start_date) %> - <%= format_date(process.proposals_phase_end_date) %></p>
|
<span><%= format_date(process.proposals_phase_start_date) %> - <%= format_date(process.proposals_phase_end_date) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if process.draft_publication.enabled? %>
|
<% if process.draft_publication.enabled? %>
|
||||||
<li <%= 'class=is-active' if phase.to_sym == :draft_publication %>>
|
<li <%= 'class=is-active' if phase.to_sym == :draft_publication %>>
|
||||||
<%= link_to draft_publication_legislation_process_path(process) do %>
|
<%= link_to draft_publication_legislation_process_path(process) do %>
|
||||||
<h4><%= t('legislation.processes.shared.draft_publication_date') %></h4>
|
<h4><%= t("legislation.processes.shared.draft_publication_date") %></h4>
|
||||||
<p><%= format_date(process.draft_publication_date) %></p>
|
<span><%= format_date(process.draft_publication_date) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if process.allegations_phase.enabled? %>
|
<% if process.allegations_phase.enabled? %>
|
||||||
<li <%= 'class=is-active' if phase.to_sym == :allegations_phase %>>
|
<li <%= 'class=is-active' if phase.to_sym == :allegations_phase %>>
|
||||||
<%= link_to allegations_legislation_process_path(process) do %>
|
<%= link_to allegations_legislation_process_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>
|
<span><%= format_date(process.allegations_start_date) %> - <%= format_date(process.allegations_end_date) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if process.result_publication.enabled? %>
|
<% if process.result_publication.enabled? %>
|
||||||
<li <%= 'class=is-active' if phase.to_sym == :result_publication %>>
|
<li <%= 'class=is-active' if phase.to_sym == :result_publication %>>
|
||||||
<%= link_to result_publication_legislation_process_path(process) do %>
|
<%= link_to result_publication_legislation_process_path(process) do %>
|
||||||
<h4><%= t('legislation.processes.shared.result_publication_date') %></h4>
|
<h4><%= t("legislation.processes.shared.result_publication_date") %></h4>
|
||||||
<p><%= format_date(process.result_publication_date) %></p>
|
<span><%= format_date(process.result_publication_date) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if process.milestones.any? %>
|
<% if process.milestones.any? %>
|
||||||
<li class="milestones <%= "is-active" if phase == :milestones %>">
|
<li class="milestones <%= "is-active" if phase == :milestones %>">
|
||||||
<%= link_to milestones_legislation_process_path(process) do %>
|
<%= link_to milestones_legislation_process_path(process) do %>
|
||||||
<h4><%= t("legislation.processes.shared.milestones_date") %></h4>
|
<h4><%= t("legislation.processes.shared.milestones_date") %></h4>
|
||||||
<p><%= format_date(process.milestones.order_by_publication_date.last.publication_date) %></p>
|
<span><%= format_date(process.milestones.order_by_publication_date.last.publication_date) %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -100,6 +100,25 @@ FactoryBot.define do
|
|||||||
end_date { 1.week.from_now }
|
end_date { 1.week.from_now }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :empty do
|
||||||
|
start_date { Date.current - 5.days }
|
||||||
|
end_date { Date.current + 5.days }
|
||||||
|
debate_start_date nil
|
||||||
|
debate_end_date nil
|
||||||
|
draft_publication_date nil
|
||||||
|
allegations_start_date nil
|
||||||
|
allegations_end_date nil
|
||||||
|
proposals_phase_start_date nil
|
||||||
|
proposals_phase_end_date nil
|
||||||
|
result_publication_date nil
|
||||||
|
debate_phase_enabled false
|
||||||
|
allegations_phase_enabled false
|
||||||
|
proposals_phase_enabled false
|
||||||
|
draft_publication_enabled false
|
||||||
|
result_publication_enabled false
|
||||||
|
published true
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :legislation_draft_version, class: 'Legislation::DraftVersion' do
|
factory :legislation_draft_version, class: 'Legislation::DraftVersion' do
|
||||||
|
|||||||
@@ -47,17 +47,32 @@ feature 'Legislation' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Key dates are displayed on current locale' do
|
scenario 'Participation phases are displayed only if there is a phase enabled' do
|
||||||
|
process = create(:legislation_process, :empty)
|
||||||
|
process_debate = create(:legislation_process)
|
||||||
|
|
||||||
|
visit legislation_process_path(process)
|
||||||
|
|
||||||
|
expect(page).not_to have_content("Participation phases")
|
||||||
|
|
||||||
|
visit legislation_process_path(process_debate)
|
||||||
|
|
||||||
|
expect(page).to have_content("Participation phases")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Participation phases are displayed on current locale' do
|
||||||
process = create(:legislation_process, proposals_phase_start_date: Date.new(2018, 01, 01),
|
process = create(:legislation_process, proposals_phase_start_date: Date.new(2018, 01, 01),
|
||||||
proposals_phase_end_date: Date.new(2018, 12, 01))
|
proposals_phase_end_date: Date.new(2018, 12, 01))
|
||||||
|
|
||||||
visit legislation_process_path(process)
|
visit legislation_process_path(process)
|
||||||
|
|
||||||
|
expect(page).to have_content("Participation phases")
|
||||||
expect(page).to have_content("Proposals")
|
expect(page).to have_content("Proposals")
|
||||||
expect(page).to have_content("01 Jan 2018 - 01 Dec 2018")
|
expect(page).to have_content("01 Jan 2018 - 01 Dec 2018")
|
||||||
|
|
||||||
visit legislation_process_path(process, locale: "es")
|
visit legislation_process_path(process, locale: "es")
|
||||||
|
|
||||||
|
expect(page).to have_content("Fases de participación")
|
||||||
expect(page).to have_content("Propuestas")
|
expect(page).to have_content("Propuestas")
|
||||||
expect(page).to have_content("01 ene 2018 - 01 dic 2018")
|
expect(page).to have_content("01 ene 2018 - 01 dic 2018")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user