Skip to content

Commit

Permalink
Merge pull request #497 from tighten/ajm/prevent-duplicate-rejected-c…
Browse files Browse the repository at this point in the history
…onferences

Prevent re-importing rejected conferences
  • Loading branch information
damiani authored Jan 3, 2024
2 parents 6728651 + 55ff2f5 commit 303939b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/CallingAllPapers/ConferenceImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
23 changes: 23 additions & 0 deletions tests/Feature/CallingAllPapersConferenceImporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 303939b

Please sign in to comment.