File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ public function handle()
31
31
$ this ->submission ->remove ($ field ->handle ());
32
32
});
33
33
34
- $ this ->submission ->saveQuietly ();
34
+ if ($ this ->submission ->form ()->store ()) {
35
+ $ this ->submission ->saveQuietly ();
36
+ }
35
37
}
36
38
}
Original file line number Diff line number Diff line change 5
5
use Illuminate \Support \Facades \Bus ;
6
6
use PHPUnit \Framework \Attributes \DataProvider ;
7
7
use PHPUnit \Framework \Attributes \Test ;
8
+ use Statamic \Contracts \Forms \SubmissionRepository ;
8
9
use Statamic \Facades \Form as FacadesForm ;
9
10
use Statamic \Facades \Site ;
10
11
use Statamic \Forms \DeleteTemporaryAttachments ;
@@ -115,6 +116,29 @@ public function it_dispatches_delete_attachments_job_after_dispatching_email_job
115
116
]);
116
117
}
117
118
119
+ #[Test]
120
+ public function delete_attachments_job_only_saves_submission_when_enabled ()
121
+ {
122
+ $ form = tap (FacadesForm::make ('attachments_test ' )->email ([
123
+ 'from ' => 'first@sender.com ' ,
124
+ 'to ' => 'first@recipient.com ' ,
125
+ 'foo ' => 'bar ' ,
126
+ ]))->save ();
127
+
128
+ $ form
129
+ ->store (false )
130
+ ->blueprint ()
131
+ ->ensureField ('attachments ' , ['type ' => 'files ' ])->save ();
132
+
133
+ $ submission = $ form ->makeSubmission ();
134
+
135
+ (new DeleteTemporaryAttachments ($ submission ))->handle ();
136
+
137
+ $ submissions = app (SubmissionRepository::class)->all ();
138
+
139
+ $ this ->assertEmpty ($ submissions );
140
+ }
141
+
118
142
#[Test]
119
143
#[DataProvider('noEmailsProvider ' )]
120
144
public function no_email_jobs_are_queued_if_none_are_configured ($ emailConfig )
You can’t perform that action at this time.
0 commit comments