Update bundle (with newest rubocop version) and fix offenses

This commit is contained in:
Sebastian Serth
2022-01-03 18:11:17 +01:00
parent 57e32611ed
commit ea85519163
93 changed files with 968 additions and 985 deletions

View File

@ -8,11 +8,11 @@ end
describe FileParameters do
let(:controller) { Controller.new }
let(:hello_world) { FactoryBot.create(:hello_world) }
let(:hello_world) { create(:hello_world) }
describe '#reject_illegal_file_attributes!' do
def file_accepted?(file)
files = [[0, FactoryBot.attributes_for(:file, context: hello_world, file_id: file.id)]]
files = [[0, attributes_for(:file, context: hello_world, file_id: file.id)]]
filtered_files = controller.send(:reject_illegal_file_attributes, hello_world, files)
files.eql?(filtered_files)
end
@ -24,31 +24,31 @@ describe FileParameters do
end
it 'new file' do
submission = FactoryBot.create(:submission, exercise: hello_world, id: 1337)
new_file = FactoryBot.create(:file, context: submission)
submission = create(:submission, exercise: hello_world, id: 1337)
new_file = create(:file, context: submission)
expect(file_accepted?(new_file)).to be true
end
end
describe 'rejects' do
it 'file of different exercise' do
fibonacci = FactoryBot.create(:fibonacci, allow_file_creation: true)
other_exercises_file = FactoryBot.create(:file, context: fibonacci)
fibonacci = create(:fibonacci, allow_file_creation: true)
other_exercises_file = create(:file, context: fibonacci)
expect(file_accepted?(other_exercises_file)).to be false
end
it 'hidden file' do
hidden_file = FactoryBot.create(:file, context: hello_world, hidden: true)
hidden_file = create(:file, context: hello_world, hidden: true)
expect(file_accepted?(hidden_file)).to be false
end
it 'read only file' do
read_only_file = FactoryBot.create(:file, context: hello_world, read_only: true)
read_only_file = create(:file, context: hello_world, read_only: true)
expect(file_accepted?(read_only_file)).to be false
end
it 'non existent file' do
non_existent_file = FactoryBot.build(:file, context: hello_world, id: 42)
non_existent_file = build(:file, context: hello_world, id: 42)
expect(file_accepted?(non_existent_file)).to be false
end
end

View File

@ -13,7 +13,7 @@ describe Lti do
describe '#build_tool_provider' do
it 'instantiates a tool provider' do
expect(IMS::LTI::ToolProvider).to receive(:new)
controller.send(:build_tool_provider, consumer: FactoryBot.build(:consumer), parameters: {})
controller.send(:build_tool_provider, consumer: build(:consumer), parameters: {})
end
end
@ -101,12 +101,12 @@ describe Lti do
end
describe '#send_score' do
let(:consumer) { FactoryBot.create(:consumer) }
let(:consumer) { create(:consumer) }
let(:score) { 0.5 }
let(:submission) { FactoryBot.create(:submission) }
let(:submission) { create(:submission) }
before do
FactoryBot.create(:lti_parameter, consumers_id: consumer.id, external_users_id: submission.user_id, exercises_id: submission.exercise_id)
create(:lti_parameter, consumers_id: consumer.id, external_users_id: submission.user_id, exercises_id: submission.exercise_id)
end
context 'with an invalid score' do
@ -168,18 +168,18 @@ describe Lti do
let(:parameters) { ActionController::Parameters.new({}) }
it 'stores data in the session' do
controller.instance_variable_set(:@current_user, FactoryBot.create(:external_user))
controller.instance_variable_set(:@exercise, FactoryBot.create(:fibonacci))
controller.instance_variable_set(:@current_user, create(:external_user))
controller.instance_variable_set(:@exercise, create(:fibonacci))
expect(controller.session).to receive(:[]=).with(:external_user_id, anything)
expect(controller.session).to receive(:[]=).with(:lti_parameters_id, anything)
controller.send(:store_lti_session_data, consumer: FactoryBot.build(:consumer), parameters: parameters)
controller.send(:store_lti_session_data, consumer: build(:consumer), parameters: parameters)
end
it 'creates an LtiParameter Object' do
before_count = LtiParameter.count
controller.instance_variable_set(:@current_user, FactoryBot.create(:external_user))
controller.instance_variable_set(:@exercise, FactoryBot.create(:fibonacci))
controller.send(:store_lti_session_data, consumer: FactoryBot.build(:consumer), parameters: parameters)
controller.instance_variable_set(:@current_user, create(:external_user))
controller.instance_variable_set(:@exercise, create(:fibonacci))
controller.send(:store_lti_session_data, consumer: build(:consumer), parameters: parameters)
expect(LtiParameter.count).to eq(before_count + 1)
end
end