Restrict compatilibility edit on admin investment form
Why: * A non-winner but compatible investment shouldn't be marked as incompatible How: * Show incompatilibility checkbox only if investment is winner or incompatible
This commit is contained in:
@@ -63,6 +63,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="row margin-top">
|
<div class="row margin-top">
|
||||||
|
<% if @investment.incompatible? || @investment.winner? %>
|
||||||
<div class="small-12 medium-3 column">
|
<div class="small-12 medium-3 column">
|
||||||
<h2 id="incompatible"><%= t("admin.budget_investments.edit.compatibility") %></h2>
|
<h2 id="incompatible"><%= t("admin.budget_investments.edit.compatibility") %></h2>
|
||||||
<%= f.label :incompatible do %>
|
<%= f.label :incompatible do %>
|
||||||
@@ -70,6 +71,7 @@
|
|||||||
<span class="checkbox"><%= t("admin.budget_investments.edit.mark_as_incompatible") %></span>
|
<span class="checkbox"><%= t("admin.budget_investments.edit.mark_as_incompatible") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
<div class="small-12 medium-3 column float-left">
|
<div class="small-12 medium-3 column float-left">
|
||||||
<h2 id="selected"><%= t("admin.budget_investments.edit.selection") %></h2>
|
<h2 id="selected"><%= t("admin.budget_investments.edit.selection") %></h2>
|
||||||
<%= f.label :selected do %>
|
<%= f.label :selected do %>
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ feature 'Admin budget investments' do
|
|||||||
context "Edit" do
|
context "Edit" do
|
||||||
|
|
||||||
scenario "Change title, incompatible, description or heading" do
|
scenario "Change title, incompatible, description or heading" do
|
||||||
budget_investment = create(:budget_investment, :selected)
|
budget_investment = create(:budget_investment, :incompatible)
|
||||||
create(:budget_heading, group: budget_investment.group, name: "Barbate")
|
create(:budget_heading, group: budget_investment.group, name: "Barbate")
|
||||||
|
|
||||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||||
@@ -321,7 +321,7 @@ feature 'Admin budget investments' do
|
|||||||
fill_in 'budget_investment_title', with: 'Potatoes'
|
fill_in 'budget_investment_title', with: 'Potatoes'
|
||||||
fill_in 'budget_investment_description', with: 'Carrots'
|
fill_in 'budget_investment_description', with: 'Carrots'
|
||||||
select "#{budget_investment.group.name}: Barbate", from: 'budget_investment[heading_id]'
|
select "#{budget_investment.group.name}: Barbate", from: 'budget_investment[heading_id]'
|
||||||
check "budget_investment_incompatible"
|
uncheck "budget_investment_incompatible"
|
||||||
check "budget_investment_selected"
|
check "budget_investment_selected"
|
||||||
|
|
||||||
click_button 'Update'
|
click_button 'Update'
|
||||||
@@ -329,10 +329,21 @@ feature 'Admin budget investments' do
|
|||||||
expect(page).to have_content 'Potatoes'
|
expect(page).to have_content 'Potatoes'
|
||||||
expect(page).to have_content 'Carrots'
|
expect(page).to have_content 'Carrots'
|
||||||
expect(page).to have_content 'Barbate'
|
expect(page).to have_content 'Barbate'
|
||||||
expect(page).to have_content 'Incompatible'
|
expect(page).to have_content 'Compatibility: Compatible'
|
||||||
expect(page).to have_content 'Selected'
|
expect(page).to have_content 'Selected'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Compatible non-winner can't edit incompatibility" do
|
||||||
|
budget_investment = create(:budget_investment, :selected)
|
||||||
|
create(:budget_heading, group: budget_investment.group, name: "Tetuan")
|
||||||
|
|
||||||
|
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||||
|
click_link 'Edit'
|
||||||
|
|
||||||
|
expect(page).not_to have_content 'Compatibility'
|
||||||
|
expect(page).not_to have_content 'Mark as incompatible'
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Add administrator" do
|
scenario "Add administrator" do
|
||||||
budget_investment = create(:budget_investment)
|
budget_investment = create(:budget_investment)
|
||||||
administrator = create(:administrator, user: create(:user, username: 'Marta', email: 'marta@admins.org'))
|
administrator = create(:administrator, user: create(:user, username: 'Marta', email: 'marta@admins.org'))
|
||||||
|
|||||||
Reference in New Issue
Block a user