diff --git a/app/services/courses/publish_service.rb b/app/services/courses/publish_service.rb index 5286a132d9..ccdec1b5f1 100644 --- a/app/services/courses/publish_service.rb +++ b/app/services/courses/publish_service.rb @@ -26,6 +26,7 @@ def call def publish_course Course.transaction do + course.undiscard course.publish_sites course.publish_enrichment(user) course.application_status_open! diff --git a/spec/services/courses/publish_service_spec.rb b/spec/services/courses/publish_service_spec.rb index b4dd8df767..9fe3b00a39 100644 --- a/spec/services/courses/publish_service_spec.rb +++ b/spec/services/courses/publish_service_spec.rb @@ -29,6 +29,17 @@ end end + describe 'when the course is discarded' do + let(:course) { create(:course, :publishable, uuid:, discarded_at: 1.minute.ago) } + + it 'the course is undiscarded and published' do + allow(Course).to receive(:find_by).with({ uuid: uuid }).and_return(course) + subject.call + expect(course.reload).to be_published + expect(course.reload).to be_undiscarded + end + end + describe 'publishing the course fails' do it 'the course is unpublished' do allow(Course).to receive(:find_by).with({ uuid: uuid }).and_return(course)