From c75f52f2c8843f3c5ec39e8ac9897457ceb186a7 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Mon, 24 Oct 2022 12:10:10 +0200 Subject: [PATCH] Fix Rubocop offenses --- app/controllers/consumers_controller.rb | 30 +++++------ .../execution_environments_controller.rb | 40 +++++++------- .../exercise_collections_controller.rb | 14 ++--- app/controllers/exercises_controller.rb | 54 +++++++++---------- app/controllers/file_types_controller.rb | 30 +++++------ app/controllers/internal_users_controller.rb | 48 ++++++++--------- app/controllers/proxy_exercises_controller.rb | 44 +++++++-------- app/controllers/sessions_controller.rb | 32 +++++------ app/controllers/submissions_controller.rb | 18 +++---- app/controllers/tags_controller.rb | 30 +++++------ app/controllers/tips_controller.rb | 30 +++++------ .../user_exercise_feedbacks_controller.rb | 44 +++++++-------- lib/tasks/export_public_exercises.rake | 6 +-- spec/controllers/ping_controller_spec.rb | 2 +- .../request_for_comments_filter_spec.rb | 2 +- .../strategy/docker_container_pool_spec.rb | 2 +- spec/lib/runner/strategy/poseidon_spec.rb | 2 +- spec/models/runner_spec.rb | 12 ++--- spec/models/submission_spec.rb | 2 +- ...pec.rb => ping_controller_routing_spec.rb} | 2 +- 20 files changed, 222 insertions(+), 222 deletions(-) rename spec/routing/{ping_routing_spec.rb => ping_controller_routing_spec.rb} (80%) diff --git a/app/controllers/consumers_controller.rb b/app/controllers/consumers_controller.rb index 2bf09d5b..7f5cc1e2 100644 --- a/app/controllers/consumers_controller.rb +++ b/app/controllers/consumers_controller.rb @@ -10,31 +10,29 @@ class ConsumersController < ApplicationController end private :authorize! - def create - @consumer = Consumer.new(consumer_params) + def index + @consumers = Consumer.paginate(page: params[:page], per_page: per_page_param) authorize! - create_and_respond(object: @consumer) end - def destroy - destroy_and_respond(object: @consumer) - end + def show; end - def edit; end + def new + @consumer = Consumer.new(oauth_key: SecureRandom.hex, oauth_secret: SecureRandom.hex) + authorize! + end def consumer_params params[:consumer].permit(:name, :oauth_key, :oauth_secret) if params[:consumer].present? end private :consumer_params - def index - @consumers = Consumer.paginate(page: params[:page], per_page: per_page_param) - authorize! - end + def edit; end - def new - @consumer = Consumer.new(oauth_key: SecureRandom.hex, oauth_secret: SecureRandom.hex) + def create + @consumer = Consumer.new(consumer_params) authorize! + create_and_respond(object: @consumer) end def set_consumer @@ -43,9 +41,11 @@ class ConsumersController < ApplicationController end private :set_consumer - def show; end - def update update_and_respond(object: @consumer, params: consumer_params) end + + def destroy + destroy_and_respond(object: @consumer) + end end diff --git a/app/controllers/execution_environments_controller.rb b/app/controllers/execution_environments_controller.rb index 0f400196..8770deee 100644 --- a/app/controllers/execution_environments_controller.rb +++ b/app/controllers/execution_environments_controller.rb @@ -12,19 +12,20 @@ class ExecutionEnvironmentsController < ApplicationController end private :authorize! - def create - @execution_environment = ExecutionEnvironment.new(execution_environment_params) + def index + @execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param) authorize! - create_and_respond(object: @execution_environment) end - def destroy - destroy_and_respond(object: @execution_environment) + def show + if @execution_environment.testing_framework? + @testing_framework_adapter = TestingFrameworkAdapter.descendants.find {|klass| klass.name == @execution_environment.testing_framework } + end end - def edit - # Add the current execution_environment if not already present in the list - @docker_images |= [@execution_environment.docker_image] + def new + @execution_environment = ExecutionEnvironment.new + authorize! end def execute_command @@ -122,21 +123,22 @@ class ExecutionEnvironmentsController < ApplicationController end private :execution_environment_params - def index - @execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param) - authorize! + def edit + # Add the current execution_environment if not already present in the list + @docker_images |= [@execution_environment.docker_image] end - def new - @execution_environment = ExecutionEnvironment.new + def create + @execution_environment = ExecutionEnvironment.new(execution_environment_params) authorize! + create_and_respond(object: @execution_environment) end def set_docker_images @docker_images ||= ExecutionEnvironment.pluck(:docker_image) @docker_images += Runner.strategy_class.available_images rescue Runner::Error => e - flash[:warning] = html_escape e.message + flash.now[:warning] = html_escape e.message ensure @docker_images = @docker_images.sort.uniq end @@ -158,16 +160,14 @@ class ExecutionEnvironmentsController < ApplicationController def shell; end - def show - if @execution_environment.testing_framework? - @testing_framework_adapter = TestingFrameworkAdapter.descendants.find {|klass| klass.name == @execution_environment.testing_framework } - end - end - def update update_and_respond(object: @execution_environment, params: execution_environment_params) end + def destroy + destroy_and_respond(object: @execution_environment) + end + def sync_to_runner_management return unless Runner.management_active? diff --git a/app/controllers/exercise_collections_controller.rb b/app/controllers/exercise_collections_controller.rb index 40d49e64..f6236916 100644 --- a/app/controllers/exercise_collections_controller.rb +++ b/app/controllers/exercise_collections_controller.rb @@ -17,6 +17,8 @@ class ExerciseCollectionsController < ApplicationController authorize! end + def edit; end + def create @exercise_collection = ExerciseCollection.new authorize! @@ -24,18 +26,16 @@ class ExerciseCollectionsController < ApplicationController update_and_respond(object: @exercise_collection, params: exercise_collection_params) end - def destroy - authorize! - destroy_and_respond(object: @exercise_collection) - end - - def edit; end - def update authorize! update_and_respond(object: @exercise_collection, params: exercise_collection_params) end + def destroy + authorize! + destroy_and_respond(object: @exercise_collection) + end + def statistics; end private diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 883112ff..48595918 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -73,22 +73,22 @@ class ExercisesController < ApplicationController private :collect_paths - def create - @exercise = Exercise.new(exercise_params&.except(:tips)) + def index + @search = policy_scope(Exercise).ransack(params[:q]) + @exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page], per_page: per_page_param) + authorize! + end + + def show + # Show exercise details for teachers and admins + end + + def new + @exercise = Exercise.new authorize! - handle_exercise_tips collect_set_and_unset_exercise_tags - return if performed? - - create_and_respond(object: @exercise, params: exercise_params_with_tags) end - def destroy - destroy_and_respond(object: @exercise) - end - - def edit; end - def feedback authorize! @feedbacks = @exercise.user_exercise_feedbacks.paginate(page: params[:page], per_page: per_page_param) @@ -424,16 +424,16 @@ class ExercisesController < ApplicationController end end - def index - @search = policy_scope(Exercise).ransack(params[:q]) - @exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page], per_page: per_page_param) - authorize! - end + def edit; end - def new - @exercise = Exercise.new + def create + @exercise = Exercise.new(exercise_params&.except(:tips)) authorize! + handle_exercise_tips collect_set_and_unset_exercise_tags + return if performed? + + create_and_respond(object: @exercise, params: exercise_params_with_tags) end def not_authorized_for_exercise(_exception) @@ -489,8 +489,11 @@ class ExercisesController < ApplicationController private :collect_set_and_unset_exercise_tags - def show - # Show exercise details for teachers and admins + def update + handle_exercise_tips + return if performed? + + update_and_respond(object: @exercise, params: exercise_params_with_tags) end def reload @@ -579,7 +582,7 @@ class ExercisesController < ApplicationController if response[:status] == 'success' if response[:score_sent] != @submission.normalized_score # Score has been reduced due to the passed deadline - flash[:warning] = I18n.t('exercises.submit.too_late') + flash.now[:warning] = I18n.t('exercises.submit.too_late') flash.keep(:warning) end redirect_after_submit @@ -593,11 +596,8 @@ class ExercisesController < ApplicationController private :transmit_lti_score - def update - handle_exercise_tips - return if performed? - - update_and_respond(object: @exercise, params: exercise_params_with_tags) + def destroy + destroy_and_respond(object: @exercise) end def study_group_dashboard diff --git a/app/controllers/file_types_controller.rb b/app/controllers/file_types_controller.rb index 2f7fa37d..d51d61b6 100644 --- a/app/controllers/file_types_controller.rb +++ b/app/controllers/file_types_controller.rb @@ -11,17 +11,17 @@ class FileTypesController < ApplicationController end private :authorize! - def create - @file_type = FileType.new(file_type_params) + def index + @file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param) authorize! - create_and_respond(object: @file_type) end - def destroy - destroy_and_respond(object: @file_type) - end + def show; end - def edit; end + def new + @file_type = FileType.new + authorize! + end def file_type_params if params[:file_type].present? @@ -32,14 +32,12 @@ class FileTypesController < ApplicationController end private :file_type_params - def index - @file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param) - authorize! - end + def edit; end - def new - @file_type = FileType.new + def create + @file_type = FileType.new(file_type_params) authorize! + create_and_respond(object: @file_type) end def set_editor_modes @@ -56,9 +54,11 @@ class FileTypesController < ApplicationController end private :set_file_type - def show; end - def update update_and_respond(object: @file_type, params: file_type_params) end + + def destroy + destroy_and_respond(object: @file_type) + end end diff --git a/app/controllers/internal_users_controller.rb b/app/controllers/internal_users_controller.rb index 64e80e30..647b100c 100644 --- a/app/controllers/internal_users_controller.rb +++ b/app/controllers/internal_users_controller.rb @@ -31,17 +31,10 @@ class InternalUsersController < ApplicationController end private :change_password - def create - @user = InternalUser.new(internal_user_params) - @user.platform_admin = platform_admin_param if current_user.admin? + def index + @search = InternalUser.ransack(params[:q], {auth_object: current_user}) + @users = @search.result.in_study_group_of(current_user).includes(:consumer).order(:name).paginate(page: params[:page], per_page: per_page_param) authorize! - @user.send(:setup_activation) - create_and_respond(object: @user) do - @user.send(:send_activation_needed_email!) - # The return value is used as a flash message. If this block does not - # have any specific return value, a default success message is shown. - nil - end end def deliver_reset_password_instructions @@ -53,11 +46,13 @@ class InternalUsersController < ApplicationController end private :deliver_reset_password_instructions - def destroy - destroy_and_respond(object: @user) - end + def show; end - def edit; end + def new + @user = InternalUser.new + authorize! + collect_set_and_unset_study_group_memberships + end def forgot_password if request.get? @@ -67,11 +62,7 @@ class InternalUsersController < ApplicationController end end - def index - @search = InternalUser.ransack(params[:q], {auth_object: current_user}) - @users = @search.result.in_study_group_of(current_user).includes(:consumer).order(:name).paginate(page: params[:page], per_page: per_page_param) - authorize! - end + def edit; end def internal_user_params permitted_params = params.require(:internal_user).permit(:consumer_id, :email, :name, study_group_ids: []).presence || {} @@ -95,10 +86,17 @@ class InternalUsersController < ApplicationController end private :platform_admin_param - def new - @user = InternalUser.new + def create + @user = InternalUser.new(internal_user_params) + @user.platform_admin = platform_admin_param if current_user.admin? authorize! - collect_set_and_unset_study_group_memberships + @user.send(:setup_activation) + create_and_respond(object: @user) do + @user.send(:send_activation_needed_email!) + # The return value is used as a flash message. If this block does not + # have any specific return value, a default success message is shown. + nil + end end def render_forgot_password_form @@ -159,8 +157,6 @@ class InternalUsersController < ApplicationController private :collect_set_and_unset_study_group_memberships - def show; end - def update # Let's skip the password validation if the user is edited through # the form by another user. Otherwise, the update might fail if an @@ -169,4 +165,8 @@ class InternalUsersController < ApplicationController @user.platform_admin = platform_admin_param if current_user.admin? update_and_respond(object: @user, params: internal_user_params) end + + def destroy + destroy_and_respond(object: @user) + end end diff --git a/app/controllers/proxy_exercises_controller.rb b/app/controllers/proxy_exercises_controller.rb index 178c26c8..473ae0fe 100644 --- a/app/controllers/proxy_exercises_controller.rb +++ b/app/controllers/proxy_exercises_controller.rb @@ -22,20 +22,19 @@ class ProxyExercisesController < ApplicationController end end - def create - myparams = proxy_exercise_params - myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank) - @proxy_exercise = ProxyExercise.new(myparams) + def index + @search = policy_scope(ProxyExercise).ransack(params[:q]) + @proxy_exercises = @search.result.order(:title).paginate(page: params[:page], per_page: per_page_param) authorize! - - create_and_respond(object: @proxy_exercise) end - def destroy - destroy_and_respond(object: @proxy_exercise) + def show + @search = @proxy_exercise.exercises.ransack + @exercises = @proxy_exercise.exercises.ransack.result.order(:title) end - def edit + def new + @proxy_exercise = ProxyExercise.new @search = policy_scope(Exercise).ransack(params[:q]) @exercises = @search.result.order(:title) authorize! @@ -49,33 +48,34 @@ class ProxyExercisesController < ApplicationController end private :proxy_exercise_params - def index - @search = policy_scope(ProxyExercise).ransack(params[:q]) - @proxy_exercises = @search.result.order(:title).paginate(page: params[:page], per_page: per_page_param) - authorize! - end - - def new - @proxy_exercise = ProxyExercise.new + def edit @search = policy_scope(Exercise).ransack(params[:q]) @exercises = @search.result.order(:title) authorize! end + def create + myparams = proxy_exercise_params + myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank) + @proxy_exercise = ProxyExercise.new(myparams) + authorize! + + create_and_respond(object: @proxy_exercise) + end + def set_exercise_and_authorize @proxy_exercise = ProxyExercise.find(params[:id]) authorize! end private :set_exercise_and_authorize - def show - @search = @proxy_exercise.exercises.ransack - @exercises = @proxy_exercise.exercises.ransack.result.order(:title) - end - def update myparams = proxy_exercise_params myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank) update_and_respond(object: @proxy_exercise, params: myparams) end + + def destroy + destroy_and_respond(object: @proxy_exercise) + end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 38024d37..46360c0f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -11,15 +11,8 @@ class SessionsController < ApplicationController skip_after_action :verify_authorized skip_before_action :verify_authenticity_token, only: :create_through_lti - def create - if login(params[:email], params[:password], params[:remember_me]) - # We set the user's default study group to the "internal" group (no external id) for the given consumer. - session[:study_group_id] = current_user.study_groups.find_by(external_id: nil)&.id - redirect_back_or_to(:root, notice: t('.success')) - else - flash.now[:danger] = t('.failure') - render(:new) - end + def new + redirect_to(:root, alert: t('shared.already_signed_in')) if current_user end def create_through_lti @@ -34,13 +27,15 @@ class SessionsController < ApplicationController end end - def destroy - if current_user&.external_user? - clear_lti_session_data + def create + if login(params[:email], params[:password], params[:remember_me]) + # We set the user's default study group to the "internal" group (no external id) for the given consumer. + session[:study_group_id] = current_user.study_groups.find_by(external_id: nil)&.id + redirect_back_or_to(:root, notice: t('.success')) else - logout + flash.now[:danger] = t('.failure') + render(:new) end - redirect_to(:root, notice: t('.success')) end def destroy_through_lti @@ -52,7 +47,12 @@ class SessionsController < ApplicationController clear_lti_session_data(@submission.exercise_id, @submission.user_id) end - def new - redirect_to(:root, alert: t('shared.already_signed_in')) if current_user + def destroy + if current_user&.external_user? + clear_lti_session_data + else + logout + end + redirect_to(:root, notice: t('.success')) end end diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index bb9e49b7..b5923848 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -19,10 +19,10 @@ class SubmissionsController < ApplicationController # We want to serve .js files without raising a `ActionController::InvalidCrossOriginRequest` exception skip_before_action :verify_authenticity_token, only: %i[render_file download_file] - def create - @submission = Submission.new(submission_params) + def index + @search = Submission.ransack(params[:q]) + @submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page], per_page: per_page_param) authorize! - create_and_respond(object: @submission) end def download @@ -71,11 +71,7 @@ class SubmissionsController < ApplicationController end end - def index - @search = Submission.ransack(params[:q]) - @submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page], per_page: per_page_param) - authorize! - end + def show; end def render_file # Set @current_user with a new *learner* for Pundit checks @@ -250,7 +246,11 @@ class SubmissionsController < ApplicationController end end - def show; end + def create + @submission = Submission.new(submission_params) + authorize! + create_and_respond(object: @submission) + end def statistics; end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 6a60099b..be2e0fab 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -10,31 +10,29 @@ class TagsController < ApplicationController end private :authorize! - def create - @tag = Tag.new(tag_params) + def index + @tags = Tag.all.paginate(page: params[:page], per_page: per_page_param) authorize! - create_and_respond(object: @tag) end - def destroy - destroy_and_respond(object: @tag) - end + def show; end - def edit; end + def new + @tag = Tag.new + authorize! + end def tag_params params[:tag].permit(:name) if params[:tag].present? end private :tag_params - def index - @tags = Tag.all.paginate(page: params[:page], per_page: per_page_param) - authorize! - end + def edit; end - def new - @tag = Tag.new + def create + @tag = Tag.new(tag_params) authorize! + create_and_respond(object: @tag) end def set_tag @@ -43,12 +41,14 @@ class TagsController < ApplicationController end private :set_tag - def show; end - def update update_and_respond(object: @tag, params: tag_params) end + def destroy + destroy_and_respond(object: @tag) + end + def to_s name end diff --git a/app/controllers/tips_controller.rb b/app/controllers/tips_controller.rb index 7d808d08..3f39d6c7 100644 --- a/app/controllers/tips_controller.rb +++ b/app/controllers/tips_controller.rb @@ -11,17 +11,17 @@ class TipsController < ApplicationController end private :authorize! - def create - @tip = Tip.new(tip_params) + def index + @tips = Tip.all.paginate(page: params[:page], per_page: per_page_param) authorize! - create_and_respond(object: @tip) end - def destroy - destroy_and_respond(object: @tip) - end + def show; end - def edit; end + def new + @tip = Tip.new + authorize! + end def tip_params return if params[:tip].blank? @@ -33,14 +33,12 @@ class TipsController < ApplicationController end private :tip_params - def index - @tips = Tip.all.paginate(page: params[:page], per_page: per_page_param) - authorize! - end + def edit; end - def new - @tip = Tip.new + def create + @tip = Tip.new(tip_params) authorize! + create_and_respond(object: @tip) end def set_tip @@ -49,12 +47,14 @@ class TipsController < ApplicationController end private :set_tip - def show; end - def update update_and_respond(object: @tip, params: tip_params) end + def destroy + destroy_and_respond(object: @tip) + end + def set_file_types @file_types = FileType.all.order(:name) end diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb index 1daa0c46..9f0b0cbf 100644 --- a/app/controllers/user_exercise_feedbacks_controller.rb +++ b/app/controllers/user_exercise_feedbacks_controller.rb @@ -22,6 +22,21 @@ class UserExerciseFeedbacksController < ApplicationController [4, t('user_exercise_feedback.estimated_time_more_30')]] end + def new + exercise_id = if params[:user_exercise_feedback].nil? + params[:exercise_id] + else + params[:user_exercise_feedback][:exercise_id] + end + @exercise = Exercise.find(exercise_id) + @uef = UserExerciseFeedback.find_or_initialize_by(user: current_user, exercise: @exercise) + authorize! + end + + def edit + authorize! + end + def create Sentry.set_extras(params: uef_params) @@ -46,32 +61,12 @@ class UserExerciseFeedbacksController < ApplicationController end create_and_respond(object: @uef, path: proc { path }) else - flash[:danger] = t('shared.message_failure') + flash.now[:danger] = t('shared.message_failure') redirect_back fallback_location: user_exercise_feedback_path(@uef) end end end - def destroy - authorize! - destroy_and_respond(object: @uef) - end - - def edit - authorize! - end - - def new - exercise_id = if params[:user_exercise_feedback].nil? - params[:exercise_id] - else - params[:user_exercise_feedback][:exercise_id] - end - @exercise = Exercise.find(exercise_id) - @uef = UserExerciseFeedback.find_or_initialize_by(user: current_user, exercise: @exercise) - authorize! - end - def update submission = begin current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').final.first @@ -89,11 +84,16 @@ class UserExerciseFeedbacksController < ApplicationController end update_and_respond(object: @uef, params: uef_params, path: path) else - flash[:danger] = t('shared.message_failure') + flash.now[:danger] = t('shared.message_failure') redirect_back fallback_location: user_exercise_feedback_path(@uef) end end + def destroy + authorize! + destroy_and_respond(object: @uef) + end + private def authorize! diff --git a/lib/tasks/export_public_exercises.rake b/lib/tasks/export_public_exercises.rake index 162c36ed..610f012b 100644 --- a/lib/tasks/export_public_exercises.rake +++ b/lib/tasks/export_public_exercises.rake @@ -7,17 +7,17 @@ namespace :export_exercises do successful_exports = [] failed_exports = [] Exercise.where(public: true).each do |exercise| - puts "Exporting exercise \##{exercise.id}" + puts "Exporting exercise ##{exercise.id}" error = ExerciseService::PushExternal.call( zip: ProformaService::ExportTask.call(exercise: exercise), codeharbor_link: codeharbor_link ) if error.nil? successful_exports << exercise.id - puts "Successfully exported exercise\# #{exercise.id}" + puts "Successfully exported exercise# #{exercise.id}" else failed_exports << exercise.id - puts "An error occured during export of exercise\# #{exercise.id}: #{error}" + puts "An error occured during export of exercise# #{exercise.id}: #{error}" end end diff --git a/spec/controllers/ping_controller_spec.rb b/spec/controllers/ping_controller_spec.rb index 0361efaa..74b79822 100644 --- a/spec/controllers/ping_controller_spec.rb +++ b/spec/controllers/ping_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe PingController, type: :controller do +RSpec.describe PingController do describe 'index' do it 'returns the wanted page and answer with HTTP Status 200' do get :index diff --git a/spec/features/request_for_comments_filter_spec.rb b/spec/features/request_for_comments_filter_spec.rb index a3362a5e..0ef0c918 100644 --- a/spec/features/request_for_comments_filter_spec.rb +++ b/spec/features/request_for_comments_filter_spec.rb @@ -29,6 +29,6 @@ describe 'Request_for_Comments' do it 'contains a filter for study group in the view' do visit(request_for_comments_path) - expect(page.find_by_id('q_submission_study_group_id_in')).not_to be_nil # rubocop:disable Rails/DynamicFindBy + expect(page.find_by_id('q_submission_study_group_id_in')).not_to be_nil end end diff --git a/spec/lib/runner/strategy/docker_container_pool_spec.rb b/spec/lib/runner/strategy/docker_container_pool_spec.rb index 8ddfd36f..7e3283b9 100644 --- a/spec/lib/runner/strategy/docker_container_pool_spec.rb +++ b/spec/lib/runner/strategy/docker_container_pool_spec.rb @@ -5,7 +5,7 @@ require 'pathname' describe Runner::Strategy::DockerContainerPool do let(:runner_id) { attributes_for(:runner)[:runner_id] } - let(:execution_environment) { create :ruby } + let(:execution_environment) { create(:ruby) } let(:container_pool) { described_class.new(runner_id, execution_environment) } let(:docker_container_pool_url) { 'https://localhost:1234' } let(:config) { {url: docker_container_pool_url, unused_runner_expiration_time: 180} } diff --git a/spec/lib/runner/strategy/poseidon_spec.rb b/spec/lib/runner/strategy/poseidon_spec.rb index 66e368ce..ee29f223 100644 --- a/spec/lib/runner/strategy/poseidon_spec.rb +++ b/spec/lib/runner/strategy/poseidon_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' describe Runner::Strategy::Poseidon do let(:runner_id) { attributes_for(:runner)[:runner_id] } - let(:execution_environment) { create :ruby } + let(:execution_environment) { create(:ruby) } let(:poseidon) { described_class.new(runner_id, execution_environment) } let(:error_message) { 'test error message' } let(:response_body) { nil } diff --git a/spec/models/runner_spec.rb b/spec/models/runner_spec.rb index 5639263a..23950b86 100644 --- a/spec/models/runner_spec.rb +++ b/spec/models/runner_spec.rb @@ -8,7 +8,7 @@ describe Runner do let(:strategy) { instance_double(strategy_class) } describe 'attribute validation' do - let(:runner) { create :runner } + let(:runner) { create(:runner) } it 'validates the presence of the runner id' do described_class.skip_callback(:validation, :before, :request_id) @@ -164,8 +164,8 @@ describe Runner do end describe 'creation' do - let(:user) { create :external_user } - let(:execution_environment) { create :ruby } + let(:user) { create(:external_user) } + let(:execution_environment) { create(:ruby) } let(:create_action) { -> { described_class.create(user: user, execution_environment: execution_environment) } } it 'requests a runner id from the runner management' do @@ -194,7 +194,7 @@ describe Runner do end describe '#request_new_id' do - let(:runner) { create :runner } + let(:runner) { create(:runner) } context 'when the environment is available in the runner management' do it 'requests the runner management' do @@ -242,8 +242,8 @@ describe Runner do end describe '::for' do - let(:user) { create :external_user } - let(:exercise) { create :fibonacci } + let(:user) { create(:external_user) } + let(:exercise) { create(:fibonacci) } context 'when the runner could not be saved' do before { allow(strategy_class).to receive(:request_from_management).and_return(nil) } diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index 06744512..ae13217b 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -126,7 +126,7 @@ describe Submission do end describe '#calculate_score' do - let(:runner) { create :runner } + let(:runner) { create(:runner) } before do allow(Runner).to receive(:for).and_return(runner) diff --git a/spec/routing/ping_routing_spec.rb b/spec/routing/ping_controller_routing_spec.rb similarity index 80% rename from spec/routing/ping_routing_spec.rb rename to spec/routing/ping_controller_routing_spec.rb index 5be6e5fd..8daf00b6 100644 --- a/spec/routing/ping_routing_spec.rb +++ b/spec/routing/ping_controller_routing_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe PingController, type: :routing do +describe PingController do context 'with routes to #show' do it { expect(get: '/ping').to route_to('ping#index', format: :json) } end