Skip to content

Commit

Permalink
Add one off rake task for executing Course::PublishService
Browse files Browse the repository at this point in the history
  • Loading branch information
inulty-dfe committed Nov 18, 2024
1 parent 181844b commit fb3bbdf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/tasks/publish_given_course.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

namespace :app do
desc 'We have a course from a previous cycle that we need to publish'
task :publish_course, %i[user_email course_uuid] => :environment do |_task, args|
course_uuid = args[:course_uuid]
user_email = args[:user_email]

user = User.admins.find_by!(email: user_email)
Course.find_by!(uuid: course_uuid)
Course::PublishService.call(uuid: course_uuid, user:)
end
end
2 changes: 2 additions & 0 deletions spec/services/courses/publish_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
end

describe 'publish fails' do
let(:course) { create(:course, uuid:) }

it 'raises UnpublishableError' do
expect do
described_class.publish(uuid: course.uuid, user:)
Expand Down

0 comments on commit fb3bbdf

Please sign in to comment.