Fix Rubocop offenses

This commit is contained in:
Sebastian Serth
2022-10-24 12:10:10 +02:00
parent b32bf1232b
commit c75f52f2c8
20 changed files with 222 additions and 222 deletions

View File

@ -10,31 +10,29 @@ class ConsumersController < ApplicationController
end end
private :authorize! private :authorize!
def create def index
@consumer = Consumer.new(consumer_params) @consumers = Consumer.paginate(page: params[:page], per_page: per_page_param)
authorize! authorize!
create_and_respond(object: @consumer)
end end
def destroy def show; end
destroy_and_respond(object: @consumer)
end
def edit; end def new
@consumer = Consumer.new(oauth_key: SecureRandom.hex, oauth_secret: SecureRandom.hex)
authorize!
end
def consumer_params def consumer_params
params[:consumer].permit(:name, :oauth_key, :oauth_secret) if params[:consumer].present? params[:consumer].permit(:name, :oauth_key, :oauth_secret) if params[:consumer].present?
end end
private :consumer_params private :consumer_params
def index def edit; end
@consumers = Consumer.paginate(page: params[:page], per_page: per_page_param)
authorize!
end
def new def create
@consumer = Consumer.new(oauth_key: SecureRandom.hex, oauth_secret: SecureRandom.hex) @consumer = Consumer.new(consumer_params)
authorize! authorize!
create_and_respond(object: @consumer)
end end
def set_consumer def set_consumer
@ -43,9 +41,11 @@ class ConsumersController < ApplicationController
end end
private :set_consumer private :set_consumer
def show; end
def update def update
update_and_respond(object: @consumer, params: consumer_params) update_and_respond(object: @consumer, params: consumer_params)
end end
def destroy
destroy_and_respond(object: @consumer)
end
end end

View File

@ -12,19 +12,20 @@ class ExecutionEnvironmentsController < ApplicationController
end end
private :authorize! private :authorize!
def create def index
@execution_environment = ExecutionEnvironment.new(execution_environment_params) @execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
authorize! authorize!
create_and_respond(object: @execution_environment)
end end
def destroy def show
destroy_and_respond(object: @execution_environment) if @execution_environment.testing_framework?
@testing_framework_adapter = TestingFrameworkAdapter.descendants.find {|klass| klass.name == @execution_environment.testing_framework }
end
end end
def edit def new
# Add the current execution_environment if not already present in the list @execution_environment = ExecutionEnvironment.new
@docker_images |= [@execution_environment.docker_image] authorize!
end end
def execute_command def execute_command
@ -122,21 +123,22 @@ class ExecutionEnvironmentsController < ApplicationController
end end
private :execution_environment_params private :execution_environment_params
def index def edit
@execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param) # Add the current execution_environment if not already present in the list
authorize! @docker_images |= [@execution_environment.docker_image]
end end
def new def create
@execution_environment = ExecutionEnvironment.new @execution_environment = ExecutionEnvironment.new(execution_environment_params)
authorize! authorize!
create_and_respond(object: @execution_environment)
end end
def set_docker_images def set_docker_images
@docker_images ||= ExecutionEnvironment.pluck(:docker_image) @docker_images ||= ExecutionEnvironment.pluck(:docker_image)
@docker_images += Runner.strategy_class.available_images @docker_images += Runner.strategy_class.available_images
rescue Runner::Error => e rescue Runner::Error => e
flash[:warning] = html_escape e.message flash.now[:warning] = html_escape e.message
ensure ensure
@docker_images = @docker_images.sort.uniq @docker_images = @docker_images.sort.uniq
end end
@ -158,16 +160,14 @@ class ExecutionEnvironmentsController < ApplicationController
def shell; end 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 def update
update_and_respond(object: @execution_environment, params: execution_environment_params) update_and_respond(object: @execution_environment, params: execution_environment_params)
end end
def destroy
destroy_and_respond(object: @execution_environment)
end
def sync_to_runner_management def sync_to_runner_management
return unless Runner.management_active? return unless Runner.management_active?

View File

