Skip to content

Commit

Permalink
Merge pull request #4979 from dodona-edu/dependabot/bundler/rubocop-b…
Browse files Browse the repository at this point in the history
…2b229325b
  • Loading branch information
bmesuere authored Sep 18, 2023
2 parents 52b5b60 + 9577e01 commit 07a297b
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ group :development do

gem 'rb-readline', '~> 0.5.5' # require for irb
gem 'rubocop-capybara', '~> 2.18.0'
gem 'rubocop-factory_bot', '~> 2.23'
gem 'rubocop-factory_bot', '~> 2.24'
gem 'rubocop-minitest', '~> 0.31.1'
gem 'rubocop-rails', '~> 2.20.2'
gem 'rubocop-rails', '~> 2.21.1'

# for opening letters
gem 'letter_opener', '~> 1.8.1'
Expand Down
14 changes: 8 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ GEM
attr_required (1.0.1)
autoprefixer-rails (10.4.15.0)
execjs (~> 2)
base64 (0.1.1)
bcrypt (3.1.18)
bcrypt_pbkdf (1.1.0)
bindata (2.4.15)
Expand Down Expand Up @@ -405,26 +406,27 @@ GEM
railties (>= 5.2)
rexml (3.2.6)
rouge (4.1.3)
rubocop (1.53.1)
rubocop (1.56.3)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.23.1)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-minitest (0.31.1)
rubocop (>= 1.39, < 2.0)
rubocop-rails (2.20.2)
rubocop-rails (2.21.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
Expand Down Expand Up @@ -588,9 +590,9 @@ DEPENDENCIES
rb-readline (~> 0.5.5)
rouge (= 4.1.3)
rubocop-capybara (~> 2.18.0)
rubocop-factory_bot (~> 2.23)
rubocop-factory_bot (~> 2.24)
rubocop-minitest (~> 0.31.1)
rubocop-rails (~> 2.20.2)
rubocop-rails (~> 2.21.1)
ruby-saml (~> 1.15.0)
rubyzip (~> 2.3.2)
selenium-webdriver (~> 4.12.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/annotations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def update

def destroy
@annotation.destroy
render json: {}, status: :no_content
head :no_content
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/score_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def destroy
@score_item.destroy
respond_to do |format|
format.js { render 'score_items/index', locals: { new: nil, evaluation_exercise: preload_eval_exercise(@score_item) } }
format.json { render json: {}, status: :no_content }
format.json { head :no_content }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/scores_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def destroy
set_common
respond_to do |format|
format.js { render 'feedbacks/show' }
format.json { render json: {}, status: :no_content }
format.json { head :no_content }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ def set_user

def set_users
authorize User
@users = apply_scopes(User).all.order(permission: :desc, last_name: :asc, first_name: :asc).paginate(page: parse_pagination_param(params[:page]))
@users = apply_scopes(User).order(permission: :desc, last_name: :asc, first_name: :asc).paginate(page: parse_pagination_param(params[:page]))
end
end
2 changes: 1 addition & 1 deletion app/helpers/export_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def bundle
end

def get_submissions_for_series(series, selected_exercises, users)
submissions = policy_scope(Submission).all.where(user_id: users.map(&:id), exercise_id: selected_exercises.map(&:id), course: series.course_id).includes(:user, :exercise)
submissions = policy_scope(Submission).where(user_id: users.map(&:id), exercise_id: selected_exercises.map(&:id), course: series.course_id).includes(:user, :exercise)
submissions = submissions.before_deadline(@options[:deadline]) if deadline?
submissions = submissions.group(:user_id, :exercise_id).most_recent if only_last_submission?
submissions.sort_by { |s| [selected_exercises.map(&:id).index(s.exercise_id), users.map(&:id).index(s.user_id), s.id] }
Expand Down
9 changes: 6 additions & 3 deletions app/helpers/notifications_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ module NotificationsHelper
def base_notifiable_url_params(notification)
return { controller: 'exports', action: 'index' } if notification.notifiable_type == 'Export'
return { controller: 'submissions', action: 'show', id: notification.notifiable_id } if notification.notifiable_type == 'Submission'
return { controller: 'evaluations', action: 'overview', id: notification.notifiable_id } if notification.notifiable_type == 'Evaluation'

{ controller: 'evaluations', action: 'overview', id: notification.notifiable_id } if notification.notifiable_type == 'Evaluation'
end

def notifiable_url(notification)
return exports_path(highlighted: notification.notifiable_id) if notification.notifiable_type == 'Export'
return submission_path(notification.notifiable_id, anchor: 'code') if notification.notifiable_type == 'Submission'
return overview_evaluation_path(notification.notifiable_id) if notification.notifiable_type == 'Evaluation'

overview_evaluation_path(notification.notifiable_id) if notification.notifiable_type == 'Evaluation'
end

def notifiable_icon(notification)
return 'mdi-file-download-outline' if notification.notifiable_type == 'Export'
return 'mdi-comment-account-outline' if notification.notifiable_type == 'Submission'
return 'mdi-comment-multiple-outline' if notification.notifiable_type == 'Evaluation'

'mdi-comment-multiple-outline' if notification.notifiable_type == 'Evaluation'
end
end
2 changes: 1 addition & 1 deletion app/runners/submission_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def execute
while Time.zone.now - before_time < time_limit
before_stats = Time.zone.now
# Check if container is still running
if !Rails.env.test? && (Docker::Container.all.any? { |c| c.id.starts_with?(container.id) || container.id.starts_with?(container.id) } && container.refresh!.info['State']['Running'])
if !Rails.env.test? && (Docker::Container.any? { |c| c.id.starts_with?(container.id) || container.id.starts_with?(container.id) } && container.refresh!.info['State']['Running'])
# If we don't pass these extra options gathering stats takes 1+ seconds (https://github.com/moby/moby/issues/23188#issuecomment-223211481)
stats = container.stats({ 'one-shot': true, stream: false })
memory = [stats['memory_stats']['usage'] / (1024.0 * 1024.0), memory].max if stats['memory_stats']&.fetch('usage', nil)
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/activities_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def setup
assert_equal Activity.where(judge: judge).count, response.parsed_body.count
assert_equal @instance.id, response.parsed_body[0]['id']

get activities_url(format: :json, judge_id: Judge.all.last.id + 1)
get activities_url(format: :json, judge_id: Judge.last.id + 1)

assert_equal 0, response.parsed_body.count
end
Expand Down
6 changes: 3 additions & 3 deletions test/controllers/evaluations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ def setup
normal_annotations += 1
end

assert_equal normal_annotations, Notification.all.count, 'only notifications for the annotations without a feedback session'
assert_equal normal_annotations, Notification.count, 'only notifications for the annotations without a feedback session'

evaluation.feedbacks.each do |feedback|
feedback.update(completed: true)
end

assert_equal normal_annotations, Notification.all.count, 'no new notification should be made upon completing a feedback'
assert_equal normal_annotations, Notification.count, 'no new notification should be made upon completing a feedback'

evaluation.update(released: true)

assert_equal normal_annotations + @users.count, Notification.all.count, 'A new notification per user should be made upon releasing a feedback session, along with keeping the notifications made for annotations without a feedback session'
assert_equal normal_annotations + @users.count, Notification.count, 'A new notification per user should be made upon releasing a feedback session, along with keeping the notifications made for annotations without a feedback session'
end

test 'non released annotations are not queryable' do
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/exports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ExportsControllerTest < ActionDispatch::IntegrationTest
post series_exports_path(@series), params: { all: true }

assert_redirected_to exports_path
assert_zip ActiveStorage::Blob.last.download, solution_count: Submission.all.count, data: @data
assert_zip ActiveStorage::Blob.last.download, solution_count: Submission.count, data: @data
end

test 'all students should be present in the zip' do
Expand Down
2 changes: 1 addition & 1 deletion test/factories/content_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
repository { Repository.find(1) } # load python repo fixture

trait :generated_repo do
association :repository, factory: %i[repository git_stubbed]
repository factory: %i[repository git_stubbed]
end

transient do
Expand Down
2 changes: 1 addition & 1 deletion test/factories/evaluations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
FactoryBot.define do
factory :evaluation do
association :series, deadline: DateTime.now - 1.minute
series { association :series, deadline: DateTime.now - 1.minute }
deadline { series.deadline || (DateTime.now - 1.minute) }
released { false }
exercises { series.exercises }
Expand Down
4 changes: 2 additions & 2 deletions test/factories/exercises.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
judge { repository.judge }

trait :generated_repo do
association :repository, factory: %i[repository git_stubbed]
repository factory: %i[repository git_stubbed]
judge { repository.judge }
end

Expand Down Expand Up @@ -81,7 +81,7 @@
end

trait :with_programming_language do
association :programming_language
programming_language
end

trait :nameless do
Expand Down
2 changes: 1 addition & 1 deletion test/factories/repositories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
judge { Judge.find(1) } # load python judge fixture

trait :generated_judge do
association :judge, factory: %i[judge git_stubbed]
judge factory: %i[judge git_stubbed]
end

trait :git_stubbed do
Expand Down
2 changes: 1 addition & 1 deletion test/factories/rights_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
FactoryBot.define do
factory :rights_request do
association :user, :with_institution
user factory: %i[user with_institution]
institution_name { Faker::University.unique.name.gsub(/[^[:ascii:]]/, '') }
context { Faker::Lorem.paragraph(sentence_count: 25) }
end
Expand Down
2 changes: 1 addition & 1 deletion test/factories/series.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
course { Course.find(1) } # load course 1 fixture

trait :generated_course do
association :course
course
end

trait :hidden do
Expand Down
4 changes: 2 additions & 2 deletions test/factories/submissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
initialize_with { new(attributes) }

trait :generated_user do
association :user
user
end

trait :generated_exercise do
association :exercise
exercise
end

trait :correct do
Expand Down
2 changes: 1 addition & 1 deletion test/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
permission { :student }

trait :with_institution do
association :institution
institution
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/models/activity_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class ActivityTest < ActiveSupport::TestCase
create :series, course: c3, exercises: [e1, e2]
create :series, course: c4, exercises: [e2, e3]
# should count the same activity twice in the same course
5.times { create :series, course: c4, exercises: [e3] }
create_list :series, 5, course: c4, exercises: [e3]

assert_equal [e3.id, e1.id, e2.id], Activity.order_by_popularity(:DESC).pluck(:id)
assert_equal [e2.id, e1.id, e3.id], Activity.order_by_popularity(:ASC).pluck(:id)
Expand Down
2 changes: 1 addition & 1 deletion test/models/course_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class CourseTest < ActiveSupport::TestCase
[create(:institution), i, nil].each do |institution|
u = create :user, institution: institution

Course.all.each do |c|
Course.find_each do |c|
assert_equal c.open_for_user?(u), Course.can_register(u).exists?(c.id)
end
end
Expand Down
12 changes: 6 additions & 6 deletions test/models/repository_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def teardown
end

test 'should create new exercise when config without token is placed in path of removed exercise' do
start = Exercise.all.count
start = Exercise.count
@remote.remove_dir(@echo.path)
@remote.commit('remove exercise')
@repository.reset
Expand All @@ -195,11 +195,11 @@ def teardown
@echo.reload

assert_equal 'removed', @echo.status
assert_equal 1, Exercise.all.count - start
assert_equal 1, Exercise.count - start
end

test 'should create new exercise when exercise is copied' do
start = Exercise.all.count
start = Exercise.count
new_dir = 'echo2'
@remote.copy_dir(@echo.path, new_dir)
@remote.commit('copy exercise')
Expand All @@ -208,11 +208,11 @@ def teardown
@echo.reload

assert_equal 'echo', @echo.path
assert_equal 1, Exercise.all.count - start
assert_equal 1, Exercise.count - start
end

test 'should create only 1 new exercise on copy + rename' do
start = Exercise.all.count
start = Exercise.count
new_dir1 = 'echo2'
new_dir2 = 'echo3'
@remote.copy_dir(@echo.path, new_dir1)
Expand All @@ -223,7 +223,7 @@ def teardown
@echo.reload

assert_includes [new_dir1, new_dir2], @echo.path
assert_equal 1, Exercise.all.count - start
assert_equal 1, Exercise.count - start
end

test 'should copy valid token for new exercise' do
Expand Down
8 changes: 2 additions & 6 deletions test/models/submission_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,8 @@ class StatisticsTest < ActiveSupport::TestCase
@series = create :series, exercises: [@exercise], course: @course
3.times do
user = create :student, subscribed_courses: [@course]
2.times do
create :submission, user: user, exercise: @exercise, status: :correct, course: @course, created_at: @date
end
3.times do
create :submission, user: user, exercise: @exercise, status: :wrong, course: @course, created_at: @date
end
create_list :submission, 2, user: user, exercise: @exercise, status: :correct, course: @course, created_at: @date
create_list :submission, 3, user: user, exercise: @exercise, status: :wrong, course: @course, created_at: @date
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def setup
CourseMembership.create user: u1, course: c, status: 'student'
CourseMembership.create user: u2, course: c, status: 'student'
s1 = create :series, course: c, exercise_count: 0
s2 = create :series, course: c2, exercise_count: 0
s2 = create :series, course: c2, exercise_count: 0
e1 = create :exercise
e2 = create :exercise
e3 = create :exercise
Expand Down
2 changes: 1 addition & 1 deletion test/system/feedbacks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FeedbacksTest < ApplicationSystemTestCase
@staff_member = create :staff
series = create :series, exercise_count: 2
series.course.administrating_members << @staff_member
@users = [create(:user), create(:user)]
@users = create_list :user, 2
@exercises = series.exercises
@users.each do |u|
series.course.enrolled_members << u
Expand Down

0 comments on commit 07a297b

Please sign in to comment.