Add DMCA complaint form.

Add a form for submitting DMCA complaints. The complaint is emailed to
the site owner, and a confirmation email is sent to the submitter.
This commit is contained in:
evazion
2022-10-11 15:45:03 -05:00
parent 8fbc6d1d3a
commit 24bc6aa949
12 changed files with 278 additions and 12 deletions

View File

@@ -0,0 +1,28 @@
require "test_helper"
class DmcasControllerTest < ActionDispatch::IntegrationTest
context "show action" do
should "work for anonymous users" do
get dmca_path
assert_response :success
end
end
context "create action" do
should "work" do
dmca = {
name: "John Doe",
email: "test@example.com",
address: "123 Fake Street",
infringing_urls: "https://example.com/1.html\nhttps://example.com/2.html",
original_urls: "https://google.com/1.html\nhttps://google.com/2.html",
proof: "source: me",
signature: "John Doe",
}
post dmca_path, params: { dmca: dmca }
assert_response :success
assert_emails 2
end
end
end

View File

@@ -1,21 +1,36 @@
class UserMailerPreview < ActionMailer::Preview
def dmail_notice
dmail = User.system.dmails.first
user = params[:id].present? ? User.find(params[:id]) : User.owner
dmail = Dmail.received.order(id: :desc).offset(279).first
UserMailer.dmail_notice(dmail)
end
def password_reset
user = User.find(params[:id])
user = params[:id].present? ? User.find(params[:id]) : User.owner
UserMailer.password_reset(user)
end
def email_change_confirmation
user = User.find(params[:id])
user = params[:id].present? ? User.find(params[:id]) : User.owner
UserMailer.email_change_confirmation(user)
end
def welcome_user
user = User.find(params[:id])
user = params[:id].present? ? User.find(params[:id]) : User.owner
UserMailer.welcome_user(user)
end
def dmca_complaint
dmca = {
name: "John Doe",
email: "test@example.com",
address: "123 Fake Street",
infringing_urls: "https://example.com/1.html\nhttps://example.com/2.html",
original_urls: "https://google.com/1.html\nhttps://google.com/2.html",
proof: "source: me",
signature: "John Doe",
}
UserMailer.with(dmca: dmca).dmca_complaint(to: dmca[:email])
end
end

View File

@@ -68,5 +68,22 @@ class UserMailerTest < ActionMailer::TestCase
assert_emails(0) { mail.deliver_now }
end
end
context "dmail_complaint method" do
should "work" do
dmca = {
name: "John Doe",
email: "test@example.com",
address: "123 Fake Street",
infringing_urls: "https://example.com/1.html\nhttps://example.com/2.html",
original_urls: "https://google.com/1.html\nhttps://google.com/2.html",
proof: "source: me",
signature: "John Doe",
}
mail = UserMailer.with(dmca: dmca).dmca_complaint(to: dmca[:email])
assert_emails(1) { mail.deliver_now }
end
end
end
end