Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wth - (SPARCRequest & SPARC Dashboard) Document upload bug #1281

Merged
merged 1 commit into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 16 additions & 20 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,22 @@ class Document < ApplicationRecord
has_and_belongs_to_many :sub_service_requests
belongs_to :protocol
has_attached_file :document #, :preserve_files => true
validates_attachment :document, content_type: { content_type: [
"application/pdf",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.ms-office",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/vnd.ms-powerpoint",
"application/octet-stream",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/msword",
"application/vnd.ms-excel",
"image/jpeg",
"text/csv",
"text/rtf",
"text/plain",
"text/msg",
"message/rfc822",
"image/gif",
"image/png",
"image/tiff"
] }
validates_attachment_file_name :document, matches: [
/\.pdf$/,
/\.docx?$/,
/\.xlsx?$/,
/\.rtf$/,
/\.txt$/,
/\.csv$/,
/\.ppt?$/,
/\.msg$/,
/\.eml$/,
/\.jpg$/,
/\.gif$/,
/\.png$/,
/\.tiff$/,
/\.jpeg$/
]

validates :doc_type, :document, presence: true
validates :doc_type_other, presence: true, if: Proc.new { |doc| doc.doc_type == 'other' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def go_to_show_protocol(protocol_id)
let!(:super_user) { create(:super_user, organization: organization, identity: logged_in_user) }
let!(:service_request) { create(:service_request_without_validations, protocol: protocol) }
let!(:ssr) { create(:sub_service_request_without_validations, service_request: service_request, organization: organization, status: 'draft') }
let!(:document_with_access) { create(:document, protocol: protocol, doc_type: 'Protocol', document_file_name: 'accessible_doc') }
let!(:document_no_access) { create(:document, protocol: protocol, doc_type: 'Consent', document_file_name: 'inaccessible_doc') }
let!(:document_with_access) { create(:document, protocol: protocol, doc_type: 'Protocol', document_file_name: 'accessible_doc.pdf') }
let!(:document_no_access) { create(:document, protocol: protocol, doc_type: 'Consent', document_file_name: 'inaccessible_doc.pdf') }

before :each do
document_with_access.sub_service_requests = [ssr]
Expand Down