@ -17,6 +17,8 @@ class ExerciseCollectionsController < ApplicationController
authorize! authorize!
end end
def edit; end
def create def create
@exercise_collection = ExerciseCollection.new @exercise_collection = ExerciseCollection.new
authorize! authorize!
@ -24,18 +26,16 @@ class ExerciseCollectionsController < ApplicationController
update_and_respond(object: @exercise_collection, params: exercise_collection_params) update_and_respond(object: @exercise_collection, params: exercise_collection_params)
end end
def destroy
authorize!
destroy_and_respond(object: @exercise_collection)
end
def edit; end
def update def update
authorize! authorize!
update_and_respond(object: @exercise_collection, params: exercise_collection_params) update_and_respond(object: @exercise_collection, params: exercise_collection_params)
end end
def destroy
authorize!
destroy_and_respond(object: @exercise_collection)
end
def statistics; end def statistics; end
private private

View File

@ -73,22 +73,22 @@ class ExercisesController < ApplicationController
private :collect_paths private :collect_paths
def create def index
@exercise = Exercise.new(exercise_params&.except(:tips)) @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! authorize!
handle_exercise_tips
collect_set_and_unset_exercise_tags collect_set_and_unset_exercise_tags
return if performed?
create_and_respond(object: @exercise, params: exercise_params_with_tags)
end end
def destroy
destroy_and_respond(object: @exercise)
end
def edit; end
def feedback def feedback
authorize! authorize!
@feedbacks = @exercise.user_exercise_feedbacks.paginate(page: params[:page], per_page: per_page_param) @feedbacks = @exercise.user_exercise_feedbacks.paginate(page: params[:page], per_page: per_page_param)
@ -424,16 +424,16 @@ class ExercisesController < ApplicationController
end end
end end
def index def edit; end
@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 new def create
@exercise = Exercise.new @exercise = Exercise.new(exercise_params&.except(:tips))
authorize! authorize!
handle_exercise_tips
collect_set_and_unset_exercise_tags collect_set_and_unset_exercise_tags
return if performed?
create_and_respond(object: @exercise, params: exercise_params_with_tags)
end end
def not_authorized_for_exercise(_exception) def not_authorized_for_exercise(_exception)
@ -489,8 +489,11 @@ class ExercisesController < ApplicationController
private :collect_set_and_unset_exercise_tags private :collect_set_and_unset_exercise_tags
def show def update
# Show exercise details for teachers and admins handle_exercise_tips
return if performed?
update_and_respond(object: @exercise, params: exercise_params_with_tags)
end end
def reload def reload
@ -579,7 +582,7 @@ class ExercisesController < ApplicationController
if response[:status] == 'success' if response[:status] == 'success'
if response[:score_sent] != @submission.normalized_score if response[:score_sent] != @submission.normalized_score
# Score has been reduced due to the passed deadline # 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) flash.keep(:warning)
end end
redirect_after_submit redirect_after_submit
@ -593,11 +596,8 @@ class ExercisesController < ApplicationController
private :transmit_lti_score private :transmit_lti_score
def update def destroy
handle_exercise_tips destroy_and_respond(object: @exercise)
return if performed?
update_and_respond(object: @exercise, params: exercise_params_with_tags)
end end
def study_group_dashboard def study_group_dashboard

View File

@ -11,17 +11,17 @@ class FileTypesController < ApplicationController
end end
private :authorize! private :authorize!
def create def index
@file_type = FileType.new(file_type_params) @file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
authorize! authorize!
create_and_respond(object: @file_type)
end end
def destroy def show; end
destroy_and_respond(object: @file_type)
end
def edit; end def new
@file_type = FileType.new
authorize!
end
def file_type_params def file_type_params
if params[:file_type].present? if params[:file_type].present?
@ -32,14 +32,12 @@ class FileTypesController < ApplicationController
end end
private :file_type_params private :file_type_params
def index def edit; end
@file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
authorize!
end
def new def create
@file_type = FileType.new @file_type = FileType.new(file_type_params)
authorize! authorize!
create_and_respond(object: @file_type)
end end
def set_editor_modes def set_editor_modes
@ -56,9 +54,11 @@ class FileTypesController < ApplicationController
end end
private :set_file_type private :set_file_type
def show; end
def update def update
update_and_respond(object: @file_type, params: file_type_params) update_and_respond(object: @file_type, params: file_type_params)
end end
def destroy
destroy_and_respond(object: @file_type)
end
end end

