course_participations_controller_test.rb 856 B

1234567891011121314151617181920212223242526272829
  1. require 'test_helper'
  2. class CourseParticipationsControllerTest < ActionDispatch::IntegrationTest
  3. def setup
  4. @admin = users(:admin)
  5. @student = users(:billy)
  6. @course = courses(:two)
  7. @course_participation = course_participations(:two)
  8. log_in_as @admin
  9. end
  10. test "should create valid course participation" do
  11. get course_path @course
  12. assert_difference 'CourseParticipation.count', 1 do
  13. post course_participations_path,
  14. params: { course_participation: {
  15. course_id: @course.id, user_id: @student.id
  16. } }
  17. end
  18. assert_redirected_to course_path @course
  19. end
  20. test "should delete course participation" do
  21. assert_difference 'CourseParticipation.count', -1 do
  22. delete course_participation_path @course_participation
  23. end
  24. assert_redirected_to course_path courses(:one)
  25. end
  26. end