Skip to content

Commit 66f142e

Browse files
authored
refactor: remove streamless tutorials (#580)
* refactor: ensure tutorial stream is required for new tutorial * test: ensure all tests supply tutorial stream abbreviation * test: ensure tutorial stream abbreviation is supplied
1 parent 9bb64fd commit 66f142e

File tree

3 files changed

+203
-53
lines changed

3 files changed

+203
-53
lines changed

app/api/tutorials_api.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class TutorialsApi < Grape::API
6565
requires :meeting_location, type: String, desc: 'The tutorials location', allow_blank: false
6666
requires :meeting_day, type: String, desc: 'Day of the tutorial', allow_blank: false
6767
requires :meeting_time, type: String, desc: 'Time of the tutorial', allow_blank: false
68-
optional :tutorial_stream_abbr, type: String, desc: 'Abbreviation of the associated tutorial stream', allow_blank: false
68+
requires :tutorial_stream_abbr, type: String, desc: 'Abbreviation of the associated tutorial stream', allow_blank: false
6969
end
7070
end
7171
post '/tutorials' do
@@ -83,6 +83,10 @@ class TutorialsApi < Grape::API
8383
tutorial_stream_abbr = tut_params[:tutorial_stream_abbr]
8484
tutorial_stream = unit.tutorial_streams.find_by!(abbreviation: tutorial_stream_abbr) unless tutorial_stream_abbr.nil?
8585

86+
unless tutorial_stream
87+
error!({ error: 'Tutorial must belong to a tutorial stream' }, 403)
88+
end
89+
8690
tutorial = unit.add_tutorial(tut_params[:meeting_day], tut_params[:meeting_time], tut_params[:meeting_location], tutor, campus, tut_params[:capacity], tut_params[:abbreviation], tutorial_stream)
8791

8892
present tutorial, with: Entities::TutorialEntity

0 commit comments

Comments
 (0)