View File

@ -31,17 +31,10 @@ class InternalUsersController < ApplicationController
end end
private :change_password private :change_password
def create def index
@user = InternalUser.new(internal_user_params) @search = InternalUser.ransack(params[:q], {auth_object: current_user})
@user.platform_admin = platform_admin_param if current_user.admin? @users = @search.result.in_study_group_of(current_user).includes(:consumer).order(:name).paginate(page: params[:page], per_page: per_page_param)
authorize! 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 end
def deliver_reset_password_instructions def deliver_reset_password_instructions
@ -53,11 +46,13 @@ class InternalUsersController < ApplicationController
end end
private :deliver_reset_password_instructions private :deliver_reset_password_instructions
def destroy def show; end
destroy_and_respond(object: @user)
end
def edit; end def new
@user = InternalUser.new
authorize!
collect_set_and_unset_study_group_memberships
end
def forgot_password def forgot_password
if request.get? if request.get?
@ -67,11 +62,7 @@ class InternalUsersController < ApplicationController
end end
end end
def index def edit; end
@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 internal_user_params def internal_user_params
permitted_params = params.require(:internal_user).permit(:consumer_id, :email, :name, study_group_ids: []).presence || {} permitted_params = params.require(:internal_user).permit(:consumer_id, :email, :name, study_group_ids: []).presence || {}
@ -95,10 +86,17 @@ class InternalUsersController < ApplicationController
end end
private :platform_admin_param private :platform_admin_param
def new def create
@user = InternalUser.new @user = InternalUser.new(internal_user_params)
@user.platform_admin = platform_admin_param if current_user.admin?
authorize! 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 end
def render_forgot_password_form def render_forgot_password_form
@ -159,8 +157,6 @@ class InternalUsersController < ApplicationController
private :collect_set_and_unset_study_group_memberships private :collect_set_and_unset_study_group_memberships
def show; end
def update def update
# Let's skip the password validation if the user is edited through # Let's skip the password validation if the user is edited through
# the form by another user. Otherwise, the update might fail if an # 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? @user.platform_admin = platform_admin_param if current_user.admin?
update_and_respond(object: @user, params: internal_user_params) update_and_respond(object: @user, params: internal_user_params)
end end
def destroy
destroy_and_respond(object: @user)
end
end end

View File

@ -22,20 +22,19 @@ class ProxyExercisesController < ApplicationController
end end
end end
def create def index
myparams = proxy_exercise_params @search = policy_scope(ProxyExercise).ransack(params[:q])
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank) @proxy_exercises = @search.result.order(:title).paginate(page: params[:page], per_page: per_page_param)
@proxy_exercise = ProxyExercise.new(myparams)
authorize! authorize!
create_and_respond(object: @proxy_exercise)
end end
def destroy def show
destroy_and_respond(object: @proxy_exercise) @search = @proxy_exercise.exercises.ransack
@exercises = @proxy_exercise.exercises.ransack.result.order(:title)
end end
def edit def new
@proxy_exercise = ProxyExercise.new
@search = policy_scope(Exercise).ransack(params[:q]) @search = policy_scope(Exercise).ransack(params[:q])
@exercises = @search.result.order(:title) @exercises = @search.result.order(:title)
authorize! authorize!
@ -49,33 +48,34 @@ class ProxyExercisesController < ApplicationController
end end
private :proxy_exercise_params private :proxy_exercise_params
def index def edit
@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
@search = policy_scope(Exercise).ransack(params[:q]) @search = policy_scope(Exercise).ransack(params[:q])
@exercises = @search.result.order(:title) @exercises = @search.result.order(:title)
authorize! authorize!
end 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 def set_exercise_and_authorize
@proxy_exercise = ProxyExercise.find(params[:id]) @proxy_exercise = ProxyExercise.find(params[:id])
authorize! authorize!
end end
private :set_exercise_and_authorize private :set_exercise_and_authorize
def show
@search = @proxy_exercise.exercises.ransack
@exercises = @proxy_exercise.exercises.ransack.result.order(:title)
end
def update def update
myparams = proxy_exercise_params myparams = proxy_exercise_params
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank) myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
update_and_respond(object: @proxy_exercise, params: myparams) update_and_respond(object: @proxy_exercise, params: myparams)
end end
def destroy
destroy_and_respond(object: @proxy_exercise)
end
end end

