Skip to content

Commit

Permalink
Fix legacy 'exercises' path support
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Oct 10, 2024
1 parent 6764da6 commit 073cdeb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ def set_submissions
end

@series = Series.find(params[:series_id]) if params[:series_id]
@activity = Exercise.find(params[:activity_id]) if params[:activity_id]
# both /activities/:id/submissions and /exercises/:id/submissions are valid routes
activity_id = params[:activity_id] || params[:exercise_id]
@activity = Exercise.find(activity_id) if activity_id
@judge = Judge.find(params[:judge_id]) if params[:judge_id]

if @activity
Expand Down
7 changes: 7 additions & 0 deletions test/controllers/submissions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,11 @@ def expected_score_string(*args)

assert_response :ok
end

test 'should be able to use legacy paths containing `exercise`' do
course = create :course, series_count: 1, activities_per_series: 1
get course_series_exercise_submissions_path(course, course.series.first, course.series.first.exercises.first)

assert_response :ok
end
end

0 comments on commit 073cdeb

Please sign in to comment.