From 95016a1bf337aeb84fcb85b3bfc8065e7063c396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Thu, 21 Sep 2017 12:30:22 +0200 Subject: [PATCH] Some renaming and cleaning --- app/assets/javascripts/imageable.js.coffee | 2 +- app/assets/stylesheets/documentable.scss | 1 - app/assets/stylesheets/imageable.scss | 3 +- app/helpers/images_helper.rb | 2 +- app/views/images/_form.html.erb | 2 +- config/locales/en/images.yml | 1 - config/locales/es/images.yml | 1 - spec/features/proposals_spec.rb | 62 +++++++++++----------- 8 files changed, 34 insertions(+), 40 deletions(-) diff --git a/app/assets/javascripts/imageable.js.coffee b/app/assets/javascripts/imageable.js.coffee index 62a013bf0..793ac3c66 100644 --- a/app/assets/javascripts/imageable.js.coffee +++ b/app/assets/javascripts/imageable.js.coffee @@ -1,7 +1,7 @@ App.Imageable = initialize: -> - inputFiles = $('input.direct_upload_image_attachment[type=file]') + inputFiles = $('input.js-document-attachment[type=file]') $.each inputFiles, (index, input) -> App.Imageable.initializeDirectUploadInput(input) diff --git a/app/assets/stylesheets/documentable.scss b/app/assets/stylesheets/documentable.scss index b2ef50135..b7a5f7e4b 100644 --- a/app/assets/stylesheets/documentable.scss +++ b/app/assets/stylesheets/documentable.scss @@ -28,7 +28,6 @@ background-color: $light-gray; } - input.direct_upload_image_attachment[type=file], .js-document-attachment{ display: none; } diff --git a/app/assets/stylesheets/imageable.scss b/app/assets/stylesheets/imageable.scss index 179e262da..0c49341db 100644 --- a/app/assets/stylesheets/imageable.scss +++ b/app/assets/stylesheets/imageable.scss @@ -29,8 +29,7 @@ background-color: $light-gray; } - input.direct_upload_image_attachment[type=file], - input.direct_upload_document_attachment[type=file] { + .js-image-attachment{ display: none; } diff --git a/app/helpers/images_helper.rb b/app/helpers/images_helper.rb index 7b0edb24a..9596f1a82 100644 --- a/app/helpers/images_helper.rb +++ b/app/helpers/images_helper.rb @@ -76,7 +76,7 @@ module ImagesHelper def render_image_attachment(image) html = file_field_tag :attachment, accept: imageable_accepted_content_types_extensions, - class: 'direct_upload_image_attachment', + class: 'js-document-attachment', data: { url: image_direct_upload_url(image), cached_attachment_input_field: image_nested_field_id(image, :cached_attachment), diff --git a/app/views/images/_form.html.erb b/app/views/images/_form.html.erb index 5f5689a7f..0af13b655 100644 --- a/app/views/images/_form.html.erb +++ b/app/views/images/_form.html.erb @@ -24,7 +24,7 @@ <%= f.file_field :attachment, accept: imageable_accepted_content_types_extensions, label: false, - class: 'direct_upload_image_attachment', + class: 'js-document-attachment', data: { url: direct_uploads_url("direct_upload[resource_type]": @image.imageable_type, "direct_upload[resource_id]": @image.imageable_id, diff --git a/config/locales/en/images.yml b/config/locales/en/images.yml index b026d544d..d54ef79fb 100644 --- a/config/locales/en/images.yml +++ b/config/locales/en/images.yml @@ -2,7 +2,6 @@ en: images: upload_image: Upload image remove_image: Remove image - remove_alert: Are you sure you want to remove the image? form: title: Descriptive image diff --git a/config/locales/es/images.yml b/config/locales/es/images.yml index 652630a29..92b6acaf8 100644 --- a/config/locales/es/images.yml +++ b/config/locales/es/images.yml @@ -2,7 +2,6 @@ es: images: upload_image: Subir imagen remove_image: Eliminar imagen - remove_alert: ¿Está seguro que desea eliminar la imagen del proyecto? form: title: Imagen descriptiva diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 4aa923216..2c8db068d 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -1290,44 +1290,42 @@ feature 'Proposals' do it_behaves_like "followable", "proposal", "proposal_path", { "id": "id" } - describe "my specs group" do + it_behaves_like "imageable", "proposal", "proposal_path", { "id": "id" } - it_behaves_like "imageable", "proposal", "proposal_path", { "id": "id" } + it_behaves_like "nested imageable", + "proposal", + "new_proposal_path", + { }, + "imageable_fill_new_valid_proposal", + "Create proposal", + "Proposal created successfully" - it_behaves_like "nested imageable", - "proposal", - "new_proposal_path", - { }, - "imageable_fill_new_valid_proposal", - "Create proposal", - "Proposal created successfully" + it_behaves_like "nested imageable", + "proposal", + "edit_proposal_path", + { "id": "id" }, + nil, + "Save changes", + "Proposal updated successfully" - it_behaves_like "nested imageable", - "proposal", - "edit_proposal_path", - { "id": "id" }, - nil, - "Save changes", - "Proposal updated successfully" + it_behaves_like "documentable", "proposal", "proposal_path", { "id": "id" } - it_behaves_like "documentable", "proposal", "proposal_path", { "id": "id" } + it_behaves_like "nested documentable", + "proposal", + "new_proposal_path", + { }, + "documentable_fill_new_valid_proposal", + "Create proposal", + "Proposal created successfully" - it_behaves_like "nested documentable", - "proposal", - "new_proposal_path", - { }, - "documentable_fill_new_valid_proposal", - "Create proposal", - "Proposal created successfully" + it_behaves_like "nested documentable", + "proposal", + "edit_proposal_path", + { "id": "id" }, + nil, + "Save changes", + "Proposal updated successfully" - it_behaves_like "nested documentable", - "proposal", - "edit_proposal_path", - { "id": "id" }, - nil, - "Save changes", - "Proposal updated successfully" - end scenario 'Erased author' do user = create(:user) proposal = create(:proposal, author: user)