View File

@ -11,15 +11,8 @@ class SessionsController < ApplicationController
skip_after_action :verify_authorized skip_after_action :verify_authorized
skip_before_action :verify_authenticity_token, only: :create_through_lti skip_before_action :verify_authenticity_token, only: :create_through_lti
def create def new
if login(params[:email], params[:password], params[:remember_me]) redirect_to(:root, alert: t('shared.already_signed_in')) if current_user
# 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
end end
def create_through_lti def create_through_lti
@ -34,13 +27,15 @@ class SessionsController < ApplicationController
end end
end end
def destroy def create
if current_user&.external_user? if login(params[:email], params[:password], params[:remember_me])
clear_lti_session_data # 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 else
logout flash.now[:danger] = t('.failure')
render(:new)
end end
redirect_to(:root, notice: t('.success'))
end end
def destroy_through_lti def destroy_through_lti
@ -52,7 +47,12 @@ class SessionsController < ApplicationController
clear_lti_session_data(@submission.exercise_id, @submission.user_id) clear_lti_session_data(@submission.exercise_id, @submission.user_id)
end end
def new def destroy
redirect_to(:root, alert: t('shared.already_signed_in')) if current_user if current_user&.external_user?
clear_lti_session_data
else
logout
end
redirect_to(:root, notice: t('.success'))
end end
end end

View File

@ -19,10 +19,10 @@ class SubmissionsController < ApplicationController
# We want to serve .js files without raising a `ActionController::InvalidCrossOriginRequest` exception # We want to serve .js files without raising a `ActionController::InvalidCrossOriginRequest` exception
skip_before_action :verify_authenticity_token, only: %i[render_file download_file] skip_before_action :verify_authenticity_token, only: %i[render_file download_file]
def create def index
@submission = Submission.new(submission_params) @search = Submission.ransack(params[:q])
@submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page], per_page: per_page_param)
authorize! authorize!
create_and_respond(object: @submission)
end end
def download def download
@ -71,11 +71,7 @@ class SubmissionsController < ApplicationController
end end
end end
def index def show; end
@search = Submission.ransack(params[:q])
@submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page], per_page: per_page_param)
authorize!
end
def render_file def render_file
# Set @current_user with a new *learner* for Pundit checks # Set @current_user with a new *learner* for Pundit checks
@ -250,7 +246,11 @@ class SubmissionsController < ApplicationController
end end
end end
def show; end def create
@submission = Submission.new(submission_params)
authorize!
create_and_respond(object: @submission)
end
def statistics; end def statistics; end

View File

@ -10,31 +10,29 @@ class TagsController < ApplicationController
end end
private :authorize! private :authorize!
def create def index
@tag = Tag.new(tag_params) @tags = Tag.all.paginate(page: params[:page], per_page: per_page_param)
authorize! authorize!
create_and_respond(object: @tag)
end end
def destroy def show; end
destroy_and_respond(object: @tag)
end
def edit; end def new
@tag = Tag.new
authorize!
end
def tag_params def tag_params
params[:tag].permit(:name) if params[:tag].present? params[:tag].permit(:name) if params[:tag].present?
end end
private :tag_params private :tag_params
def index def edit; end
@tags = Tag.all.paginate(page: params[:page], per_page: per_page_param)
authorize!
end
def new def create
@tag = Tag.new @tag = Tag.new(tag_params)
authorize! authorize!
create_and_respond(object: @tag)
end end
def set_tag def set_tag
@ -43,12 +41,14 @@ class TagsController < ApplicationController
end end
private :set_tag private :set_tag
def show; end
def update def update
update_and_respond(object: @tag, params: tag_params) update_and_respond(object: @tag, params: tag_params)
end end
def destroy
destroy_and_respond(object: @tag)
end
def to_s def to_s
name name
end end

