Merge pull request #2386 from wairbut-m2c/2377_show_investment_links_only_on_balloting_or_later
Show investment links only on phase balloting or later
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
module BudgetsHelper
|
module BudgetsHelper
|
||||||
|
|
||||||
|
def show_links_to_budget_investments(budget)
|
||||||
|
['balloting', 'reviewing_ballots', 'finished'].include? budget.phase
|
||||||
|
end
|
||||||
|
|
||||||
def heading_name_and_price_html(heading, budget)
|
def heading_name_and_price_html(heading, budget)
|
||||||
content_tag :div do
|
content_tag :div do
|
||||||
concat(heading.name + ' ')
|
concat(heading.name + ' ')
|
||||||
|
|||||||
@@ -89,15 +89,20 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
<% show_links = show_links_to_budget_investments(current_budget) %>
|
||||||
|
<% if show_links %>
|
||||||
<%= link_to budget_investments_path(current_budget.id) do %>
|
<%= link_to budget_investments_path(current_budget.id) do %>
|
||||||
<small><%= t("budgets.index.investment_proyects") %></small>
|
<small><%= t("budgets.index.investment_proyects") %></small>
|
||||||
<% end %><br>
|
<% end %><br>
|
||||||
|
<% end %>
|
||||||
<%= link_to budget_investments_path(budget_id: current_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>
|
<small><%= t("budgets.index.unfeasible_investment_proyects") %></small>
|
||||||
<% end %><br>
|
<% end %><br>
|
||||||
|
<% if show_links %>
|
||||||
<%= link_to budget_investments_path(budget_id: current_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>
|
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ feature 'Budgets' do
|
|||||||
|
|
||||||
let(:budget) { create(:budget) }
|
let(:budget) { create(:budget) }
|
||||||
let(:level_two_user) { create(:user, :level_two) }
|
let(:level_two_user) { create(:user, :level_two) }
|
||||||
|
let(:allowed_phase_list) { ['balloting', 'reviewing_ballots', 'finished'] }
|
||||||
|
|
||||||
context 'Index' do
|
context 'Index' do
|
||||||
|
|
||||||
@@ -77,6 +78,45 @@ feature 'Budgets' do
|
|||||||
expect(page).not_to have_css('div#map')
|
expect(page).not_to have_css('div#map')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'Show investment links only on balloting or later' do
|
||||||
|
|
||||||
|
budget = create(:budget)
|
||||||
|
group = create(:budget_group, budget: budget)
|
||||||
|
heading = create(:budget_heading, group: group)
|
||||||
|
|
||||||
|
allowed_phase_list.each do |phase|
|
||||||
|
budget.update(phase: phase)
|
||||||
|
|
||||||
|
visit budgets_path
|
||||||
|
|
||||||
|
expect(page).to have_content(I18n.t("budgets.index.investment_proyects"))
|
||||||
|
expect(page).to have_content(I18n.t("budgets.index.unfeasible_investment_proyects"))
|
||||||
|
expect(page).to have_content(I18n.t("budgets.index.not_selected_investment_proyects"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Not show investment links earlier of balloting ' do
|
||||||
|
|
||||||
|
budget = create(:budget)
|
||||||
|
group = create(:budget_group, budget: budget)
|
||||||
|
heading = create(:budget_heading, group: group)
|
||||||
|
phases_without_links = ['drafting','informing']
|
||||||
|
not_allowed_phase_list = Budget::Phase::PHASE_KINDS -
|
||||||
|
phases_without_links -
|
||||||
|
allowed_phase_list
|
||||||
|
|
||||||
|
not_allowed_phase_list.each do |phase|
|
||||||
|
budget.update(phase: phase)
|
||||||
|
|
||||||
|
visit budgets_path
|
||||||
|
|
||||||
|
expect(page).not_to have_content(I18n.t("budgets.index.investment_proyects"))
|
||||||
|
expect(page).to have_content(I18n.t("budgets.index.unfeasible_investment_proyects"))
|
||||||
|
expect(page).not_to have_content(I18n.t("budgets.index.not_selected_investment_proyects"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Index shows only published phases' do
|
scenario 'Index shows only published phases' do
|
||||||
|
|||||||
Reference in New Issue
Block a user