diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb
index 1e21ee706..c33039021 100644
--- a/app/views/admin/budget_investments/edit.html.erb
+++ b/app/views/admin/budget_investments/edit.html.erb
@@ -63,6 +63,7 @@
+ <% if @investment.incompatible? || @investment.winner? %>
<%= t("admin.budget_investments.edit.compatibility") %>
<%= f.label :incompatible do %>
@@ -70,6 +71,7 @@
<%= t("admin.budget_investments.edit.mark_as_incompatible") %>
<% end %>
+ <% end %>
<%= t("admin.budget_investments.edit.selection") %>
<%= f.label :selected do %>
diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb
index 57dedcb54..925f105b0 100644
--- a/spec/features/admin/budget_investments_spec.rb
+++ b/spec/features/admin/budget_investments_spec.rb
@@ -312,7 +312,7 @@ feature 'Admin budget investments' do
context "Edit" 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")
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_description', with: 'Carrots'
select "#{budget_investment.group.name}: Barbate", from: 'budget_investment[heading_id]'
- check "budget_investment_incompatible"
+ uncheck "budget_investment_incompatible"
check "budget_investment_selected"
click_button 'Update'
@@ -329,10 +329,21 @@ feature 'Admin budget investments' do
expect(page).to have_content 'Potatoes'
expect(page).to have_content 'Carrots'
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'
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
budget_investment = create(:budget_investment)
administrator = create(:administrator, user: create(:user, username: 'Marta', email: 'marta@admins.org'))