View File

@ -11,17 +11,17 @@ class TipsController < ApplicationController
end end
private :authorize! private :authorize!
def create def index
@tip = Tip.new(tip_params) @tips = Tip.all.paginate(page: params[:page], per_page: per_page_param)
authorize! authorize!
create_and_respond(object: @tip)
end end
def destroy def show; end
destroy_and_respond(object: @tip)
end
def edit; end def new
@tip = Tip.new
authorize!
end
def tip_params def tip_params
return if params[:tip].blank? return if params[:tip].blank?
@ -33,14 +33,12 @@ class TipsController < ApplicationController
end end
private :tip_params private :tip_params
def index def edit; end
@tips = Tip.all.paginate(page: params[:page], per_page: per_page_param)
authorize!
end
def new def create
@tip = Tip.new @tip = Tip.new(tip_params)
authorize! authorize!
create_and_respond(object: @tip)
end end
def set_tip def set_tip
@ -49,12 +47,14 @@ class TipsController < ApplicationController
end end
private :set_tip private :set_tip
def show; end
def update def update
update_and_respond(object: @tip, params: tip_params) update_and_respond(object: @tip, params: tip_params)
end end
def destroy
destroy_and_respond(object: @tip)
end
def set_file_types def set_file_types
@file_types = FileType.all.order(:name) @file_types = FileType.all.order(:name)
end end

View File

@ -22,6 +22,21 @@ class UserExerciseFeedbacksController < ApplicationController
[4, t('user_exercise_feedback.estimated_time_more_30')]] [4, t('user_exercise_feedback.estimated_time_more_30')]]
end 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 def create
Sentry.set_extras(params: uef_params) Sentry.set_extras(params: uef_params)
@ -46,32 +61,12 @@ class UserExerciseFeedbacksController < ApplicationController
end end
create_and_respond(object: @uef, path: proc { path }) create_and_respond(object: @uef, path: proc { path })
else else
flash[:danger] = t('shared.message_failure') flash.now[:danger] = t('shared.message_failure')
redirect_back fallback_location: user_exercise_feedback_path(@uef) redirect_back fallback_location: user_exercise_feedback_path(@uef)
end end
end 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 def update
submission = begin submission = begin
current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').final.first current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').final.first
@ -89,11 +84,16 @@ class UserExerciseFeedbacksController < ApplicationController
end end
update_and_respond(object: @uef, params: uef_params, path: path) update_and_respond(object: @uef, params: uef_params, path: path)
else else
flash[:danger] = t('shared.message_failure') flash.now[:danger] = t('shared.message_failure')
redirect_back fallback_location: user_exercise_feedback_path(@uef) redirect_back fallback_location: user_exercise_feedback_path(@uef)
end end
end end
def destroy
authorize!
destroy_and_respond(object: @uef)
end
private private
def authorize! def authorize!

View File

@ -7,17 +7,17 @@ namespace :export_exercises do
successful_exports = [] successful_exports = []
failed_exports = [] failed_exports = []
Exercise.where(public: true).each do |exercise| Exercise.where(public: true).each do |exercise|
puts "Exporting exercise \##{exercise.id}" puts "Exporting exercise ##{exercise.id}"
error = ExerciseService::PushExternal.call( error = ExerciseService::PushExternal.call(
zip: ProformaService::ExportTask.call(exercise: exercise), zip: ProformaService::ExportTask.call(exercise: exercise),
codeharbor_link: codeharbor_link codeharbor_link: codeharbor_link
) )
if error.nil? if error.nil?
successful_exports << exercise.id successful_exports << exercise.id
puts "Successfully exported exercise\# #{exercise.id}" puts "Successfully exported exercise# #{exercise.id}"
else else
failed_exports << exercise.id 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
end end

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe PingController, type: :controller do RSpec.describe PingController do
describe 'index' do describe 'index' do
it 'returns the wanted page and answer with HTTP Status 200' do it 'returns the wanted page and answer with HTTP Status 200' do
get :index get :index

