diff --git a/app/CallingAllPapers/ConferenceImporter.php b/app/CallingAllPapers/ConferenceImporter.php index 7ff96ed3..52c0256f 100644 --- a/app/CallingAllPapers/ConferenceImporter.php +++ b/app/CallingAllPapers/ConferenceImporter.php @@ -68,7 +68,9 @@ public function import(Event $event) ], ]); - $conference = Conference::firstOrNew(['calling_all_papers_id' => $event->id]); + $conference = Conference::query() + ->withoutGlobalScope('notRejected') + ->firstOrNew(['calling_all_papers_id' => $event->id]); $this->updateConferenceFromCallingAllPapersEvent($conference, $event); if (! $conference->latitude && ! $conference->longitude && $conference->location) { diff --git a/tests/Feature/CallingAllPapersConferenceImporterTest.php b/tests/Feature/CallingAllPapersConferenceImporterTest.php index 7ac509a1..a8e84554 100644 --- a/tests/Feature/CallingAllPapersConferenceImporterTest.php +++ b/tests/Feature/CallingAllPapersConferenceImporterTest.php @@ -382,6 +382,29 @@ public function conferences_with_cfp_duration_over_2_years_are_rejected() $this->assertNotNull($conference->rejected_at); } + /** @test */ + public function rejected_conferences_cannot_be_reimported() + { + $this->mockClient(); + + $conference = Conference::factory()->rejected()->create([ + 'calling_all_papers_id' => 'fake-cfp-id', + ]); + + $importer = new ConferenceImporter(1); + $event = $this->eventStub; + $event->id = 'fake-cfp-id'; + $event->dateCfpStart = '2014-06-01T00:00:00-04:00'; + $event->dateCfpEnd = '2017-06-01T00:00:00-04:00'; + $importer->import($event); + + $conferenceCount = Conference::withoutGlobalScope('notRejected') + ->where('calling_all_papers_id', 'fake-cfp-id') + ->count(); + + $this->assertEquals(1, $conferenceCount); + } + /** @test */ public function conferences_with_null_cfp_start_are_valid_with_cfp_end_less_than_2_years_in_future() {