Fix overlapping error on Travis with make_visible option on attach_field spec helper

This commit is contained in:
Senén Rodero Rodríguez
2017-08-24 20:17:13 +02:00
parent f4ac8b17d0
commit d67ad6d6d0
5 changed files with 9 additions and 8 deletions

View File

@@ -8,6 +8,10 @@
background-color: $light-gray; background-color: $light-gray;
} }
input.document_ajax_attachment[type=file]{
display: none;
}
.file-name { .file-name {
margin-top: $line-height / 2; margin-top: $line-height / 2;
} }

View File

@@ -20,7 +20,7 @@
<%= f.file_field :attachment, <%= f.file_field :attachment,
accept: accepted_content_types_extensions(@document.documentable.class), accept: accepted_content_types_extensions(@document.documentable.class),
label: false, label: false,
class: 'document_ajax_attachment show-for-sr', class: 'document_ajax_attachment',
data: { data: {
url: upload_documents_url(documentable_type: @document.documentable_type, documentable_id: @document.documentable_id), url: upload_documents_url(documentable_type: @document.documentable_type, documentable_id: @document.documentable_id),
cached_attachment_input_field: "document_cached_attachment", cached_attachment_input_field: "document_cached_attachment",

View File

@@ -25,7 +25,7 @@
<%= file_field_tag :attachment, <%= file_field_tag :attachment,
accept: accepted_content_types_extensions(document.documentable_type.constantize), accept: accepted_content_types_extensions(document.documentable_type.constantize),
class: 'document_ajax_attachment show-for-sr', class: 'document_ajax_attachment',
data: { data: {
url: upload_documents_url( url: upload_documents_url(
documentable_type: document.documentable_type, documentable_type: document.documentable_type,

View File

@@ -197,8 +197,7 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
click_on "Upload document" click_on "Upload document"
expect(page).to have_content "2 errors prevented this Document from being saved: " expect(page).to have_content "2 errors prevented this Document from being saved: "
expect(page).to have_selector "small.error:not(.show-for-sr)", text: "can't be blank", count: 2 expect(page).to have_selector "small.error", text: "can't be blank", count: 3
expect(page).to have_selector "small.show-for-sr", text: "can't be blank", count: 1
end end
scenario "Should display file name after file selection", :js do scenario "Should display file name after file selection", :js do

View File

@@ -105,8 +105,7 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum
click_link "Add new document" click_link "Add new document"
fill_in "#{documentable_factory_name}[documents_attributes][0][title]", with: "Title" fill_in "#{documentable_factory_name}[documents_attributes][0][title]", with: "Title"
execute_script "$('input[type=\"file\"]').removeClass('show-for-sr');" attach_file("#{documentable_factory_name}[documents_attributes][0][attachment]", "spec/fixtures/files/empty.pdf", make_visible: true)
attach_file "#{documentable_factory_name}[documents_attributes][0][attachment]", "spec/fixtures/files/empty.pdf"
sleep 1 sleep 1
expect(find("##{documentable_factory_name}_documents_attributes_0_title").value).to eq "Title" expect(find("##{documentable_factory_name}_documents_attributes_0_title").value).to eq "Title"
@@ -261,8 +260,7 @@ end
def attach_new_file(documentable_factory_name, index, path) def attach_new_file(documentable_factory_name, index, path)
click_link "Add new document" click_link "Add new document"
sleep 1 sleep 1
execute_script "$('input[type=\"file\"]').removeClass('show-for-sr');" attach_file("#{documentable_factory_name}[documents_attributes][#{index}][attachment]", path, make_visible: true)
attach_file "#{documentable_factory_name}[documents_attributes][#{index}][attachment]", path
sleep 1 sleep 1
end end