Merge pull request #2369 from consul/fix_finished_budgets_list
Correctly show finished budgets at budget index
This commit is contained in:
@@ -14,8 +14,7 @@ class BudgetsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@budgets = @budgets.order(created_at: :desc)
|
||||
@budget = current_budget
|
||||
@finished_budgets = @budgets.finished.order(created_at: :desc)
|
||||
@budgets_coordinates = current_budget_map_locations
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ul class="no-bullet budget-timeline">
|
||||
<% @budget.published_phases.each do |phase| %>
|
||||
<li class="phase <%= 'active' if phase == @budget.current_phase %>">
|
||||
<% current_budget.published_phases.each do |phase| %>
|
||||
<li class="phase <%= 'active' if phase == current_budget.current_phase %>">
|
||||
<h3><%= t("budgets.phase.#{phase.kind}") %></h3>
|
||||
<span>
|
||||
<%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %>
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
<div class="row" data-equalizer data-equalizer-on="medium">
|
||||
<div class="small-12 medium-9 column padding" data-equalizer-watch>
|
||||
|
||||
<h1><%= @budget.name %></h1>
|
||||
<h1><%= current_budget.name %></h1>
|
||||
<div class="description">
|
||||
<%= safe_html_with_links(@budget.description) %>
|
||||
<%= safe_html_with_links(current_budget.description) %>
|
||||
</div>
|
||||
<p>
|
||||
<%= link_to t("budgets.index.section_header.help"), "#section_help" %>
|
||||
@@ -19,11 +19,11 @@
|
||||
<p>
|
||||
<strong><%= t('budgets.show.phase') %></strong>
|
||||
</p>
|
||||
<h2><%= t("budgets.phase.#{@budget.phase}") %></h2>
|
||||
<h2><%= t("budgets.phase.#{current_budget.phase}") %></h2>
|
||||
|
||||
<%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %>
|
||||
|
||||
<% if @budget.accepting? %>
|
||||
<% if current_budget.accepting? %>
|
||||
<% if current_user %>
|
||||
<% if current_user.level_two_or_three_verified? %>
|
||||
<%= link_to t("budgets.investments.index.sidebar.create"),
|
||||
@@ -48,9 +48,9 @@
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if @budget.finished? || (@budget.balloting? && can?(:read_results, @budget)) %>
|
||||
<% if current_budget.finished? || (current_budget.balloting? && can?(:read_results, current_budget)) %>
|
||||
<%= link_to t("budgets.show.see_results"),
|
||||
budget_results_path(@budget, heading_id: @budget.headings.first),
|
||||
budget_results_path(current_budget, heading_id: current_budget.headings.first),
|
||||
class: "button margin-top expanded" %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -62,18 +62,18 @@
|
||||
<div class="small-12 column">
|
||||
|
||||
<div id="groups_and_headings" class="groups-and-headings">
|
||||
<% @budget.groups.each do |group| %>
|
||||
<% current_budget.groups.each do |group| %>
|
||||
<h2><%= group.name %></h2>
|
||||
<ul class="no-bullet">
|
||||
<% group.headings.order_by_group_name.each do |heading| %>
|
||||
<li class="heading small-12 medium-4 large-2">
|
||||
<% unless @budget.informing? %>
|
||||
<%= link_to budget_investments_path(@budget.id, heading_id: heading.id) do %>
|
||||
<%= heading_name_and_price_html(heading, @budget) %>
|
||||
<% unless current_budget.informing? %>
|
||||
<%= link_to budget_investments_path(current_budget.id, heading_id: heading.id) do %>
|
||||
<%= heading_name_and_price_html(heading, current_budget) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div>
|
||||
<%= heading_name_and_price_html(heading, @budget) %>
|
||||
<%= heading_name_and_price_html(heading, current_budget) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</li>
|
||||
@@ -82,20 +82,20 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% unless @budget.informing? %>
|
||||
<% unless current_budget.informing? %>
|
||||
<div id="map">
|
||||
<h3><%= t("budgets.index.map") %></h3>
|
||||
<%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<%= link_to budget_investments_path(@budget.id) do %>
|
||||
<%= link_to budget_investments_path(current_budget.id) do %>
|
||||
<small><%= t("budgets.index.investment_proyects") %></small>
|
||||
<% end %><br>
|
||||
<%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unfeasible') do %>
|
||||
<%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unfeasible') do %>
|
||||
<small><%= t("budgets.index.unfeasible_investment_proyects") %></small>
|
||||
<% end %><br>
|
||||
<%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unselected') do %>
|
||||
<%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unselected') do %>
|
||||
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
|
||||
<% end %>
|
||||
</p>
|
||||
@@ -103,26 +103,26 @@
|
||||
|
||||
<div id="all_phases">
|
||||
<h2><%= t("budgets.index.all_phases") %></h2>
|
||||
<%= render "phases" %>
|
||||
<%= render "phases", budget: current_budget %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row margin-top">
|
||||
<div class="small-12 medium-9 column">
|
||||
<ul class="no-bullet submenu">
|
||||
<li class="inline-block">
|
||||
<%= link_to "#other_budgets", class: "active" do %>
|
||||
<h2>
|
||||
<%= t("budgets.index.finished_budgets") %>
|
||||
</h2>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<% if @finished_budgets.present? %>
|
||||
<div class="row margin-top">
|
||||
<div class="small-12 medium-9 column">
|
||||
<ul class="no-bullet submenu">
|
||||
<li class="inline-block">
|
||||
<%= link_to "#other_budgets", class: "active" do %>
|
||||
<h2>
|
||||
<%= t("budgets.index.finished_budgets") %>
|
||||
</h2>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="budget-investments-list">
|
||||
<% @budgets.each do |budget| %>
|
||||
<% if budget_published?(budget) %>
|
||||
<div id="finished_budgets" class="budget-investments-list">
|
||||
<% @finished_budgets.each do |budget| %>
|
||||
<div class="budget-investment clear">
|
||||
<div class="panel past-budgets">
|
||||
<div class="row" data-equalizer data-equalizer-on="medium">
|
||||
@@ -142,10 +142,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
|
||||
@@ -6,32 +6,27 @@ feature 'Budgets' do
|
||||
let(:level_two_user) { create(:user, :level_two) }
|
||||
|
||||
context 'Index' do
|
||||
let(:budgets) { create_list(:budget, 3) }
|
||||
let(:last_budget) { budgets.last }
|
||||
|
||||
scenario 'Show normal index with links' do
|
||||
group1 = create(:budget_group, budget: last_budget)
|
||||
group2 = create(:budget_group, budget: last_budget)
|
||||
|
||||
group1 = create(:budget_group, budget: budget)
|
||||
group2 = create(:budget_group, budget: budget)
|
||||
heading1 = create(:budget_heading, group: group1)
|
||||
heading2 = create(:budget_heading, group: group2)
|
||||
|
||||
last_budget.update_attributes(phase: 'informing')
|
||||
budget.update_attributes(phase: 'informing')
|
||||
|
||||
visit budgets_path
|
||||
|
||||
|
||||
within("#budget_heading") do
|
||||
expect(page).to have_content(last_budget.name)
|
||||
expect(page).to have_content(last_budget.description)
|
||||
expect(page).to have_content(budget.name)
|
||||
expect(page).to have_content(budget.description)
|
||||
expect(page).to have_content("Actual phase")
|
||||
expect(page).to have_content(I18n.t('budgets.phase.informing'))
|
||||
expect(page).to have_link 'Help with participatory budgets'
|
||||
expect(page).to have_link 'See all phases'
|
||||
end
|
||||
|
||||
expect(page).to have_content("Accepting projects")
|
||||
|
||||
last_budget.update_attributes(phase: 'publishing_prices')
|
||||
budget.update_attributes(phase: 'publishing_prices')
|
||||
visit budgets_path
|
||||
|
||||
within("#budget_heading") do
|
||||
@@ -39,21 +34,32 @@ feature 'Budgets' do
|
||||
end
|
||||
|
||||
within('#budget_info') do
|
||||
expect(page).to have_content group1.name
|
||||
expect(page).to have_content group2.name
|
||||
expect(page).to have_content heading1.name
|
||||
expect(page).to have_content last_budget.formatted_heading_price(heading1)
|
||||
expect(page).to have_content heading2.name
|
||||
expect(page).to have_content last_budget.formatted_heading_price(heading2)
|
||||
expect(page).to have_content(group1.name)
|
||||
expect(page).to have_content(group2.name)
|
||||
expect(page).to have_content(heading1.name)
|
||||
expect(page).to have_content(budget.formatted_heading_price(heading1))
|
||||
expect(page).to have_content(heading2.name)
|
||||
expect(page).to have_content(budget.formatted_heading_price(heading2))
|
||||
end
|
||||
|
||||
expect(page).to have_content budgets.first.name
|
||||
expect(page).to have_content budgets[2].name
|
||||
expect(page).not_to have_content("#finished_budgets")
|
||||
end
|
||||
|
||||
scenario 'Show finished budgets list' do
|
||||
finished_budget = create(:budget, :finished)
|
||||
drafting_budget = create(:budget, :drafting)
|
||||
visit budgets_path
|
||||
|
||||
within("#finished_budgets") do
|
||||
expect(page).to have_content(finished_budget.name)
|
||||
expect(page).not_to have_content(budget.name)
|
||||
expect(page).not_to have_content(drafting_budget.name)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show informing index without links' do
|
||||
last_budget.update_attributes(phase: 'informing')
|
||||
group = create(:budget_group, budget: last_budget)
|
||||
budget.update_attributes(phase: 'informing')
|
||||
group = create(:budget_group, budget: budget)
|
||||
heading = create(:budget_heading, group: group)
|
||||
|
||||
visit budgets_path
|
||||
@@ -74,42 +80,42 @@ feature 'Budgets' do
|
||||
scenario 'Index shows only published phases' do
|
||||
|
||||
budget.update(phase: :finished)
|
||||
phases = budget.phases
|
||||
phases.drafting.update(starts_at: '30-12-2017', ends_at: '31-12-2017', enabled: true,
|
||||
description: 'Description of drafting phase',
|
||||
summary: '<p>This is the summary for drafting phase</p>')
|
||||
|
||||
budget.phases.drafting.update(starts_at: '30-12-2017', ends_at: '31-12-2017', enabled: true,
|
||||
description: 'Description of drafting phase',
|
||||
summary: '<p>This is the summary for drafting phase</p>')
|
||||
phases.accepting.update(starts_at: '01-01-2018', ends_at: '10-01-2018', enabled: true,
|
||||
description: 'Description of accepting phase',
|
||||
summary: 'This is the summary for accepting phase')
|
||||
|
||||
budget.phases.accepting.update(starts_at: '01-01-2018', ends_at: '10-01-2018', enabled: true,
|
||||
description: 'Description of accepting phase',
|
||||
summary: 'This is the summary for accepting phase')
|
||||
phases.reviewing.update(starts_at: '11-01-2018', ends_at: '20-01-2018', enabled: false,
|
||||
description: 'Description of reviewing phase',
|
||||
summary: 'This is the summary for reviewing phase')
|
||||
|
||||
budget.phases.reviewing.update(starts_at: '11-01-2018', ends_at: '20-01-2018', enabled: false,
|
||||
description: 'Description of reviewing phase',
|
||||
summary: 'This is the summary for reviewing phase')
|
||||
phases.selecting.update(starts_at: '21-01-2018', ends_at: '01-02-2018', enabled: true,
|
||||
description: 'Description of selecting phase',
|
||||
summary: 'This is the summary for selecting phase')
|
||||
|
||||
budget.phases.selecting.update(starts_at: '21-01-2018', ends_at: '01-02-2018', enabled: true,
|
||||
description: 'Description of selecting phase',
|
||||
summary: 'This is the summary for selecting phase')
|
||||
phases.valuating.update(starts_at: '10-02-2018', ends_at: '20-02-2018', enabled: false,
|
||||
description: 'Description of valuating phase',
|
||||
summary: 'This is the summary for valuating phase')
|
||||
|
||||
budget.phases.valuating.update(starts_at: '10-02-2018', ends_at: '20-02-2018', enabled: false,
|
||||
description: 'Description of valuating phase',
|
||||
summary: 'This is the summary for valuating phase')
|
||||
phases.publishing_prices.update(starts_at: '21-02-2018', ends_at: '01-03-2018', enabled: false,
|
||||
description: 'Description of publishing prices phase',
|
||||
summary: 'This is the summary for publishing_prices phase')
|
||||
|
||||
budget.phases.publishing_prices.update(starts_at: '21-02-2018', ends_at: '01-03-2018', enabled: false,
|
||||
description: 'Description of publishing prices phase',
|
||||
summary: 'This is the summary for publishing_prices phase')
|
||||
phases.balloting.update(starts_at: '02-03-2018', ends_at: '10-03-2018', enabled: true,
|
||||
description: 'Description of balloting phase',
|
||||
summary: 'This is the summary for balloting phase')
|
||||
|
||||
budget.phases.balloting.update(starts_at: '02-03-2018', ends_at: '10-03-2018', enabled: true,
|
||||
description: 'Description of balloting phase',
|
||||
summary: 'This is the summary for balloting phase')
|
||||
phases.reviewing_ballots.update(starts_at: '11-03-2018', ends_at: '20-03-2018', enabled: false,
|
||||
description: 'Description of reviewing ballots phase',
|
||||
summary: 'This is the summary for reviewing_ballots phase')
|
||||
|
||||
budget.phases.reviewing_ballots.update(starts_at: '11-03-2018', ends_at: '20-03-2018', enabled: false,
|
||||
description: 'Description of reviewing ballots phase',
|
||||
summary: 'This is the summary for reviewing_ballots phase')
|
||||
|
||||
budget.phases.finished.update(starts_at: '21-03-2018', ends_at: '30-03-2018', enabled: true,
|
||||
description: 'Description of finished phase',
|
||||
summary: 'This is the summary for finished phase')
|
||||
phases.finished.update(starts_at: '21-03-2018', ends_at: '30-03-2018', enabled: true,
|
||||
description: 'Description of finished phase',
|
||||
summary: 'This is the summary for finished phase')
|
||||
|
||||
visit budgets_path
|
||||
|
||||
@@ -199,25 +205,11 @@ feature 'Budgets' do
|
||||
end
|
||||
|
||||
context "Listed" do
|
||||
scenario "Not listed to guest users at the public budgets list" do
|
||||
scenario "Not listed at public budgets list" do
|
||||
visit budgets_path
|
||||
|
||||
expect(page).not_to have_content(budget.name)
|
||||
end
|
||||
|
||||
scenario "Not listed to logged users at the public budgets list" do
|
||||
login_as(level_two_user)
|
||||
visit budgets_path
|
||||
|
||||
expect(page).not_to have_content(budget.name)
|
||||
end
|
||||
|
||||
scenario "Is listed to admins at the public budgets list" do
|
||||
login_as(admin)
|
||||
visit budgets_path
|
||||
|
||||
expect(page).to have_content(budget.name)
|
||||
end
|
||||
end
|
||||
|
||||
context "Shown" do
|
||||
@@ -269,7 +261,7 @@ feature 'Budgets' do
|
||||
scenario "user not logged in" do
|
||||
visit budget_path(budget)
|
||||
|
||||
expect(page).to have_content "To create a new budget investment you must sign in or sign up."
|
||||
expect(page).to have_content "To create a new budget investment you must sign in or sign up"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user