Fix rubocop offenses - Requires Ruby 3.1+
This commit is contained in:
@ -76,7 +76,7 @@ describe ApplicationController do
|
||||
context "when using the 'locale' parameter" do
|
||||
it 'overwrites the session' do
|
||||
expect(session).to receive(:[]=).with(:locale, locale)
|
||||
get :welcome, params: {locale: locale}
|
||||
get :welcome, params: {locale:}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -30,7 +30,7 @@ describe CodeOcean::FilesController do
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
let(:submission) { create(:submission, user: user) }
|
||||
let(:submission) { create(:submission, user:) }
|
||||
|
||||
context 'with a valid file' do
|
||||
let(:perform_request) { proc { post :create, params: {code_ocean_file: build(:file, context: submission).attributes, format: :json} } }
|
||||
|
@ -22,7 +22,7 @@ describe CodeharborLinksController do
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
let(:codeharbor_link) { create(:codeharbor_link, user: user) }
|
||||
let(:codeharbor_link) { create(:codeharbor_link, user:) }
|
||||
|
||||
before { get :edit, params: {id: codeharbor_link.id} }
|
||||
|
||||
@ -56,7 +56,7 @@ describe CodeharborLinksController do
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
let(:codeharbor_link) { create(:codeharbor_link, user: user) }
|
||||
let(:codeharbor_link) { create(:codeharbor_link, user:) }
|
||||
let(:put_request) { patch :update, params: {id: codeharbor_link.id, codeharbor_link: params} }
|
||||
let(:params) { {push_url: 'https://foo.bar/push', check_uuid_url: 'https://foo.bar/check', api_key: 'api_key'} }
|
||||
|
||||
@ -91,7 +91,7 @@ describe CodeharborLinksController do
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
let!(:codeharbor_link) { create(:codeharbor_link, user: user) }
|
||||
let!(:codeharbor_link) { create(:codeharbor_link, user:) }
|
||||
let(:destroy_request) { delete :destroy, params: {id: codeharbor_link.id} }
|
||||
|
||||
it 'deletes codeharbor_link' do
|
||||
|
@ -6,7 +6,7 @@ describe CommentsController do
|
||||
render_views
|
||||
|
||||
let(:user) { create(:learner) }
|
||||
let(:rfc_with_comment) { create(:rfc_with_comment, user: user) }
|
||||
let(:rfc_with_comment) { create(:rfc_with_comment, user:) }
|
||||
let(:comment) { rfc_with_comment.comments.first }
|
||||
let(:updated_comment) { comment.reload }
|
||||
let(:perform_request) { proc { put :update, format: :json, params: {id: comment.id, comment: comment_params} } }
|
||||
|
@ -95,7 +95,7 @@ describe ExecutionEnvironmentsController do
|
||||
runner = instance_double Runner
|
||||
allow(Runner).to receive(:for).with(user, execution_environment).and_return runner
|
||||
allow(runner).to receive(:execute_command).and_return({})
|
||||
post :execute_command, params: {command: command, id: execution_environment.id}
|
||||
post :execute_command, params: {command:, id: execution_environment.id}
|
||||
end
|
||||
|
||||
expect_assigns(execution_environment: :execution_environment)
|
||||
|
@ -37,7 +37,7 @@ describe ExercisesController do
|
||||
expect_assigns(exercise: Exercise)
|
||||
|
||||
it 'clones the exercise' do
|
||||
expect_any_instance_of(Exercise).to receive(:duplicate).with(hash_including(public: false, user: user)).and_call_original
|
||||
expect_any_instance_of(Exercise).to receive(:duplicate).with(hash_including(public: false, user:)).and_call_original
|
||||
expect { perform_request.call }.to change(Exercise, :count).by(1)
|
||||
end
|
||||
|
||||
@ -78,7 +78,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
context 'when including a file' do
|
||||
let(:perform_request) { proc { post :create, params: {exercise: exercise_attributes.merge(files_attributes: files_attributes)} } }
|
||||
let(:perform_request) { proc { post :create, params: {exercise: exercise_attributes.merge(files_attributes:)} } }
|
||||
|
||||
context 'when specifying the file content within the form' do
|
||||
let(:files_attributes) { {'0' => build(:file).attributes} }
|
||||
@ -89,7 +89,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
context 'when uploading a file' do
|
||||
let(:files_attributes) { {'0' => build(:file, file_type: file_type).attributes.merge(content: uploaded_file)} }
|
||||
let(:files_attributes) { {'0' => build(:file, file_type:).attributes.merge(content: uploaded_file)} }
|
||||
|
||||
context 'when uploading a binary file' do
|
||||
let(:file_path) { Rails.root.join('db/seeds/audio_video/devstories.mp4') }
|
||||
@ -255,14 +255,14 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
describe 'GET #external_user_statistics' do
|
||||
let(:perform_request) { get :external_user_statistics, params: params }
|
||||
let(:perform_request) { get :external_user_statistics, params: }
|
||||
let(:params) { {id: exercise.id, external_user_id: external_user.id} }
|
||||
let(:external_user) { create(:external_user) }
|
||||
|
||||
before do
|
||||
2.times { create(:submission, cause: 'autosave', user: external_user, exercise: exercise) }
|
||||
2.times { create(:submission, cause: 'run', user: external_user, exercise: exercise) }
|
||||
create(:submission, cause: 'assess', user: external_user, exercise: exercise)
|
||||
2.times { create(:submission, cause: 'autosave', user: external_user, exercise:) }
|
||||
2.times { create(:submission, cause: 'run', user: external_user, exercise:) }
|
||||
create(:submission, cause: 'assess', user: external_user, exercise:)
|
||||
end
|
||||
|
||||
context 'when viewing the default submission statistics page without a parameter' do
|
||||
@ -312,8 +312,8 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
before do
|
||||
create(:lti_parameter, external_user: user, exercise: exercise)
|
||||
submission = build(:submission, exercise: exercise, user: user)
|
||||
create(:lti_parameter, external_user: user, exercise:)
|
||||
submission = build(:submission, exercise:, user:)
|
||||
allow(submission).to receive(:normalized_score).and_return(1)
|
||||
allow(submission).to receive(:calculate_score).and_return(scoring_response)
|
||||
allow(Submission).to receive(:create).and_return(submission)
|
||||
@ -404,13 +404,13 @@ describe ExercisesController do
|
||||
render_views
|
||||
|
||||
let(:post_request) { post :export_external_check, params: {id: exercise.id} }
|
||||
let!(:codeharbor_link) { create(:codeharbor_link, user: user) }
|
||||
let(:external_check_hash) { {message: message, uuid_found: true, update_right: update_right, error: error} }
|
||||
let!(:codeharbor_link) { create(:codeharbor_link, user:) }
|
||||
let(:external_check_hash) { {message:, uuid_found: true, update_right:, error:} }
|
||||
let(:message) { 'message' }
|
||||
let(:update_right) { true }
|
||||
let(:error) { nil }
|
||||
|
||||
before { allow(ExerciseService::CheckExternal).to receive(:call).with(uuid: exercise.uuid, codeharbor_link: codeharbor_link).and_return(external_check_hash) }
|
||||
before { allow(ExerciseService::CheckExternal).to receive(:call).with(uuid: exercise.uuid, codeharbor_link:).and_return(external_check_hash) }
|
||||
|
||||
it 'renders the correct contents as json' do
|
||||
post_request
|
||||
@ -457,14 +457,14 @@ describe ExercisesController do
|
||||
describe 'POST #export_external_confirm' do
|
||||
render_views
|
||||
|
||||
let!(:codeharbor_link) { create(:codeharbor_link, user: user) }
|
||||
let!(:codeharbor_link) { create(:codeharbor_link, user:) }
|
||||
let(:post_request) { post :export_external_confirm, params: {id: exercise.id, codeharbor_link: codeharbor_link.id} }
|
||||
let(:error) { nil }
|
||||
let(:zip) { 'zip' }
|
||||
|
||||
before do
|
||||
allow(ProformaService::ExportTask).to receive(:call).with(exercise: exercise).and_return(zip)
|
||||
allow(ExerciseService::PushExternal).to receive(:call).with(zip: zip, codeharbor_link: codeharbor_link).and_return(error)
|
||||
allow(ProformaService::ExportTask).to receive(:call).with(exercise:).and_return(zip)
|
||||
allow(ExerciseService::PushExternal).to receive(:call).with(zip:, codeharbor_link:).and_return(error)
|
||||
end
|
||||
|
||||
it 'renders correct response' do
|
||||
@ -493,9 +493,9 @@ describe ExercisesController do
|
||||
|
||||
describe 'POST #import_uuid_check' do
|
||||
let(:exercise) { create(:dummy, uuid: SecureRandom.uuid) }
|
||||
let!(:codeharbor_link) { create(:codeharbor_link, user: user) }
|
||||
let!(:codeharbor_link) { create(:codeharbor_link, user:) }
|
||||
let(:uuid) { exercise.reload.uuid }
|
||||
let(:post_request) { post :import_uuid_check, params: {uuid: uuid} }
|
||||
let(:post_request) { post :import_uuid_check, params: {uuid:} }
|
||||
let(:headers) { {'Authorization' => "Bearer #{codeharbor_link.api_key}"} }
|
||||
|
||||
before { request.headers.merge! headers }
|
||||
@ -542,7 +542,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
describe 'POST #import_task' do
|
||||
let(:codeharbor_link) { create(:codeharbor_link, user: user) }
|
||||
let(:codeharbor_link) { create(:codeharbor_link, user:) }
|
||||
let!(:imported_exercise) { create(:fibonacci) }
|
||||
let(:post_request) { post :import_task, body: zip_file_content }
|
||||
let(:zip_file_content) { 'zipped task xml' }
|
||||
@ -560,7 +560,7 @@ describe ExercisesController do
|
||||
|
||||
it 'calls service' do
|
||||
post_request
|
||||
expect(ProformaService::Import).to have_received(:call).with(zip: be_a(Tempfile).and(has_content(zip_file_content)), user: user)
|
||||
expect(ProformaService::Import).to have_received(:call).with(zip: be_a(Tempfile).and(has_content(zip_file_content)), user:)
|
||||
end
|
||||
|
||||
context 'when import fails with ProformaError' do
|
||||
|
@ -61,7 +61,7 @@ describe InternalUsersController do
|
||||
context 'with an already activated user' do
|
||||
before do
|
||||
user.activate!
|
||||
put :activate, params: {id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: password}}
|
||||
put :activate, params: {id: user.id, internal_user: {activation_token: user.activation_token, password:, password_confirmation: password}}
|
||||
end
|
||||
|
||||
expect_redirect(:root)
|
||||
@ -80,7 +80,7 @@ describe InternalUsersController do
|
||||
end
|
||||
|
||||
context 'without a valid password confirmation' do
|
||||
before { put :activate, params: {id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: ''}} }
|
||||
before { put :activate, params: {id: user.id, internal_user: {activation_token: user.activation_token, password:, password_confirmation: ''}} }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
|
||||
@ -92,7 +92,7 @@ describe InternalUsersController do
|
||||
end
|
||||
|
||||
context 'with valid preconditions' do
|
||||
before { put :activate, params: {id: user.id, internal_user: {activation_token: user.activation_token, password: password, password_confirmation: password}} }
|
||||
before { put :activate, params: {id: user.id, internal_user: {activation_token: user.activation_token, password:, password_confirmation: password}} }
|
||||
|
||||
expect_assigns(user: InternalUser)
|
||||
|
||||
@ -278,7 +278,7 @@ describe InternalUsersController do
|
||||
let(:password) { 'foo' }
|
||||
|
||||
context 'with a matching password confirmation' do
|
||||
let(:perform_request) { proc { put :reset_password, params: {internal_user: {password: password, password_confirmation: password}, id: user.id, token: user.reset_password_token} } }
|
||||
let(:perform_request) { proc { put :reset_password, params: {internal_user: {password:, password_confirmation: password}, id: user.id, token: user.reset_password_token} } }
|
||||
|
||||
before { perform_request.call }
|
||||
|
||||
@ -310,7 +310,7 @@ describe InternalUsersController do
|
||||
|
||||
context 'without a matching password confirmation' do
|
||||
before do
|
||||
put :reset_password, params: {internal_user: {password: password, password_confirmation: ''}, id: user.id, token: user.reset_password_token}
|
||||
put :reset_password, params: {internal_user: {password:, password_confirmation: ''}, id: user.id, token: user.reset_password_token}
|
||||
end
|
||||
|
||||
expect_assigns(user: :user)
|
||||
|
@ -19,7 +19,7 @@ describe RequestForCommentsController do
|
||||
|
||||
it 'shows only rfc`s belonging to selected study group' do
|
||||
my_study_group = create(:study_group)
|
||||
rfc_within_my_study_group = create(:rfc, user: user)
|
||||
rfc_within_my_study_group = create(:rfc, user:)
|
||||
user.update(study_groups: [my_study_group])
|
||||
rfc_within_my_study_group.submission.update(study_group: my_study_group)
|
||||
|
||||
|
@ -9,13 +9,13 @@ describe SessionsController do
|
||||
|
||||
describe 'POST #create' do
|
||||
let(:password) { attributes_for(:teacher)[:password] }
|
||||
let(:user) { InternalUser.create(user_attributes.merge(password: password)) }
|
||||
let(:user) { InternalUser.create(user_attributes.merge(password:)) }
|
||||
let(:user_attributes) { build(:teacher).attributes }
|
||||
|
||||
context 'with valid credentials' do
|
||||
before do
|
||||
user.activate!
|
||||
post :create, params: {email: user.email, password: password, remember_me: 1}
|
||||
post :create, params: {email: user.email, password:, remember_me: 1}
|
||||
end
|
||||
|
||||
expect_flash_message(:notice, :'sessions.create.success')
|
||||
@ -113,7 +113,7 @@ describe SessionsController do
|
||||
|
||||
context 'when LTI outcomes are supported' do
|
||||
# The expected message should be localized in the requested localization
|
||||
let(:message) { I18n.t('sessions.create_through_lti.session_with_outcome', consumer: consumer, locale: locale) }
|
||||
let(:message) { I18n.t('sessions.create_through_lti.session_with_outcome', consumer:, locale:) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:lti_outcome_service?).and_return(true)
|
||||
@ -125,7 +125,7 @@ describe SessionsController do
|
||||
|
||||
context 'when LTI outcomes are not supported' do
|
||||
# The expected message should be localized in the requested localization
|
||||
let(:message) { I18n.t('sessions.create_through_lti.session_without_outcome', consumer: consumer, locale: locale) }
|
||||
let(:message) { I18n.t('sessions.create_through_lti.session_without_outcome', consumer:, locale:) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:lti_outcome_service?).and_return(false)
|
||||
|
@ -116,7 +116,7 @@ describe SubmissionsController do
|
||||
context 'with an invalid filename' do
|
||||
let(:filename) { SecureRandom.hex }
|
||||
|
||||
before { get :render_file, params: {filename: filename, id: submission.id, token: token} }
|
||||
before { get :render_file, params: {filename:, id: submission.id, token:} }
|
||||
|
||||
expect_http_status(:not_found)
|
||||
end
|
||||
@ -125,7 +125,7 @@ describe SubmissionsController do
|
||||
let(:submission) { create(:submission, exercise: create(:audio_video)) }
|
||||
let(:filename) { file.name_with_extension }
|
||||
|
||||
before { get :render_file, params: {filename: filename, id: submission.id, token: token} }
|
||||
before { get :render_file, params: {filename:, id: submission.id, token:} }
|
||||
|
||||
context 'with a binary file' do
|
||||
let(:file) { submission.collect_files.detect {|file| file.file_type.file_extension == '.mp4' } }
|
||||
|
Reference in New Issue
Block a user