Skip to content

Commit

Permalink
Add spec for Course#last_published_at
Browse files Browse the repository at this point in the history
  • Loading branch information
inulty-dfe committed Oct 30, 2024
1 parent c542ae3 commit 90c5218
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec/models/course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,37 @@
end
end

describe '#last_published_at' do
context 'with an unpublished course' do
let(:course) { create(:course, study_mode: :part_time, enrichments: [create(:course_enrichment)]) }

it 'returns nil' do
expect(course.last_published_at).to be_nil
end
end

context 'with a twice published course' do
let(:course) do
create(:course, study_mode: :part_time, enrichments: [
create(:course_enrichment, :published, last_published_timestamp_utc: '1/1/2024'),
create(:course_enrichment, :published, last_published_timestamp_utc: '1/1/2023')
])
end

it 'selects the enrichment with the latest date' do
expect(course.last_published_at).to eq('1/1/2024')
end

context 'when the enrichments are not loaded' do
it 'selects the enrichment with the latest date' do
course.reload
expect(course.enrichments.loaded?).to be_falsey
expect(course.last_published_at).to eq('1/1/2024')
end
end
end
end

describe 'funding_type and program_type' do
context 'setting the funding to apprenticeship' do
it 'sets the funding to apprenticeship and program_type to pg_teaching_apprenticeship' do
Expand Down

0 comments on commit 90c5218

Please sign in to comment.