Add dynamic texts to investment image button.
This commit is contained in:
@@ -5,13 +5,16 @@
|
|||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<span class="note-marked">
|
<span class="note-marked">
|
||||||
<%= t("budgets.investments.edit_image.note", title: @investment.title) %></p>
|
<% note_key = @investment.image.exists? ? "edit_note" : "add_note" %>
|
||||||
|
<%= t("budgets.investments.edit_image.#{note_key}", title: @investment.title) %></p>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% if @investment.image.exists? %>
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= image_tag @investment.image.url(:large) %>
|
<%= image_tag @investment.image.url(:large) %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.file_field :image, accept: 'image/jpeg' %>
|
<%= f.file_field :image, accept: 'image/jpeg' %>
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if author_of?(investment, current_user) || (current_user && current_user.administrator?) %>
|
<% 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),
|
edit_image_budget_investment_path(investment.budget, investment),
|
||||||
class: 'button hollow float-right' %>
|
class: 'button hollow float-right' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -45,7 +46,7 @@
|
|||||||
|
|
||||||
<!-- TODO: ROCK&ROR: Markup rework accordingly to mockup definition -->
|
<!-- TODO: ROCK&ROR: Markup rework accordingly to mockup definition -->
|
||||||
<% if investment.image.exists? %>
|
<% if investment.image.exists? %>
|
||||||
<%= image_tag investment.image.url(:medium),
|
<%= image_tag investment.image.url(:large),
|
||||||
title: investment.image_title,
|
title: investment.image_title,
|
||||||
alt: investment.image_title %>
|
alt: investment.image_title %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -109,9 +109,11 @@ en:
|
|||||||
no_milestones: Don't have defined milestones
|
no_milestones: Don't have defined milestones
|
||||||
milestone_publish_date: "Published %{publish_date}"
|
milestone_publish_date: "Published %{publish_date}"
|
||||||
edit_image: Edit image
|
edit_image: Edit image
|
||||||
|
add_image: Add image
|
||||||
edit_image:
|
edit_image:
|
||||||
title: Change your project 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:
|
form:
|
||||||
image_title: Image title
|
image_title: Image title
|
||||||
submit_button: Save image
|
submit_button: Save image
|
||||||
|
|||||||
@@ -109,9 +109,11 @@ es:
|
|||||||
no_milestones: No hay hitos definidos
|
no_milestones: No hay hitos definidos
|
||||||
milestone_publish_date: "Publicado el %{publish_date}"
|
milestone_publish_date: "Publicado el %{publish_date}"
|
||||||
edit_image: Editar imagen
|
edit_image: Editar imagen
|
||||||
|
add_image: Añadir imagen
|
||||||
edit_image:
|
edit_image:
|
||||||
title: Cambia la imagen de tu proyecto
|
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:
|
form:
|
||||||
image_title: 'Título de la imagen'
|
image_title: 'Título de la imagen'
|
||||||
submit_button: Guardar imagen
|
submit_button: Guardar imagen
|
||||||
|
|||||||
@@ -387,7 +387,24 @@ feature 'Budget Investments' do
|
|||||||
expect(page).to have_link "Go back", href: budget_investments_path(budget, heading_id: investment.heading)
|
expect(page).to have_link "Go back", href: budget_investments_path(budget, heading_id: investment.heading)
|
||||||
end
|
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
|
scenario "should not be shown for anonymous users" do
|
||||||
investment = create(:budget_investment, heading: heading)
|
investment = create(:budget_investment, heading: heading)
|
||||||
visit budget_investment_path(budget, investment)
|
visit budget_investment_path(budget, investment)
|
||||||
@@ -407,7 +424,7 @@ feature 'Budget Investments' do
|
|||||||
login_as(author)
|
login_as(author)
|
||||||
visit budget_investment_path(budget, investment)
|
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
|
||||||
|
|
||||||
scenario "should be shown when current user is administrator" do
|
scenario "should be shown when current user is administrator" do
|
||||||
@@ -416,7 +433,7 @@ feature 'Budget Investments' do
|
|||||||
login_as(administrator)
|
login_as(administrator)
|
||||||
visit budget_investment_path(budget, investment)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -592,12 +609,12 @@ feature 'Budget Investments' do
|
|||||||
context "Destroy" do
|
context "Destroy" do
|
||||||
|
|
||||||
scenario "Admin cannot destroy budget investments" do
|
scenario "Admin cannot destroy budget investments" do
|
||||||
administrator = create(:administrator).user
|
admin = create(:administrator)
|
||||||
user = create(:user, :level_two)
|
user = create(:user, :level_two)
|
||||||
investment = create(:budget_investment, heading: heading, author: user)
|
investment = create(:budget_investment, heading: heading, author: user)
|
||||||
|
|
||||||
login_as(administrator)
|
login_as(admin.user)
|
||||||
visit user_path(administrator)
|
visit user_path(user)
|
||||||
|
|
||||||
within("#budget_investment_#{investment.id}") do
|
within("#budget_investment_#{investment.id}") do
|
||||||
expect(page).to_not have_link "Delete"
|
expect(page).to_not have_link "Delete"
|
||||||
|
|||||||
Reference in New Issue
Block a user