diff --git a/app/helpers/budget_investments_helper.rb b/app/helpers/budget_investments_helper.rb
index 1e6d8405e..68e4435a3 100644
--- a/app/helpers/budget_investments_helper.rb
+++ b/app/helpers/budget_investments_helper.rb
@@ -49,4 +49,8 @@ module BudgetInvestmentsHelper
def investments_secondary_view
investments_current_view == "default" ? "minimal" : "default"
end
+
+ def show_author_actions?(investment)
+ can?(:edit, investment) || can_destroy_image?(investment)
+ end
end
diff --git a/app/views/budgets/investments/_author_actions.html.erb b/app/views/budgets/investments/_author_actions.html.erb
index 20faa2af5..92a4aa863 100644
--- a/app/views/budgets/investments/_author_actions.html.erb
+++ b/app/views/budgets/investments/_author_actions.html.erb
@@ -1,12 +1,18 @@
-<% if can_destroy_image?(investment) %>
+<% if show_author_actions?(investment) %>
<%= t("budgets.investments.show.author") %>
<% end %>
diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb
index 3e432ad5d..8e87b2aad 100644
--- a/spec/features/budgets/investments_spec.rb
+++ b/spec/features/budgets/investments_spec.rb
@@ -1957,5 +1957,48 @@ describe "Budget Investments" do
expect(page).to have_css(".map-icon", count: 3, visible: false)
end
end
+
+ context "Author actions section" do
+ scenario "Is not shown if investment is not editable or does not have an image" do
+ budget.update!(phase: "reviewing")
+ investment = create(:budget_investment, heading: heading, author: author)
+
+ login_as(author)
+ visit budget_investment_path(budget, investment)
+
+ within("aside") do
+ expect(page).not_to have_content "Author"
+ expect(page).not_to have_link "Edit"
+ expect(page).not_to have_link "Remove image"
+ end
+ end
+
+ scenario "Contains edit button in the accepting phase" do
+ investment = create(:budget_investment, heading: heading, author: author)
+
+ login_as(author)
+ visit budget_investment_path(budget, investment)
+
+ within("aside") do
+ expect(page).to have_content "Author"
+ expect(page).to have_link "Edit"
+ expect(page).not_to have_link "Remove image"
+ end
+ end
+
+ scenario "Contains remove image button in phases different from accepting" do
+ budget.update!(phase: "reviewing")
+ investment = create(:budget_investment, :with_image, heading: heading, author: author)
+
+ login_as(author)
+ visit budget_investment_path(budget, investment)
+
+ within("aside") do
+ expect(page).to have_content "Author"
+ expect(page).not_to have_link "Edit"
+ expect(page).to have_link "Remove image"
+ end
+ end
+ end
end
end