about summary refs log tree commit diff
path: root/spec/services
diff options
context:
space:
mode:
authorJoshua Wood <josh@joshuawood.net>2022-11-17 01:59:35 -0800
committerGitHub <noreply@github.com>2022-11-17 10:59:35 +0100
commitdaf6f3453e2a37db3d9a8362d64106b6c7cf0763 (patch)
treeb6fb6551791d7057c01b90471dd3f477fafdb9a6 /spec/services
parentcbb0153bd0945a6aaf612850e1fa6c788336c01b (diff)
Handle links with no href in VerifyLinkService (#20741)
Before this change, the following error would cause VerifyAccountLinksWorker to fail:

NoMethodError: undefined method `downcase' for nil:NilClass
  [PROJECT_ROOT]/app/services/verify_link_service.rb:31 :in `block in link_back_present?`
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/verify_link_service_spec.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/services/verify_link_service_spec.rb b/spec/services/verify_link_service_spec.rb
index 3fc88e60e..52ba454cc 100644
--- a/spec/services/verify_link_service_spec.rb
+++ b/spec/services/verify_link_service_spec.rb
@@ -76,7 +76,25 @@ RSpec.describe VerifyLinkService, type: :service do
     context 'when a link does not contain a link back' do
       let(:html) { '' }
 
-      it 'marks the field as verified' do
+      it 'does not mark the field as verified' do
+        expect(field.verified?).to be false
+      end
+    end
+
+    context 'when link has no `href` attribute' do
+      let(:html) do
+        <<-HTML
+          <!doctype html>
+          <head>
+            <link type="text/html" rel="me" />
+          </head>
+          <body>
+            <a rel="me" target="_blank">Follow me on Mastodon</a>
+          </body>
+        HTML
+      end
+
+      it 'does not mark the field as verified' do
         expect(field.verified?).to be false
       end
     end