Merge branch 'master' into aperez-dates-for-milestones
This commit is contained in:
@@ -336,7 +336,8 @@
|
||||
.draft-panels,
|
||||
.debate-questions,
|
||||
.communities-show,
|
||||
.topic-show {
|
||||
.topic-show,
|
||||
.milestone-content {
|
||||
|
||||
p {
|
||||
word-wrap: break-word;
|
||||
|
||||
@@ -44,7 +44,8 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
|
||||
def milestone_params
|
||||
params.require(:budget_investment_milestone)
|
||||
.permit(:title, :description, :publication_date, :budget_investment_id,
|
||||
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
|
||||
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]),
|
||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
|
||||
end
|
||||
|
||||
def load_budget_investment
|
||||
|
||||
@@ -2,6 +2,10 @@ class Budget
|
||||
class Investment
|
||||
class Milestone < ActiveRecord::Base
|
||||
include Imageable
|
||||
include Documentable
|
||||
documentable max_documents_allowed: 3,
|
||||
max_file_size: 3.megabytes,
|
||||
accepted_content_types: [ "application/pdf" ]
|
||||
|
||||
belongs_to :investment
|
||||
|
||||
|
||||
@@ -8,5 +8,10 @@
|
||||
|
||||
<%= render 'images/admin_image', imageable: @milestone, f: f %>
|
||||
|
||||
<hr>
|
||||
<div class="documents">
|
||||
<%= render 'documents/nested_documents', documentable: @milestone, f: f %>
|
||||
</div>
|
||||
|
||||
<%= f.submit nil, class: "button success" %>
|
||||
<% end %>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<th><%= t("admin.milestones.index.table_description") %></th>
|
||||
<th><%= t("admin.milestones.index.table_publication_date") %></th>
|
||||
<th><%= t("admin.milestones.index.image") %></th>
|
||||
<th><%= t("admin.milestones.index.documents") %></th>
|
||||
<th><%= t("admin.milestones.index.table_actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -29,6 +30,16 @@
|
||||
milestone.image_url(:large),
|
||||
target: :_blank if milestone.image.present? %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<% if milestone.documents.present? %>
|
||||
<% milestone.documents.each do |document| %>
|
||||
<%= link_to document.title,
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow" %><br>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("admin.milestones.index.delete"),
|
||||
admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget,
|
||||
|
||||
@@ -20,6 +20,20 @@
|
||||
<% end %>
|
||||
<%= image_tag(milestone.image_url(:large), { alt: milestone.image.title, class: "margin", id: "image_#{milestone.id}" }) if milestone.image.present? %>
|
||||
<p><%= milestone.description %></p>
|
||||
<% if milestone.documents.present? %>
|
||||
<div class="document-link text-center">
|
||||
<p>
|
||||
<span class="icon-document"></span>
|
||||
<strong><%= t('proposals.show.title_external_url') %></strong>
|
||||
</p>
|
||||
<% milestone.documents.each do |document| %>
|
||||
<%= link_to document.title,
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow" %><br>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
@@ -199,6 +199,7 @@ en:
|
||||
no_milestones: "Don't have defined milestones"
|
||||
image: "Image"
|
||||
show_image: "Show image"
|
||||
documents: "Documents"
|
||||
new:
|
||||
creating: Create milestone
|
||||
edit:
|
||||
|
||||
@@ -199,6 +199,7 @@ es:
|
||||
no_milestones: "No hay hitos definidos"
|
||||
image: "Imagen"
|
||||
show_image: "Ver imagen"
|
||||
documents: "Documentos"
|
||||
new:
|
||||
creating: Crear hito
|
||||
edit:
|
||||
|
||||
@@ -12,6 +12,8 @@ feature 'Admin budget investment milestones' do
|
||||
context "Index" do
|
||||
scenario 'Displaying milestones' do
|
||||
milestone = create(:budget_investment_milestone, investment: @investment)
|
||||
create(:image, imageable: milestone)
|
||||
document = create(:document, documentable: milestone)
|
||||
|
||||
visit admin_budget_budget_investment_path(@investment.budget, @investment)
|
||||
|
||||
@@ -19,6 +21,8 @@ feature 'Admin budget investment milestones' do
|
||||
expect(page).to have_content(milestone.title)
|
||||
expect(page).to have_content(milestone.id)
|
||||
expect(page).to have_content(milestone.publication_date.to_date)
|
||||
expect(page).to have_link 'Show image'
|
||||
expect(page).to have_link document.title
|
||||
end
|
||||
|
||||
scenario 'Displaying no_milestones text' do
|
||||
@@ -63,11 +67,13 @@ feature 'Admin budget investment milestones' do
|
||||
end
|
||||
|
||||
context "Edit" do
|
||||
scenario "Change title and description" do
|
||||
scenario "Change title, description and document names" do
|
||||
milestone = create(:budget_investment_milestone, investment: @investment)
|
||||
create(:image, imageable: milestone)
|
||||
document = create(:document, documentable: milestone)
|
||||
|
||||
visit admin_budget_budget_investment_path(@investment.budget, @investment)
|
||||
expect(page).to have_link document.title
|
||||
|
||||
click_link milestone.title
|
||||
|
||||
@@ -76,6 +82,7 @@ feature 'Admin budget investment milestones' do
|
||||
fill_in 'budget_investment_milestone_title', with: 'Changed title'
|
||||
fill_in 'budget_investment_milestone_description', with: 'Changed description'
|
||||
fill_in 'budget_investment_milestone_publication_date', with: Time.zone.today.to_date
|
||||
fill_in 'budget_investment_milestone_documents_attributes_0_title', with: 'New document title'
|
||||
|
||||
click_button 'Update milestone'
|
||||
|
||||
@@ -83,6 +90,7 @@ feature 'Admin budget investment milestones' do
|
||||
expect(page).to have_content 'Changed description'
|
||||
expect(page).to have_content Time.zone.today.to_date
|
||||
expect(page).to have_link 'Show image'
|
||||
expect(page).to have_link 'New document title'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -503,6 +503,7 @@ feature 'Budget Investments' do
|
||||
investment = create(:budget_investment)
|
||||
milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show")
|
||||
image = create(:image, imageable: milestone)
|
||||
document = create(:document, documentable: milestone)
|
||||
|
||||
login_as(user)
|
||||
visit budget_investment_path(budget_id: investment.budget.id, id: investment.id)
|
||||
@@ -514,6 +515,7 @@ feature 'Budget Investments' do
|
||||
expect(page).to have_content(milestone.description)
|
||||
expect(page).to have_content(Time.zone.today.to_date)
|
||||
expect(page.find("#image_#{milestone.id}")['alt']).to have_content image.title
|
||||
expect(page).to have_link document.title
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user