Skip to content

Commit

Permalink
Undiscard the course when publishing
Browse files Browse the repository at this point in the history
  Courses may be #published? and still not appear in the API. When we
  publish a course, we should expect it to appear in the API.
  When publishing a course we should undiscard the course if it has been
  discarded
  • Loading branch information
inulty-dfe committed Nov 25, 2024
1 parent 087e833 commit 4ca649e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/services/courses/publish_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
11 changes: 11 additions & 0 deletions spec/services/courses/publish_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4ca649e

Please sign in to comment.