Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Jun 27, 2024
1 parent b00c53e commit c9450c4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/models/saved_annotation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,28 @@ class SavedAnnotationTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

test 'filtering by course_id should contain nil values' do
user = create :user
course = create :course
s1 = create :saved_annotation, course: nil, user: user
s2 = create :saved_annotation, course: course, user: user
s3 = create :saved_annotation, course: create(:course), user: user

assert_includes SavedAnnotation.by_course(course), s1
assert_includes SavedAnnotation.by_course(course), s2
assert_not_includes SavedAnnotation.by_course(course), s3
end

test 'filtering by exercise_id should contain nil values' do
user = create :user
exercise = create :exercise
s1 = create :saved_annotation, exercise: nil, user: user
s2 = create :saved_annotation, exercise: exercise, user: user
s3 = create :saved_annotation, exercise: create(:exercise), user: user

assert_includes SavedAnnotation.by_exercise(exercise), s1
assert_includes SavedAnnotation.by_exercise(exercise), s2
assert_not_includes SavedAnnotation.by_exercise(exercise), s3
end
end

0 comments on commit c9450c4

Please sign in to comment.