Fix Rubocop offenses

This commit is contained in:
Sebastian Serth
2023-07-31 08:39:14 +02:00
parent a8f368b861
commit 8f446c04a9
6 changed files with 10 additions and 22 deletions

View File

@ -314,9 +314,7 @@ describe ExercisesController do
before do before do
create(:lti_parameter, external_user: user, exercise:) create(:lti_parameter, external_user: user, exercise:)
submission = build(:submission, exercise:, user:) submission = build(:submission, exercise:, user:)
allow(submission).to receive(:normalized_score).and_return(1) allow(submission).to receive_messages(normalized_score: 1, calculate_score: scoring_response, redirect_to_feedback?: false)
allow(submission).to receive(:calculate_score).and_return(scoring_response)
allow(submission).to receive(:redirect_to_feedback?).and_return(false)
allow(Submission).to receive(:create).and_return(submission) allow(Submission).to receive(:create).and_return(submission)
end end

View File

@ -178,9 +178,8 @@ describe InternalUsersController do
describe 'GET #forgot_password' do describe 'GET #forgot_password' do
context 'when no user is logged in' do context 'when no user is logged in' do
before do before do
allow(controller).to receive(:set_sentry_context).and_return(nil) allow(controller).to receive_messages(set_sentry_context: nil, current_user: nil)
allow(controller).to receive(:current_user).and_return(nil)
get :forgot_password get :forgot_password
end end
@ -190,9 +189,8 @@ describe InternalUsersController do
context 'when a user is already logged in' do context 'when a user is already logged in' do
before do before do
allow(controller).to receive(:set_sentry_context).and_return(nil) allow(controller).to receive_messages(set_sentry_context: nil, current_user: user)
allow(controller).to receive(:current_user).and_return(user)
get :forgot_password get :forgot_password
end end

View File

@ -227,9 +227,8 @@ describe SessionsController do
describe 'GET #new' do describe 'GET #new' do
context 'when no user is logged in' do context 'when no user is logged in' do
before do before do
allow(controller).to receive(:set_sentry_context).and_return(nil) allow(controller).to receive_messages(set_sentry_context: nil, current_user: nil)
allow(controller).to receive(:current_user).and_return(nil)
get :new get :new
end end
@ -239,9 +238,8 @@ describe SessionsController do
context 'when a user is already logged in' do context 'when a user is already logged in' do
before do before do
allow(controller).to receive(:set_sentry_context).and_return(nil) allow(controller).to receive_messages(set_sentry_context: nil, current_user: build(:teacher))
allow(controller).to receive(:current_user).and_return(build(:teacher))
get :new get :new
end end

View File

@ -9,10 +9,8 @@ describe 'yaml config files' do
next unless /.*.\.yml/.match?(path) next unless /.*.\.yml/.match?(path)
before do before do
allow(Rails).to receive(:root).and_return(Pathname.new('/tmp'))
app = instance_double Rails::Application app = instance_double Rails::Application
allow(Rails).to receive(:application).and_return app allow(Rails).to receive_messages(root: Pathname.new('/tmp'), application: app)
allow(app).to receive(:credentials).and_return({}) allow(app).to receive(:credentials).and_return({})
end end

View File

@ -6,8 +6,7 @@ describe ExecutionEnvironment do
let(:execution_environment) { described_class.create.tap {|execution_environment| execution_environment.update(network_enabled: nil, privileged_execution: nil) } } let(:execution_environment) { described_class.create.tap {|execution_environment| execution_environment.update(network_enabled: nil, privileged_execution: nil) } }
it 'validates that the Docker image works' do it 'validates that the Docker image works' do
allow(execution_environment).to receive(:validate_docker_image?).and_return(true) allow(execution_environment).to receive_messages(validate_docker_image?: true, working_docker_image?: true)
allow(execution_environment).to receive(:working_docker_image?).and_return(true)
execution_environment.update(build(:ruby).attributes) execution_environment.update(build(:ruby).attributes)
expect(execution_environment).to have_received(:working_docker_image?) expect(execution_environment).to have_received(:working_docker_image?)
end end

View File

@ -56,8 +56,7 @@ describe Runner do
let(:runner) { described_class.create } let(:runner) { described_class.create }
before do before do
allow(strategy_class).to receive(:request_from_management).and_return(runner_id) allow(strategy_class).to receive_messages(request_from_management: runner_id, new: strategy)
allow(strategy_class).to receive(:new).and_return(strategy)
end end
it 'delegates to its strategy' do it 'delegates to its strategy' do
@ -73,8 +72,7 @@ describe Runner do
let(:connection) { instance_double(Runner::Connection) } let(:connection) { instance_double(Runner::Connection) }
before do before do
allow(strategy_class).to receive(:request_from_management).and_return(runner_id) allow(strategy_class).to receive_messages(request_from_management: runner_id, new: strategy)
allow(strategy_class).to receive(:new).and_return(strategy)
allow(event_loop).to receive(:wait) allow(event_loop).to receive(:wait)
allow(connection).to receive(:error).and_return(nil) allow(connection).to receive(:error).and_return(nil)
allow(Runner::EventLoop).to receive(:new).and_return(event_loop) allow(Runner::EventLoop).to receive(:new).and_return(event_loop)
@ -128,8 +126,7 @@ describe Runner do
let(:runner) { described_class.create } let(:runner) { described_class.create }
before do before do
allow(strategy_class).to receive(:request_from_management).and_return(runner_id) allow(strategy_class).to receive_messages(request_from_management: runner_id, new: strategy)
allow(strategy_class).to receive(:new).and_return(strategy)
end end
it 'delegates to its strategy' do it 'delegates to its strategy' do