<p><b>@tomhughes</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2120#discussion_r250735173">app/jobs/trace_destroyer_job.rb</a>:</p>
<pre style='color:#555'>> @@ -0,0 +1,10 @@
+class TraceDestroyerJob < ApplicationJob
+  queue_as :default
+
+  def perform(trace)
+    trace.destroy
+  rescue StandardError => ex
+    logger.info ex.to_s
+    ex.backtrace.each { |l| logger.info l }
</pre>
<p>Why are we catching and logging exceptions? By doing that we make it look like the job has succeeded and it will be removed from the queue - if we didn't do that then it would stay queued...</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2120#discussion_r250737621">test/jobs/trace_importer_job_test.rb</a>:</p>
<pre style='color:#555'>> +
+class TraceImporterJobTest < ActiveJob::TestCase
+  def test_success_notification
+    # Check that the user gets a success notification when the trace has valid points
+    trace = create(:trace)
+
+    gpx = Minitest::Mock.new
+    def gpx.actual_points
+      5
+    end
+
+    trace.stub(:import, gpx) do
+      perform_enqueued_jobs do
+        TraceImporterJob.perform_now(trace)
+      end
+    end
</pre>
<p>I'm struggling to understand this, or to find any documentation of the <code>stub</code> method that would help me. I assume it's a FactoryBot thing but although I find occasional references to it on google the actual documentation never seems to mention it.</p>
<p>I assume it stubs the <code>import</code> method but I don't see when this test would ever call that method? or why calling import which would normally be called from the job should actually run the job?</p>
<p>I'm probably just being dense but I'd like to understand what's going on ;-)</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2120#pullrequestreview-196195708">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABWnLfE3F5EuRbq-8XVe2fgjvbhySyR8ks5vGgQPgaJpZM4aDUsB">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABWnLWsCqzTZfcRNl8Jh5k6-hIFdZOKDks5vGgQPgaJpZM4aDUsB.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/openstreetmap/openstreetmap-website","title":"openstreetmap/openstreetmap-website","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/openstreetmap-website"}},"updates":{"snippets":[{"icon":"PERSON","message":"@tomhughes commented on #2120"}],"action":{"name":"View Pull Request","url":"https://github.com/openstreetmap/openstreetmap-website/pull/2120#pullrequestreview-196195708"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/2120#pullrequestreview-196195708",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/2120#pullrequestreview-196195708",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>