diff --git a/app/models/direct_upload.rb b/app/models/direct_upload.rb index 85d397706..e597f9f12 100644 --- a/app/models/direct_upload.rb +++ b/app/models/direct_upload.rb @@ -21,7 +21,7 @@ class DirectUpload #Refactor if @resource.respond_to?(:images) && - (@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present? + ((@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present?) @relation = @resource.images.send("build", relation_attributtes) elsif @resource.class.reflections[@resource_relation].macro == :has_one @relation = @resource.send("build_#{resource_relation}", relation_attributtes) diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index 3e87c4021..24d6631a8 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -191,10 +191,17 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na documentable_attach_new_file(documentable_factory_name, 0, "spec/fixtures/files/empty.pdf") click_on submit_button + documentable_redirected_to_resource_show_or_navigate_to expect(page).to have_content "Documents" - expect(page).to have_link "empty.pdf" + + find("#tab-documents-label").click + expect(page).to have_content "empty.pdf" + + #Review + #Doble check why the file is stored with a name different to empty.pdf + expect(page).to have_css("a[href$='.pdf']") end scenario "Should show resource with new document after successful creation with maximum allowed uploaded files", :js do