New phase "Information" added and UI modified to not show the links.

Specs to test the functionality added.
This commit is contained in:
iagirre
2018-01-19 11:51:18 +01:00
parent 8f3df54453
commit 846898f3ec
10 changed files with 101 additions and 50 deletions

View File

@@ -1239,7 +1239,8 @@
text-decoration: none;
}
a {
a,
div {
display: block;
padding: $line-height / 2;

View File

@@ -21,6 +21,7 @@ class Budget < ActiveRecord::Base
after_create :generate_phases
scope :drafting, -> { where(phase: "drafting") }
scope :informing, -> { where(phase: "informing") }
scope :accepting, -> { where(phase: "accepting") }
scope :reviewing, -> { where(phase: "reviewing") }
scope :selecting, -> { where(phase: "selecting") }
@@ -64,6 +65,10 @@ class Budget < ActiveRecord::Base
phase == "drafting"
end
def informing?
phase == "informing"
end
def accepting?
phase == "accepting"
end

View File

@@ -1,6 +1,6 @@
class Budget
class Phase < ActiveRecord::Base
PHASE_KINDS = %w(drafting accepting reviewing selecting valuating publishing_prices balloting
PHASE_KINDS = %w(drafting informing accepting reviewing selecting valuating publishing_prices balloting
reviewing_ballots finished).freeze
PUBLISHED_PRICES_PHASES = %w(publishing_prices balloting reviewing_ballots finished).freeze
SUMMARY_MAX_LENGTH = 1000
@@ -26,6 +26,7 @@ class Budget
scope :enabled, -> { where(enabled: true) }
scope :published, -> { enabled.where.not(kind: 'drafting') }
scope :drafting, -> { find_by_kind('drafting') }
scope :informing, -> { find_by_kind('informing') }
scope :accepting, -> { find_by_kind('accepting')}
scope :reviewing, -> { find_by_kind('reviewing')}
scope :selecting, -> { find_by_kind('selecting')}

View File

@@ -67,9 +67,16 @@
<ul class="no-bullet">
<% group.headings.each do |heading| %>
<li class="heading small-12 medium-4 large-2">
<%= link_to budget_investments_path(@budget.id, heading_id: heading.id) do %>
<%= heading.name %>
<span><%= @budget.formatted_heading_price(heading) %></span>
<% unless @budget.informing? %>
<%= link_to budget_investments_path(@budget.id, heading_id: heading.id) do %>
<%= heading.name %>
<span><%= @budget.formatted_heading_price(heading) %></span>
<% end %>
<% else %>
<div>
<%= heading.name %>
<span><%= @budget.formatted_heading_price(heading) %></span>
</div>
<% end %>
</li>
<% end %>
@@ -77,22 +84,24 @@
<% end %>
</div>
<div id="map">
<h3><%= t("budgets.index.map") %></h3>
<%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %>
</div>
<% unless @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 %>
<small><%= t("budgets.index.investment_proyects") %></small>
<% end %><br>
<%= link_to budget_investments_path(budget_id: @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 %>
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
<% end %>
</p>
<p>
<%= link_to budget_investments_path(@budget.id) do %>
<small><%= t("budgets.index.investment_proyects") %></small>
<% end %><br>
<%= link_to budget_investments_path(budget_id: @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 %>
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
<% end %>
</p>
<% end %>
<div id="all_phases">
<h2><%= t("budgets.index.all_phases") %></h2>

View File

@@ -30,6 +30,7 @@ en:
unselected: See investments not selected for balloting phase
phase:
drafting: Draft (Not visible to the public)
informing: Informating
accepting: Accepting projects
reviewing: Reviewing projects
selecting: Selecting projects

View File

@@ -30,6 +30,7 @@ es:
unselected: Ver las propuestas no seleccionadas para la votación final
phase:
drafting: Borrador (No visible para el público)
informing: Información
accepting: Presentación de proyectos
reviewing: Revisión inicial de proyectos
selecting: Fase de apoyos

View File

@@ -0,0 +1,5 @@
class AddDescriptionInformingToBudgets < ActiveRecord::Migration
def change
add_column :budgets, :description_informing, :text
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180112123641) do
ActiveRecord::Schema.define(version: 20180119073228) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -219,6 +219,7 @@ ActiveRecord::Schema.define(version: 20180112123641) do
t.string "slug"
t.text "description_drafting"
t.text "description_publishing_prices"
t.text "description_informing"
end
create_table "campaigns", force: :cascade do |t|

View File

@@ -224,6 +224,7 @@ FactoryBot.define do
currency_symbol ""
phase 'accepting'
description_drafting "This budget is drafting"
description_informing "This budget is informing"
description_accepting "This budget is accepting"
description_reviewing "This budget is reviewing"
description_selecting "This budget is selecting"
@@ -237,6 +238,10 @@ FactoryBot.define do
phase 'drafting'
end
trait :informing do
phase 'informing'
end
trait :accepting do
phase 'accepting'
end

View File

@@ -5,43 +5,65 @@ feature 'Budgets' do
let(:budget) { create(:budget) }
let(:level_two_user) { create(:user, :level_two) }
scenario 'Index' do
budgets = create_list(:budget, 3)
last_budget = budgets.last
group1 = create(:budget_group, budget: last_budget)
group2 = create(:budget_group, budget: last_budget)
context 'Index' do
let(:budgets) { create_list(:budget, 3) }
let(:last_budget) { budgets.last }
heading1 = create(:budget_heading, group: group1)
heading2 = create(:budget_heading, group: group2)
scenario 'Show normal index with links' do
group1 = create(:budget_group, budget: last_budget)
group2 = create(:budget_group, budget: last_budget)
visit budgets_path
heading1 = create(:budget_heading, group: group1)
heading2 = create(:budget_heading, group: group2)
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("Actual phase")
expect(page).to have_content("Accepting projects")
expect(page).to have_link 'Help with participatory budgets'
expect(page).to have_link 'See all phases'
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("Actual phase (2/9)")
expect(page).to have_content("Accepting projects")
expect(page).to have_link 'Help about participatory budgets'
expect(page).to have_link 'See all phases'
end
last_budget.update_attributes(phase: 'publishing_prices')
visit budgets_path
within("#budget_heading") do
expect(page).to have_content("Actual phase (6/9)")
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 budgets.first.name
expect(page).to have_content budgets[2].name
end
end
last_budget.update_attributes(phase: 'publishing_prices')
visit budgets_path
scenario 'Show informing index without links' do
last_budget.update_attributes(phase: 'informing')
group = create(:budget_group, budget: last_budget)
heading = create(:budget_heading, group: group)
within("#budget_heading") do
expect(page).to have_content("Actual phase")
end
visit budgets_path
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)
within('#budget_info') do
expect(page).not_to have_link "#{heading.name} €1,000,000"
expect(page).to have_content "#{heading.name} €1,000,000"
expect(page).to have_content budgets.first.name
expect(page).to have_content budgets[2].name
expect(page).not_to have_link "List of all investment projects"
expect(page).not_to have_link "List of all unfeasible investment projects"
expect(page).not_to have_link "List of all investment projects not selected for balloting"
expect(page).not_to have_css('div#map')
end
end
end