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
Allow own deletion
Oliver Günther61fec026b125
diff --git a/app/components/admin/quarantined_attachments/row_component.rb b/app/components/admin/quarantined_attachments/row_component.rbindex fec101fa34f..efe85f946bf 100644--- a/app/components/admin/quarantined_attachments/row_component.rb+++ b/app/components/admin/quarantined_attachments/row_component.rb@@ -63,8 +63,6 @@ module Adminenddef override_link- return if User.current == attachment.author-helpers.link_to(helpers.op_icon('icon icon-unlocked'),{ controller: '/admin/attachments/quarantined_attachments', action: :override, id: model },@@ -75,8 +73,6 @@ module Adminenddef delete_link- return if User.current == attachment.author-helpers.link_to(helpers.op_icon('icon icon-delete'),{ controller: '/admin/attachments/quarantined_attachments', action: :destroy, id: model },diff --git a/app/controllers/admin/attachments/quarantined_attachments_controller.rb b/app/controllers/admin/attachments/quarantined_attachments_controller.rbindex f2d4286e408..f1fd4b6a5dc 100644--- a/app/controllers/admin/attachments/quarantined_attachments_controller.rb+++ b/app/controllers/admin/attachments/quarantined_attachments_controller.rb@@ -34,7 +34,6 @@ module Adminbefore_action :find_quarantined_attachmentsbefore_action :find_attachment, only: %i[override destroy]- before_action :prevent_same_user, only: %i[override destroy]menu_item :attachment_quarantine@@ -88,13 +87,6 @@ module Adminrescue ActiveRecord::RecordNotFoundrender_404end-- def prevent_same_user- if current_user == @attachment.author- flash[:error] = t('antivirus_scan.quarantined_attachments.error_cannot_act_self')- redirect_to action: :index- end- endendendenddiff --git a/spec/features/admin/attachments/quarantined_attachments_spec.rb b/spec/features/admin/attachments/quarantined_attachments_spec.rbindex 616f6c44949..c60fcb218cb 100644--- a/spec/features/admin/attachments/quarantined_attachments_spec.rb+++ b/spec/features/admin/attachments/quarantined_attachments_spec.rb@@ -56,7 +56,7 @@ RSpec.describe 'Quarantined attachments', :js, :with_cuprite dopage.within("#quarantined_attachment_#{own_quarantined_attachment.id}") doexpect(page).to have_no_link I18n.t('antivirus_scan.quarantined_attachments.override')- expect(page).to have_no_link I18n.t('antivirus_scan.quarantined_attachments.delete')+ expect(page).to have_link I18n.t('antivirus_scan.quarantined_attachments.delete')endpage.within("#quarantined_attachment_#{quarantined_attachment.id}") dodiff --git a/spec/requests/admin/attachments/quarantined_attachments_spec.rb b/spec/requests/admin/attachments/quarantined_attachments_spec.rbindex e4754349acc..d760013b57f 100644--- a/spec/requests/admin/attachments/quarantined_attachments_spec.rb+++ b/spec/requests/admin/attachments/quarantined_attachments_spec.rb@@ -29,15 +29,13 @@require 'spec_helper'RSpec.describe 'Quarantined attachments',+ with_ee: %i[virus_scanning],type: :rails_request doshared_let(:other_author) { create(:user) }shared_let(:admin) { create(:admin) }shared_let(:container) { create(:work_package) }- shared_let(:own_quarantined_attachment) do- create(:attachment, container:, status: :quarantined, author: admin, filename: 'my-own.txt')- endshared_let(:quarantined_attachment) docreate(:attachment, container:, status: :quarantined, author: other_author, filename: 'other-1.txt')end@@ -61,28 +59,21 @@ RSpec.describe 'Quarantined attachments',enddescribe 'DELETE /admin/quarantined_attachments/:id' do- it 'allows management other attachments' do+ it 'allows management of attachments' dodelete admin_quarantined_attachment_path(quarantined_attachment)expect(response).to be_redirectexpect { quarantined_attachment.reload }.to raise_error(ActiveRecord::RecordNotFound)end- it 'disallows own attachments' do- delete admin_quarantined_attachment_path(own_quarantined_attachment)- expect(response).to be_redirect-- expect { own_quarantined_attachment.reload }.not_to raise_error- end-it 'fails to find if not quarantined' dodelete admin_quarantined_attachment_path(scanned_attachment)- expect(response).to have_http_status 404+ expect(response).to have_http_status :not_foundendenddescribe 'PATCH /admin/quarantined_attachments/:id/override' do- it 'allows management other attachments' do+ it 'allows management of attachments' dopatch override_admin_quarantined_attachment_path(quarantined_attachment)expect(response).to be_redirect@@ -90,17 +81,9 @@ RSpec.describe 'Quarantined attachments',expect(quarantined_attachment).to be_status_scannedend- it 'disallows own attachments' do- patch override_admin_quarantined_attachment_path(own_quarantined_attachment)- expect(response).to be_redirect-- own_quarantined_attachment.reload- expect(own_quarantined_attachment).to be_status_quarantined- end-it 'fails to find if not quarantined' dopatch override_admin_quarantined_attachment_path(scanned_attachment)- expect(response).to have_http_status 404+ expect(response).to have_http_status :not_foundendendend