Merge pull request #2223 from wairbut-m2c/iagirre-prevent-edition-if-budget-final-phase
Prevent edition of investments if budget is in the final phase
This commit is contained in:
@@ -56,25 +56,23 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="small">
|
<td class="small">
|
||||||
<% if investment.selected? %>
|
<% if investment.selected? %>
|
||||||
<%= link_to toggle_selection_admin_budget_budget_investment_path(@budget,
|
<%= link_to_unless investment.budget.finished?, t("admin.budget_investments.index.selected"),
|
||||||
|
toggle_selection_admin_budget_budget_investment_path(@budget,
|
||||||
investment,
|
investment,
|
||||||
filter: params[:filter],
|
filter: params[:filter],
|
||||||
page: params[:page]),
|
page: params[:page]),
|
||||||
method: :patch,
|
method: :patch,
|
||||||
remote: true,
|
remote: true,
|
||||||
class: "button small expanded" do %>
|
class: "button small expanded" %>
|
||||||
<%= t("admin.budget_investments.index.selected") %>
|
|
||||||
<% end %>
|
|
||||||
<% elsif investment.feasible? && investment.valuation_finished? %>
|
<% elsif investment.feasible? && investment.valuation_finished? %>
|
||||||
<%= link_to toggle_selection_admin_budget_budget_investment_path(@budget,
|
<%= link_to_unless investment.budget.finished?, t("admin.budget_investments.index.select"),
|
||||||
|
toggle_selection_admin_budget_budget_investment_path(@budget,
|
||||||
investment,
|
investment,
|
||||||
filter: params[:filter],
|
filter: params[:filter],
|
||||||
page: params[:page]),
|
page: params[:page]),
|
||||||
method: :patch,
|
method: :patch,
|
||||||
remote: true,
|
remote: true,
|
||||||
class: "button small hollow expanded" do %>
|
class: "button small hollow expanded" %>
|
||||||
<%= t("admin.budget_investments.index.select") %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% if params[:filter] == 'selected' %>
|
<% if params[:filter] == 'selected' %>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<%= link_to t("admin.budget_investments.show.edit"),
|
<%= link_to t("admin.budget_investments.show.edit"),
|
||||||
edit_admin_budget_budget_investment_path(@budget, @investment,
|
edit_admin_budget_budget_investment_path(@budget, @investment,
|
||||||
Budget::Investment.filter_params(params)) %>
|
Budget::Investment.filter_params(params)) unless @budget.finished? %>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<%= link_to t("admin.budget_investments.show.edit_classification"),
|
<%= link_to t("admin.budget_investments.show.edit_classification"),
|
||||||
edit_admin_budget_budget_investment_path(@budget, @investment,
|
edit_admin_budget_budget_investment_path(@budget, @investment,
|
||||||
{anchor: 'classification'}.merge(Budget::Investment.filter_params(params))) %>
|
{anchor: 'classification'}.merge(Budget::Investment.filter_params(params))) unless @budget.finished? %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
<%= render 'valuation/budget_investments/written_by_valuators' %>
|
<%= render 'valuation/budget_investments/written_by_valuators' %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= link_to t("admin.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %>
|
<%= link_to t("admin.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) unless @budget.finished? %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|||||||
@@ -36,6 +36,21 @@ feature 'Admin budget investments' do
|
|||||||
expect(page).to have_content(budget_investment.total_votes)
|
expect(page).to have_content(budget_investment.total_votes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'If budget is finished do not show "Selected" button' do
|
||||||
|
finished_budget = create(:budget, :finished)
|
||||||
|
budget_investment = create(:budget_investment, budget: finished_budget, cached_votes_up: 77)
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: finished_budget.id)
|
||||||
|
|
||||||
|
within("#budget_investment_#{budget_investment.id}") do
|
||||||
|
expect(page).to have_content(budget_investment.title)
|
||||||
|
expect(page).to have_content(budget_investment.heading.name)
|
||||||
|
expect(page).to have_content(budget_investment.id)
|
||||||
|
expect(page).to have_content(budget_investment.total_votes)
|
||||||
|
expect(page).to_not have_link("Selected")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'Displaying assignments info' do
|
scenario 'Displaying assignments info' do
|
||||||
budget_investment1 = create(:budget_investment, budget: @budget)
|
budget_investment1 = create(:budget_investment, budget: @budget)
|
||||||
budget_investment2 = create(:budget_investment, budget: @budget)
|
budget_investment2 = create(:budget_investment, budget: @budget)
|
||||||
@@ -279,15 +294,19 @@ feature 'Admin budget investments' do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Show' do
|
context 'Show' do
|
||||||
administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))
|
background do
|
||||||
|
@administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Show the investment details' do
|
||||||
valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org'))
|
valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org'))
|
||||||
budget_investment = create(:budget_investment,
|
budget_investment = create(:budget_investment,
|
||||||
price: 1234,
|
price: 1234,
|
||||||
price_first_year: 1000,
|
price_first_year: 1000,
|
||||||
feasibility: "unfeasible",
|
feasibility: "unfeasible",
|
||||||
unfeasibility_explanation: 'It is impossible',
|
unfeasibility_explanation: 'It is impossible',
|
||||||
administrator: administrator)
|
administrator: @administrator)
|
||||||
budget_investment.valuators << valuator
|
budget_investment.valuators << valuator
|
||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||||
@@ -309,6 +328,24 @@ feature 'Admin budget investments' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "If budget is finished, investment cannot be edited" do
|
||||||
|
# Only milestones can be managed
|
||||||
|
|
||||||
|
finished_budget = create(:budget, :finished)
|
||||||
|
budget_investment = create(:budget_investment,
|
||||||
|
budget: finished_budget,
|
||||||
|
administrator: @administrator)
|
||||||
|
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||||
|
|
||||||
|
click_link budget_investment.title
|
||||||
|
|
||||||
|
expect(page).to_not have_link "Edit"
|
||||||
|
expect(page).to_not have_link "Edit classification"
|
||||||
|
expect(page).to_not have_link "Edit dossier"
|
||||||
|
expect(page).to have_link "Create new milestone"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "Edit" do
|
context "Edit" do
|
||||||
|
|
||||||
scenario "Change title, incompatible, description or heading" do
|
scenario "Change title, incompatible, description or heading" do
|
||||||
|
|||||||
Reference in New Issue
Block a user