Skip to content

Commit

Permalink
rspec tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
ichandrasharma committed Feb 13, 2025
1 parent 59387ac commit da32307
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/models/course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,26 @@
end
end

describe 'validations' do
let!(:existing_course) { create(:course, slug: 'existing-slug') }

context 'when updating a course' do
let!(:duplicate_course) { create(:course, slug: 'duplicate-slug') }

it 'raises Course::DuplicateCourseSlugError if the slug is duplicated' do
# Attempting to update the course with an existing slug should raise an error
expect do
duplicate_course.update!(slug: existing_course.slug)
end.to raise_error(Course::DuplicateCourseSlugError, 'Duplicate Slug')
end

it 'does not raise an error if the slug is unique' do
# Updating the course with a unique slug should pass without errors
expect { existing_course.update!(slug: 'new-unique-slug') }.not_to raise_error
end
end
end

describe '#approved' do
let(:course) { create(:course) }

Expand Down

0 comments on commit da32307

Please sign in to comment.