diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss
index 2152e07a7..6db84ed6f 100644
--- a/app/assets/stylesheets/participation.scss
+++ b/app/assets/stylesheets/participation.scss
@@ -1239,7 +1239,8 @@
text-decoration: none;
}
- a {
+ a,
+ div {
display: block;
padding: $line-height / 2;
diff --git a/app/models/budget.rb b/app/models/budget.rb
index 8457ba1ac..28f37f4bc 100644
--- a/app/models/budget.rb
+++ b/app/models/budget.rb
@@ -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
diff --git a/app/models/budget/phase.rb b/app/models/budget/phase.rb
index e625272d0..704d0b85f 100644
--- a/app/models/budget/phase.rb
+++ b/app/models/budget/phase.rb
@@ -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')}
diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb
index 303c123ec..dccaad5aa 100644
--- a/app/views/budgets/index.html.erb
+++ b/app/views/budgets/index.html.erb
@@ -67,9 +67,16 @@
<% group.headings.each do |heading| %>
-
- <%= link_to budget_investments_path(@budget.id, heading_id: heading.id) do %>
- <%= heading.name %>
- <%= @budget.formatted_heading_price(heading) %>
+ <% unless @budget.informing? %>
+ <%= link_to budget_investments_path(@budget.id, heading_id: heading.id) do %>
+ <%= heading.name %>
+ <%= @budget.formatted_heading_price(heading) %>
+ <% end %>
+ <% else %>
+
+ <%= heading.name %>
+ <%= @budget.formatted_heading_price(heading) %>
+
<% end %>
<% end %>
@@ -77,22 +84,24 @@
<% end %>
-
-
<%= t("budgets.index.map") %>
- <%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %>
-
+ <% unless @budget.informing? %>
+
+
<%= t("budgets.index.map") %>
+ <%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %>
+
-
- <%= link_to budget_investments_path(@budget.id) do %>
- <%= t("budgets.index.investment_proyects") %>
- <% end %>
- <%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unfeasible') do %>
- <%= t("budgets.index.unfeasible_investment_proyects") %>
- <% end %>
- <%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unselected') do %>
- <%= t("budgets.index.not_selected_investment_proyects") %>
- <% end %>
-
+
+ <%= link_to budget_investments_path(@budget.id) do %>
+ <%= t("budgets.index.investment_proyects") %>
+ <% end %>
+ <%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unfeasible') do %>
+ <%= t("budgets.index.unfeasible_investment_proyects") %>
+ <% end %>
+ <%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unselected') do %>
+ <%= t("budgets.index.not_selected_investment_proyects") %>
+ <% end %>
+
+ <% end %>
<%= t("budgets.index.all_phases") %>
diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml
index 6e6481b28..612c628da 100644
--- a/config/locales/en/budgets.yml
+++ b/config/locales/en/budgets.yml
@@ -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
diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml
index 17b1807cd..e5bef2a0d 100644
--- a/config/locales/es/budgets.yml
+++ b/config/locales/es/budgets.yml
@@ -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
diff --git a/db/migrate/20180119073228_add_description_informing_to_budgets.rb b/db/migrate/20180119073228_add_description_informing_to_budgets.rb
new file mode 100644
index 000000000..a6eb173e9
--- /dev/null
+++ b/db/migrate/20180119073228_add_description_informing_to_budgets.rb
@@ -0,0 +1,5 @@
+class AddDescriptionInformingToBudgets < ActiveRecord::Migration
+ def change
+ add_column :budgets, :description_informing, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5cdff80f1..219707f69 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 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|
diff --git a/spec/factories.rb b/spec/factories.rb
index a357a0bb1..f9ffd1ef6 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -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
diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb
index 75348b56e..1665fadce 100644
--- a/spec/features/budgets/budgets_spec.rb
+++ b/spec/features/budgets/budgets_spec.rb
@@ -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