View File

@ -29,6 +29,6 @@ describe 'Request_for_Comments' do
it 'contains a filter for study group in the view' do it 'contains a filter for study group in the view' do
visit(request_for_comments_path) 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
end end

View File

@ -5,7 +5,7 @@ require 'pathname'
describe Runner::Strategy::DockerContainerPool do describe Runner::Strategy::DockerContainerPool do
let(:runner_id) { attributes_for(:runner)[:runner_id] } 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(:container_pool) { described_class.new(runner_id, execution_environment) }
let(:docker_container_pool_url) { 'https://localhost:1234' } let(:docker_container_pool_url) { 'https://localhost:1234' }
let(:config) { {url: docker_container_pool_url, unused_runner_expiration_time: 180} } let(:config) { {url: docker_container_pool_url, unused_runner_expiration_time: 180} }

View File

@ -4,7 +4,7 @@ require 'rails_helper'
describe Runner::Strategy::Poseidon do describe Runner::Strategy::Poseidon do
let(:runner_id) { attributes_for(:runner)[:runner_id] } 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(:poseidon) { described_class.new(runner_id, execution_environment) }
let(:error_message) { 'test error message' } let(:error_message) { 'test error message' }
let(:response_body) { nil } let(:response_body) { nil }

View File

@ -8,7 +8,7 @@ describe Runner do
let(:strategy) { instance_double(strategy_class) } let(:strategy) { instance_double(strategy_class) }
describe 'attribute validation' do describe 'attribute validation' do
let(:runner) { create :runner } let(:runner) { create(:runner) }
it 'validates the presence of the runner id' do it 'validates the presence of the runner id' do
described_class.skip_callback(:validation, :before, :request_id) described_class.skip_callback(:validation, :before, :request_id)
@ -164,8 +164,8 @@ describe Runner do
end end
describe 'creation' do describe 'creation' do
let(:user) { create :external_user } let(:user) { create(:external_user) }
let(:execution_environment) { create :ruby } let(:execution_environment) { create(:ruby) }
let(:create_action) { -> { described_class.create(user: user, execution_environment: execution_environment) } } let(:create_action) { -> { described_class.create(user: user, execution_environment: execution_environment) } }
it 'requests a runner id from the runner management' do it 'requests a runner id from the runner management' do
@ -194,7 +194,7 @@ describe Runner do
end end
describe '#request_new_id' do describe '#request_new_id' do
let(:runner) { create :runner } let(:runner) { create(:runner) }
context 'when the environment is available in the runner management' do context 'when the environment is available in the runner management' do
it 'requests the runner management' do it 'requests the runner management' do
@ -242,8 +242,8 @@ describe Runner do
end end
describe '::for' do describe '::for' do
let(:user) { create :external_user } let(:user) { create(:external_user) }
let(:exercise) { create :fibonacci } let(:exercise) { create(:fibonacci) }
context 'when the runner could not be saved' do context 'when the runner could not be saved' do
before { allow(strategy_class).to receive(:request_from_management).and_return(nil) } before { allow(strategy_class).to receive(:request_from_management).and_return(nil) }

View File

@ -126,7 +126,7 @@ describe Submission do
end end
describe '#calculate_score' do describe '#calculate_score' do
let(:runner) { create :runner } let(:runner) { create(:runner) }
before do before do
allow(Runner).to receive(:for).and_return(runner) allow(Runner).to receive(:for).and_return(runner)

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
describe PingController, type: :routing do describe PingController do
context 'with routes to #show' do context 'with routes to #show' do
it { expect(get: '/ping').to route_to('ping#index', format: :json) } it { expect(get: '/ping').to route_to('ping#index', format: :json) }
end end