From 7a61d5a9838ee8afdda7536d7605533cbf7900ea Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Mon, 27 Feb 2017 10:39:59 +0100 Subject: [PATCH] tests --- spec/controllers/sessions_controller_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 2d837522..50fef8d6 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -28,6 +28,7 @@ describe SessionsController do describe 'POST #create_through_lti' do let(:exercise) { FactoryGirl.create(:dummy) } + let(:exercise2) { FactoryGirl.create(:dummy) } let(:nonce) { SecureRandom.hex } before(:each) { I18n.locale = I18n.default_locale } @@ -135,6 +136,17 @@ describe SessionsController do post :create_through_lti, custom_locale: locale, custom_token: ProxyExercise.first.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id expect(controller).to redirect_to(implement_exercise_path(exercise.id)) end + + it 'recommends only exercises who are 1 degree more complicated than what user has seen' do + # dummy user has no exercises finished, therefore his highest difficulty is 0 + FactoryGirl.create(:proxy_exercise, exercises: [exercise, exercise2]) + exercise.expected_difficulty = 3 + exercise.save + exercise2.expected_difficulty = 1 + exercise2.save + post :create_through_lti, custom_locale: locale, custom_token: ProxyExercise.first.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id + expect(controller).to redirect_to(implement_exercise_path(exercise2.id)) + end end end