diff --git a/app/views/budgets/investments/_image_form.html.erb b/app/views/budgets/investments/_image_form.html.erb
index 60c86e513..5be91a466 100644
--- a/app/views/budgets/investments/_image_form.html.erb
+++ b/app/views/budgets/investments/_image_form.html.erb
@@ -5,13 +5,16 @@
- <%= t("budgets.investments.edit_image.note", title: @investment.title) %>
+ <% note_key = @investment.image.exists? ? "edit_note" : "add_note" %>
+ <%= t("budgets.investments.edit_image.#{note_key}", title: @investment.title) %>
-
- <%= image_tag @investment.image.url(:large) %>
-
+ <% if @investment.image.exists? %>
+
+ <%= image_tag @investment.image.url(:large) %>
+
+ <% end %>
<%= f.file_field :image, accept: 'image/jpeg' %>
diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb
index aca95d903..a71fc099d 100644
--- a/app/views/budgets/investments/_investment_show.html.erb
+++ b/app/views/budgets/investments/_investment_show.html.erb
@@ -11,7 +11,8 @@
<% end %>
<% if author_of?(investment, current_user) || (current_user && current_user.administrator?) %>
- <%= link_to t("budgets.investments.show.edit_image"),
+ <% button_text = investment.image.exists? ? t("budgets.investments.show.edit_image") : t("budgets.investments.show.add_image") %>
+ <%= link_to button_text,
edit_image_budget_investment_path(investment.budget, investment),
class: 'button hollow float-right' %>
<% end %>
@@ -45,7 +46,7 @@
<% if investment.image.exists? %>
- <%= image_tag investment.image.url(:medium),
+ <%= image_tag investment.image.url(:large),
title: investment.image_title,
alt: investment.image_title %>
<% end %>
diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml
index 45c6e93e8..a1413eb80 100644
--- a/config/locales/en/budgets.yml
+++ b/config/locales/en/budgets.yml
@@ -109,9 +109,11 @@ en:
no_milestones: Don't have defined milestones
milestone_publish_date: "Published %{publish_date}"
edit_image: Edit image
+ add_image: Add image
edit_image:
title: Change your project image
- note: 'You are changing investment project image of: %{title}'
+ add_note: 'Add an image to your investment project: %{title}'
+ edit_note: 'You are changing investment project image of: %{title}'
form:
image_title: Image title
submit_button: Save image
diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml
index 5d095c983..be281e35c 100644
--- a/config/locales/es/budgets.yml
+++ b/config/locales/es/budgets.yml
@@ -109,9 +109,11 @@ es:
no_milestones: No hay hitos definidos
milestone_publish_date: "Publicado el %{publish_date}"
edit_image: Editar imagen
+ add_image: Añadir imagen
edit_image:
title: Cambia la imagen de tu proyecto
- note: 'Estas cambiando la imagen del proyecto de inversión: %{title}'
+ add_note: 'Añade una imagen al proyecto de inversión: %{title}'
+ edit_note: 'Estas cambiando la imagen del proyecto de inversión: %{title}'
form:
image_title: 'Título de la imagen'
submit_button: Guardar imagen
diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb
index 1cb048e42..621fdc604 100644
--- a/spec/features/budgets/investments_spec.rb
+++ b/spec/features/budgets/investments_spec.rb
@@ -387,7 +387,24 @@ feature 'Budget Investments' do
expect(page).to have_link "Go back", href: budget_investments_path(budget, heading_id: investment.heading)
end
- context "Show edit image button" do
+ context "Show investment image button" do
+
+ scenario "should show add text when investment has not image" do
+ investment = create(:budget_investment, heading: heading, author: author)
+ login_as(author)
+ visit budget_investment_path(budget, investment)
+
+ expect(page).to have_link "Add image"
+ end
+
+ scenario "should show edit text when investment has already an image" do
+ investment = create(:budget_investment, :with_descriptive_image, heading: heading, author: author)
+ login_as(author)
+ visit budget_investment_path(budget, investment)
+
+ expect(page).to have_link "Edit image"
+ end
+
scenario "should not be shown for anonymous users" do
investment = create(:budget_investment, heading: heading)
visit budget_investment_path(budget, investment)
@@ -407,7 +424,7 @@ feature 'Budget Investments' do
login_as(author)
visit budget_investment_path(budget, investment)
- expect(page).to have_link "Edit image", href: edit_image_budget_investment_path(budget, investment)
+ expect(page).to have_link "Add image", href: edit_image_budget_investment_path(budget, investment)
end
scenario "should be shown when current user is administrator" do
@@ -416,7 +433,7 @@ feature 'Budget Investments' do
login_as(administrator)
visit budget_investment_path(budget, investment)
- expect(page).to have_link "Edit image", href: edit_image_budget_investment_path(budget, investment)
+ expect(page).to have_link "Add image", href: edit_image_budget_investment_path(budget, investment)
end
end
@@ -592,12 +609,12 @@ feature 'Budget Investments' do
context "Destroy" do
scenario "Admin cannot destroy budget investments" do
- administrator = create(:administrator).user
+ admin = create(:administrator)
user = create(:user, :level_two)
investment = create(:budget_investment, heading: heading, author: user)
- login_as(administrator)
- visit user_path(administrator)
+ login_as(admin.user)
+ visit user_path(user)
within("#budget_investment_#{investment.id}") do
expect(page).to_not have_link "Delete"