OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#41852] fix undefined method path for nil class when click attachment
jenenliu34efd4ecfa88
diff --git a/lib/api/helpers/attachment_renderer.rb b/lib/api/helpers/attachment_renderer.rbindex 25ae274267b..5692f47515a 100644--- a/lib/api/helpers/attachment_renderer.rb+++ b/lib/api/helpers/attachment_renderer.rb@@ -86,6 +86,10 @@ module APIenddef send_attachment(attachment)+ if attachment.diskfile.nil?+ raise ::API::Errors::NotFound.new+ end+content_type attachment_content_type(attachment)header["Content-Disposition"] = attachment.content_dispositionenv["api.format"] = :binarydiff --git a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rbindex cc32297a87d..57fd8038680 100644--- a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb+++ b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb@@ -471,6 +471,13 @@ RSpec.shared_examples "an APIv3 attachment resource", content_type: :json, type:expect(subject.body).to match(mock_file.read)end++ it "responds with not found if file has been deleted" do+ File.delete attachment.file.path++ get path+ expect(subject.status).to eq 404+ endendcontext "for a local text file" do