Skip to content

Commit 9c8dc79

Browse files
committed
Error Handling including spec for wrong ID-Hashes
1 parent 4eaf5f3 commit 9c8dc79

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

evaluationserver/app/controllers/experiments_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def start
8080
end
8181

8282
def conduct
83+
if @participant_experiment_step.nil?
84+
render :layout => 'blank', :status => :error, :text => 'No such step'
85+
return
86+
end
87+
88+
8389
unless @participant_experiment_step.experiment_step.step.scenes.empty?
8490

8591

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
require 'rails_helper'
22

33
RSpec.describe ExperimentsController, type: :controller do
4-
4+
describe "GET conduct" do
5+
it "Raises controlled error on wrong experiment" do
6+
@experiment = create(:experiment_with_static_text)
7+
get 'conduct', :params => {:id_hash => @experiment.id_hash} ## this is the wrong type of hash
8+
expect(response).to have_http_status(:error)
9+
end
10+
end
511
end

0 commit comments

Comments
 (0)