fixing tests p1

This commit is contained in:
Tom Staubitz
2017-01-12 18:12:36 +01:00
parent e4daa7ece3
commit 5fe12bfa78
11 changed files with 41 additions and 135 deletions

View File

@@ -17,11 +17,8 @@ describe Lti do
describe '#clear_lti_session_data' do
it 'clears the session' do
#Todo replace session with lti_parameter
expect(controller.session).to receive(:delete).with(:consumer_id)
expect(controller.session).to receive(:delete).with(:external_user_id)
# expect(controller.session).to receive(:delete).with(:lti_parameters)
#Todo check that there are no more LtiParameters for this user/consumer/(exercise?)
controller.send(:clear_lti_session_data)
end
end
@@ -108,10 +105,13 @@ describe Lti do
describe '#send_score' do
let(:consumer) { FactoryGirl.create(:consumer) }
let(:score) { 0.5 }
#let(:exercise) { FactoryGirl.create(:math) }
let(:submission) { FactoryGirl.create(:submission) }
let!(:lti_parameter) { FactoryGirl.create(:lti_parameter)}
context 'with an invalid score' do
it 'raises an exception' do
expect { controller.send(:send_score, Lti::MAXIMUM_SCORE * 2) }.to raise_error(Lti::Error)
expect { controller.send(:send_score, Lti::MAXIMUM_SCORE * 2, submission.exercise_id, submission.user_id) }.to raise_error(Lti::Error)
end
end
@@ -168,9 +168,10 @@ describe Lti do
describe '#store_lti_session_data' do
#Todo replace session with lti_parameter
let(:parameters) { {} }
before_count = LtiParameter.count
before(:each) { controller.instance_variable_set(:@current_user, FactoryGirl.create(:external_user)) }
#Todo do this with lti_parameter object
# after(:each) { controller.send(:store_lti_session_data, consumer: FactoryGirl.build(:consumer), parameters: parameters) }
after(:each) { controller.send(:store_lti_session_data, consumer: FactoryGirl.build(:consumer), parameters: parameters) }
it 'stores data in the session' do
#Todo replace session with lti_parameter
@@ -178,6 +179,7 @@ describe Lti do
expect(controller.session).to receive(:[]=).with(:external_user_id, anything)
# expect(controller.session).to receive(:[]=).with(:lti_parameters, kind_of(Hash))
#Todo it creates an LtiParameter Object
expect(LtiParameter.count).to eq(before_count + 1)
end
it 'stores only selected tuples' do

View File

@@ -0,0 +1,12 @@
FactoryGirl.define do
factory :lti_parameter do
association :consumers_id, factory: :consumer
association :exercises_id, factory: :math
association :external_users_id, factory: :external_user
trait :lti_parameters do
JSON.parse('{"lis_result_sourcedid": "c2db0c7c-4411-4b27-a52b-ddfc3dc32065", "lis_outcome_service_url": "http://172.16.54.235:3000/courses/0132156a-9afb-434d-83cc-704780104105/sections/21c6c6f4-1fb6-43b4-af3c-04fdc098879e/items/999b1fe6-d4b6-47b7-a577-ea2b4b1041ec/tool_grading", "launch_presentation_return_url": "http://172.16.54.235:3000/courses/0132156a-9afb-434d-83cc-704780104105/sections/21c6c6f4-1fb6-43b4-af3c-04fdc098879e/items/999b1fe6-d4b6-47b7-a577-ea2b4b1041ec/tool_return"}')
end
end
end

View File

@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :submission do
cause 'save'
created_by_external_user
association :exercise, factory: :fibonacci
association :exercise, factory: :math
after(:create) do |submission|
submission.exercise.files.editable.visible.each do |file|

View File

@@ -3,8 +3,8 @@ require 'seeds_helper'
describe DockerClient, docker: true do
let(:command) { 'whoami' }
let(:docker_client) { described_class.new(execution_environment: FactoryGirl.build(:ruby), user: FactoryGirl.build(:admin)) }
let(:execution_environment) { FactoryGirl.build(:ruby) }
let(:docker_client) { described_class.new(execution_environment: FactoryGirl.build(:java), user: FactoryGirl.build(:admin)) }
let(:execution_environment) { FactoryGirl.build(:java) }
let(:image) { double }
let(:submission) { FactoryGirl.create(:submission) }
let(:workspace_path) { '/tmp' }