Skip to content

Commit

Permalink
- create task for future tests
Browse files Browse the repository at this point in the history
- permit running without seeds
  • Loading branch information
peterdavidhamilton committed Dec 1, 2023
1 parent 56f42e6 commit 05c6eb9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/jobs/new_module_mail_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# @see HookController#release
#
# Notify users of the latest published module and record the release timestamp
class NewModuleMailJob < MailJob
# @param release_id [Integer]
def run(release_id)
Expand All @@ -8,9 +11,7 @@ def run(release_id)
recipient.send_new_module_notification(latest_module)
end

newest_release = Release.find(release_id)

record_module_release(latest_module, newest_release)
record_module_release latest_module, Release.find(release_id)
end
end

Expand All @@ -23,8 +24,6 @@ def latest_module

# @return [Boolean]
def new_module_published?
return false unless ModuleRelease.exists?

ModuleRelease.ordered.last&.module_position.to_i < latest_module.position
end

Expand Down
22 changes: 22 additions & 0 deletions lib/tasks/cms.rake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@ namespace :eyfs do
SeedSnippets.new.call
end

# ./bin/docker-rails 'eyfs:cms:seed_releases'
desc 'Seed content releases'
task seed_releases: :environment do
Training::Module.live.each do |mod|
next if ModuleRelease.find_by(module_position: mod.position)

release =
Release.create!(
name: Random.hex,
properties: {},
time: Time.zone.now,
)

ModuleRelease.create!(
release_id: release.id,
module_position: mod.position,
name: mod.name,
first_published_at: release.time,
)
end
end

# @see .env
# CONTENTFUL_ENVIRONMENT=demo
#
Expand Down

0 comments on commit 05c6eb9

Please sign in to comment.