displays unfeasible budgets link from home

This commit is contained in:
rgarcia
2017-01-16 03:09:08 +01:00
parent 0ef7afa82f
commit 5f7269a070
6 changed files with 60 additions and 21 deletions

View File

@@ -2,7 +2,6 @@ class BudgetsController < ApplicationController
include FeatureFlags include FeatureFlags
feature_flag :budgets feature_flag :budgets
load_and_authorize_resource load_and_authorize_resource
respond_to :html, :js respond_to :html, :js

View File

@@ -7,6 +7,12 @@
</div> </div>
</div> </div>
<div class="row margin-top">
<% if params[:unfeasible] %>
Propuestas inviables
<% end %>
</div>
<div class="row margin-top"> <div class="row margin-top">
<div id="select-district" class="small-12 medium-7 column select-district"> <div id="select-district" class="small-12 medium-7 column select-district">
<div class="row"> <div class="row">
@@ -16,7 +22,8 @@
<span id="<%= dom_id(heading) %>" <span id="<%= dom_id(heading) %>"
class="<%= css_for_ballot_heading(heading) %>"> class="<%= css_for_ballot_heading(heading) %>">
<%= link_to heading.name, <%= link_to heading.name,
budget_investments_path(heading_id: heading.id), budget_investments_path(heading_id: heading.id,
unfeasible: params[:unfeasible]),
data: { no_turbolink: true } %><br> data: { no_turbolink: true } %><br>
</span> </span>
<% end %> <% end %>
@@ -29,3 +36,10 @@
<%= image_tag "map.jpg" %> <%= image_tag "map.jpg" %>
</div> </div>
</div> </div>
<% if params[:unfeasible].blank? %>
<div class="row margin-top">
<%= link_to t("budgets.investments.index.sidebar.unfeasible"),
budget_path(@budget, unfeasible: 1) %>
</div>
<% end %>

View File

@@ -4,7 +4,7 @@
<div class="row"> <div class="row">
<div class="small-12 column"> <div class="small-12 column">
<%= back_link_to budget_group_path(@budget, @heading.group) %> <%= back_link_to budget_group_path(@budget, @heading.group, unfeasible: params[:unfeasible]) %>
<% if can? :show, @ballot %> <% if can? :show, @ballot %>
<%= link_to t("budgets.investments.header.check_ballot"), <%= link_to t("budgets.investments.header.check_ballot"),

View File

@@ -15,7 +15,6 @@
<%= render "shared/tag_cloud", taggable: 'budget/investment' %> <%= render "shared/tag_cloud", taggable: 'budget/investment' %>
<%= render 'budgets/investments/categories' %> <%= render 'budgets/investments/categories' %>
<%= render 'budgets/investments/feasibility_link' %>
<% if @heading && can?(:show, @ballot) %> <% if @heading && can?(:show, @ballot) %>

View File

@@ -41,6 +41,9 @@
<table class="table-fixed"> <table class="table-fixed">
<thead> <thead>
<th><%= t('budgets.show.group') %></th> <th><%= t('budgets.show.group') %></th>
<% if params[:unfeasible] %>
Propuestas inviables
<% end %>
</thead> </thead>
<tbody> <tbody>
<% @budget.groups.each do |group| %> <% @budget.groups.each do |group| %>
@@ -48,10 +51,14 @@
<td> <td>
<% if group.headings.count == 1 %> <% if group.headings.count == 1 %>
<%= link_to group.name, <%= link_to group.name,
budget_investments_path(@budget, heading_id: group.headings.first.id), budget_investments_path(@budget,
heading_id: group.headings.first.id,
unfeasible: params[:unfeasible]),
data: { no_turbolink: true } %> data: { no_turbolink: true } %>
<% else %> <% else %>
<%= link_to group.name, budget_group_path(@budget, group) %> <%= link_to group.name,
budget_group_path(@budget, group,
unfeasible: params[:unfeasible]) %>
<% end %> <% end %>
<br> <br>
</td> </td>
@@ -61,3 +68,10 @@
</table> </table>
</div> </div>
</div> </div>
<% unless params[:unfeasible] %>
<div class="row margin-top">
<%= link_to t("budgets.investments.index.sidebar.unfeasible"),
budget_path(@budget, unfeasible: 1) %>
</div>
<% end %>

View File

@@ -23,21 +23,6 @@ feature 'Budget Investments' do
end end
end end
scenario 'Feasibility links' do
visit budget_investments_path(budget, heading_id: heading.id)
expect(page).to_not have_content('Feasible projects')
within('#sidebar') do
click_link 'Unfeasible projects'
end
expect(page).to have_current_path(budget_investments_path(budget, heading_id: heading.id, unfeasible: 1))
within('#sidebar') do
click_link 'Feasible projects'
end
expect(page).to have_current_path(budget_investments_path(budget, heading_id: heading.id, unfeasible: nil))
end
context("Search") do context("Search") do
scenario 'Search by text' do scenario 'Search by text' do
@@ -82,6 +67,34 @@ feature 'Budget Investments' do
expect(page).to_not have_content(investment4.title) expect(page).to_not have_content(investment4.title)
end end
end end
scenario "by unfeasibilty link for group with one heading", :focus do
group = create(:budget_group, name: 'All City', budget: budget)
heading = create(:budget_heading, name: "Madrid", group: group)
visit budget_path(budget)
click_link 'Unfeasible projects'
click_link "All City"
expected_path = budget_investments_path(budget, heading_id: heading.id, unfeasible: 1)
expect(page).to have_current_path(expected_path)
end
scenario "by unfeasibilty link for group with many headings", :focus do
group = create(:budget_group, name: 'Districts', budget: budget)
heading1 = create(:budget_heading, name: 'Carabanchel', group: group)
heading2 = create(:budget_heading, name: 'Barajas', group: group)
visit budget_path(budget)
click_link 'Unfeasible projects'
click_link 'Districts'
click_link 'Carabanchel'
expected_path = budget_investments_path(budget, heading_id: heading1.id, unfeasible: 1)
expect(page).to have_current_path(expected_path)
end
end end
context("Orders") do context("Orders") do