diff --git a/config/locales/en/documents.yml b/config/locales/en/documents.yml
index d2485df4c..0b36dc79d 100644
--- a/config/locales/en/documents.yml
+++ b/config/locales/en/documents.yml
@@ -4,6 +4,7 @@ en:
no_documents: Don't have uploaded documents
upload_document: Upload document
max_documents_allowed_reached_html: You have reached the maximum number of documents allowed! You have to delete one before you can upload another.
+
form:
title: Documents
attachment_label: Choose document
@@ -11,8 +12,13 @@ en:
delete_button: Remove document
note: "You can upload up to a maximum of %{max_documents_allowed} documents of following content types: %{accepted_content_types}, up to %{max_file_size} MB per file."
add_new_document: Add new document
+
new:
title: Upload document
+ budget_investment:
+ note: 'Add new document to your investment project: %{title}'
+ proposal:
+ note: 'Add new document to your proposal: %{title}'
recommendations_title: File upload tips
recommendation_one_html: You can upload up to a maximum of %{max_documents_allowed} documents.
recommendation_two_html: You can upload %{accepted_content_types} files.
diff --git a/config/locales/es/documents.yml b/config/locales/es/documents.yml
index a0b646ecc..e418b2e3b 100644
--- a/config/locales/es/documents.yml
+++ b/config/locales/es/documents.yml
@@ -4,6 +4,7 @@ es:
no_documents: No hay documentos subidos
upload_document: Subir documento
max_documents_allowed_reached_html: ¡Has alcanzado el número máximo de documentos permitidos! Tienes que eliminar uno antes de poder subir otro.
+
form:
title: Documentos
attachment_label: Selecciona un documento
@@ -11,12 +12,18 @@ es:
delete_button: Eliminar documento
note: "Puedes subir hasta un máximo de %{max_documents_allowed} documentos en los formatos: %{accepted_content_types}, y de hasta %{max_file_size} MB por archivo."
add_new_document: Añadir nuevo documento
+
new:
title: Subir un documento
+ budget_investment:
+ note: 'Añade un documento la propuesta de inversión: %{title}.'
+ proposal:
+ note: 'Añade un documento a la propuesta: %{title}.'
recommendations_title: Consejos para subir archivos
recommendation_one_html: Puedes subir hasta un máximo de %{max_documents_allowed} documentos
recommendation_two_html: Sólo puedes subir archivos %{accepted_content_types}.
recommendation_three_html: Puedes subir archivos de hasta %{max_file_size} MB
+
actions:
create:
notice: "El documento se ha creado correctamente."
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 9f52ccc38..4b1ebe2ba 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -181,6 +181,7 @@ es:
signature_sheet: la hoja de firmas
document: el documento
topic: Tema
+ image: Imagen
geozones:
none: Toda la ciudad
all: Todos los ámbitos de actuación
diff --git a/config/routes.rb b/config/routes.rb
index b8289bae4..3d92db80d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -101,21 +101,16 @@ Rails.application.routes.draw do
resources :follows, only: [:create, :destroy]
resources :documents, only: [:new, :create, :destroy] do
- collection do
- get :new_nested
- delete :destroy_upload
- post :upload
- end
+ get :new_nested, on: :collection
end
resources :images, only: [:new, :create, :destroy] do
- collection do
- get :new_nested
- delete :destroy_upload
- post :upload
- end
+ get :new_nested, on: :collection
end
+ resources :direct_uploads, only: [:create]
+ delete "direct_uploads/destroy", to: "direct_uploads#destroy", as: :direct_upload_destroy
+
resources :stats, only: [:index]
resources :legacy_legislations, only: [:show], path: 'legislations'
diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb
index 23bed5690..52b26a78f 100644
--- a/spec/features/budgets/investments_spec.rb
+++ b/spec/features/budgets/investments_spec.rb
@@ -474,7 +474,7 @@ feature 'Budget Investments' do
"Create Investment",
"Budget Investment created successfully."
- it_behaves_like "documentable", "budget_investment", "budget_investment_path", {"budget_id": "budget_id", "id": "id"}
+ it_behaves_like "documentable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }
it_behaves_like "nested documentable",
"budget_investment",
diff --git a/spec/shared/features/documentable.rb b/spec/shared/features/documentable.rb
index aef4e33c8..839c38c1d 100644
--- a/spec/shared/features/documentable.rb
+++ b/spec/shared/features/documentable.rb
@@ -213,14 +213,24 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
expect(page).to have_selector ".loading-bar.errors"
end
- scenario "Should update document title with attachment original file name after file selection if no title defined by user", :js do
+ scenario "Should update document title with attachment original file name after valid upload if no title defined by user", :js do
login_as documentable.author
visit new_document_path(documentable_type: documentable.class.name,
documentable_id: documentable.id)
attach_document("spec/fixtures/files/empty.pdf", true)
- expect(page).to have_css("input[name='document[title]'][value='empty.pdf']")
+ expect(find("input#document_title").value).to eq("empty.pdf")
+ end
+
+ scenario "Should update document title with attachment original file name after invalid upload if no title defined by user", :js do
+ login_as documentable.author
+ visit new_document_path(documentable_type: documentable.class.name,
+ documentable_id: documentable.id)
+
+ attach_document("spec/fixtures/files/logo_header.png", false)
+
+ expect(find("input#document_title").value).to be_empty
end
scenario "Should not update document title with attachment original file name after file selection when title already defined by user", :js do
@@ -429,8 +439,8 @@ end
def attach_document(path, success = true)
attach_file :document_attachment, path, make_visible: true
if success
- have_css ".loading-bar.complete"
+ expect(page).to have_css ".loading-bar.complete"
else
- have_css ".loading-bar.errors"
+ expect(page).to have_css ".loading-bar.errors"
end
end
\ No newline at end of file
diff --git a/spec/shared/features/imageable.rb b/spec/shared/features/imageable.rb
index 09526b02d..c4f3156bf 100644
--- a/spec/shared/features/imageable.rb
+++ b/spec/shared/features/imageable.rb
@@ -127,7 +127,7 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
visit new_image_path(imageable_type: imageable.class.name,
imageable_id: imageable.id)
- attach_file :image_attachment, "spec/fixtures/files/logo_header.png", make_visible: true
+ attach_image("spec/fixtures/files/logo_header.png", false)
expect(page).to have_css "small.error"
end
@@ -147,9 +147,8 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
visit new_image_path(imageable_type: imageable.class.name,
imageable_id: imageable.id)
- attach_file :image_attachment, "spec/fixtures/files/clippy.png", make_visible: true
+ attach_image("spec/fixtures/files/logo_header.png", false)
- expect(page).to have_css ".loading-bar.errors"
expect(page).not_to have_content "clippy.png"
end
@@ -158,7 +157,7 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
visit new_image_path(imageable_type: imageable.class.name,
imageable_id: imageable.id)
- attach_file :image_attachment, "spec/fixtures/files/clippy.jpg", make_visible: true
+ attach_image("spec/fixtures/files/clippy.jpg", true)
expect(page).to have_css("figure img")
expect(page).not_to have_css("figure figcaption")
@@ -169,7 +168,7 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
visit new_image_path(imageable_type: imageable.class.name,
imageable_id: imageable.id)
- attach_file :image_attachment, "spec/fixtures/files/clippy.jpg", make_visible: true
+ attach_image("spec/fixtures/files/clippy.jpg", true)
expect(page).to have_selector ".loading-bar.complete"
end
@@ -179,7 +178,7 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
visit new_image_path(imageable_type: imageable.class.name,
imageable_id: imageable.id)
- attach_file :image_attachment, "spec/fixtures/files/logo_header.png", make_visible: true
+ attach_image("spec/fixtures/files/logo_header.png", false)
expect(page).to have_selector ".loading-bar.errors"
end
@@ -189,9 +188,9 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
visit new_image_path(imageable_type: imageable.class.name,
imageable_id: imageable.id)
- attach_file :image_attachment, "spec/fixtures/files/clippy.jpg", make_visible: true
+ attach_image("spec/fixtures/files/clippy.jpg")
- expect(page).to have_css("input[name='image[title]'][value='clippy.jpg']", visible: false)
+ expect(find('input#image_title').value).to eq('clippy.jpg')
end
scenario "Should not update image title with attachment original file name after valid image upload when title already defined by user", :js do
@@ -200,10 +199,9 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
imageable_id: imageable.id)
fill_in :image_title, with: "My custom title"
- attach_file :image_attachment, "spec/fixtures/files/clippy.jpg", make_visible: true
+ attach_image("spec/fixtures/files/clippy.jpg")
- expect(page).to have_selector ".loading-bar.complete"
- expect(page).to have_css("input[name='image[title]'][value='My custom title']", visible: false)
+ expect(find('input#image_title').value).to eq('My custom title')
end
scenario "Should update image cached_attachment field after valid file upload", :js do
@@ -211,7 +209,7 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
visit new_image_path(imageable_type: imageable.class.name,
imageable_id: imageable.id)
- attach_file :image_attachment, "spec/fixtures/files/clippy.jpg", make_visible: true
+ attach_image("spec/fixtures/files/clippy.jpg", true)
expect(page).to have_css("input[name='image[cached_attachment]'][value$='clippy.jpg']", visible: false)
end
@@ -221,7 +219,7 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
visit new_image_path(imageable_type: imageable.class.name,
imageable_id: imageable.id)
- attach_file :image_attachment, "spec/fixtures/files/logo_header.png", make_visible: true
+ attach_image("spec/fixtures/files/logo_header.png", false)
expect(page).to have_selector ".loading-bar.errors"
expect(find("input[name='image[cached_attachment]']", visible: false).value).to eq("")
@@ -342,3 +340,12 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
end
end
+
+def attach_image(path, success = true)
+ attach_file :image_attachment, path, make_visible: true
+ if success
+ expect(page).to have_css ".loading-bar.complete"
+ else
+ expect(page).to have_css ".loading-bar.errors"
+ end
+end