Skip to content

Commit

Permalink
AO3-6832 Don't attach work download to abuse report if provided comme…
Browse files Browse the repository at this point in the history
…nt URL (#4972)

* Don't attach work download to abuse report if provided comment URL

* Add test, tweak for readability
  • Loading branch information
WelpThatWorked authored Dec 10, 2024
1 parent 9a81cf0 commit 493f91e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/abuse_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ def send_report
end

def attach_work_download(ticket_id)
is_not_comments = url[%r{/comments/}, 0].nil?
work_id = url[%r{/works/(\d+)}, 1]
return unless work_id
return unless work_id && is_not_comments

work = Work.find_by(id: work_id)
ReportAttachmentJob.perform_later(ticket_id, work) if work
Expand Down
7 changes: 7 additions & 0 deletions spec/models/abuse_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@
.not_to have_enqueued_job
end

it "does not attach a download for comment sub-URLs asynchronously" do
allow(subject).to receive(:url).and_return("http://archiveofourown.org/works/#{work.id}/comments/")

expect { subject.attach_work_download(ticket_id) }
.not_to have_enqueued_job
end

it "attaches a download for work URLs asynchronously" do
allow(subject).to receive(:url).and_return("http://archiveofourown.org/works/#{work.id}/")

Expand Down

0 comments on commit 493f91e

Please sign in to comment.