Autocorrect new rubocop offenses

This commit is contained in:
Henne Vogelsang 2025-08-12 16:44:20 +02:00
parent deda3d4273
commit 988b3bf689
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6
24 changed files with 48 additions and 41 deletions

View file

@ -141,7 +141,7 @@ class AdminAbility
# Abilities for Role (Conference resource)
can [:index, :show], Role do |role|
role.resource_type == 'Conference' || role.resource_type == 'Track'
['Conference', 'Track'].include?(role.resource_type)
end
can [:edit, :update, :toggle_user], Role do |role|
@ -180,7 +180,7 @@ class AdminAbility
# Abilities for Role (Conference resource)
can [:index, :show], Role do |role|
role.resource_type == 'Conference' || role.resource_type == 'Track'
['Conference', 'Track'].include?(role.resource_type)
end
# Can add or remove users from role, when user has that same role for the conference
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
@ -218,7 +218,7 @@ class AdminAbility
# Abilities for Role (Conference resource)
can [:index, :show], Role do |role|
role.resource_type == 'Conference' || role.resource_type == 'Track'
['Conference', 'Track'].include?(role.resource_type)
end
# Can add or remove users from role, when user has that same role for the conference
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
@ -242,7 +242,7 @@ class AdminAbility
# Abilities for Role (Conference resource)
can [:index, :show], Role do |role|
role.resource_type == 'Conference' || role.resource_type == 'Track'
['Conference', 'Track'].include?(role.resource_type)
end
# Can add or remove users from role, when user has that same role for the conference
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
@ -278,7 +278,7 @@ class AdminAbility
# Show Roles in the admin sidebar and allow authorization of the index action
can [:index, :show], Role do |role|
role.resource_type == 'Conference' || role.resource_type == 'Track'
['Conference', 'Track'].include?(role.resource_type)
end
can :toggle_user, Role do |role|

View file

@ -2,6 +2,7 @@
class Booth < ApplicationRecord
include ActiveRecord::Transitions
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
belongs_to :conference

View file

@ -35,13 +35,13 @@ class Comment < ApplicationRecord
# Helper class method to lookup all comments assigned
# to all commentable types for a given user.
scope :find_comments_by_user, lambda { |user|
where(user_id: user.id).order('created_at DESC')
where(user_id: user.id).order(created_at: :desc)
}
# Helper class method to look up all comments for
# commentable class name and commentable id.
scope :find_comments_for_commentable, lambda { |commentable_str, commentable_id|
where(commentable_type: commentable_str.to_s, commentable_id: commentable_id).order('created_at DESC')
where(commentable_type: commentable_str.to_s, commentable_id: commentable_id).order(created_at: :desc)
}
scope :find_since_last_login, lambda { |user|

View file

@ -2,13 +2,14 @@
class Conference < ApplicationRecord
include RevisionCount
require 'uri'
serialize :events_per_week, Hash
# Needed to call 'Conference.with_role' in /models/ability.rb
# Dependent destroy will fail as roles#destroy will be cancelled,hence delete_all
resourcify :roles, dependent: :delete_all
default_scope { order('start_date DESC') }
default_scope { order(start_date: :desc) }
scope :upcoming, (-> { where(end_date: Date.current..) })
scope :past, (-> { where(end_date: ...Date.current) })
@ -39,7 +40,7 @@ class Conference < ApplicationRecord
has_many :participants, through: :registrations, source: :user
has_many :vdays, dependent: :destroy
has_many :vpositions, dependent: :destroy
has_many :sponsorship_levels, -> { order('position ASC') }, dependent: :destroy
has_many :sponsorship_levels, -> { order(:position) }, dependent: :destroy
has_many :sponsors, dependent: :destroy
has_many :commercials, as: :commercialable, dependent: :destroy
has_many :subscriptions, dependent: :destroy
@ -107,7 +108,7 @@ class Conference < ApplicationRecord
# * +false+ -> If the user is registered
# * +true+ - If the user isn't registered
def user_registered? user
user.present? && registrations.where(user_id: user.id).count > 0
user.present? && registrations.where(user_id: user.id).any?
end
##
@ -350,7 +351,7 @@ class Conference < ApplicationRecord
# * +hash+ -> user: submissions
def self.get_top_submitter(limit = 5)
submitter = EventUser.select(:user_id).where('event_role = ?', 'submitter').limit(limit).group(:user_id)
counter = submitter.order('count_all desc').count(:all)
counter = submitter.order(count_all: :desc).count(:all)
calculate_user_submission_hash(submitter, counter)
end
@ -363,7 +364,7 @@ class Conference < ApplicationRecord
submitter = EventUser.joins(:event).select(:user_id)
.where('event_role = ? and program_id = ?', 'submitter', Conference.find(id).program.id)
.limit(limit).group(:user_id)
counter = submitter.order('count_all desc').count(:all)
counter = submitter.order(count_all: :desc).count(:all)
Conference.calculate_user_submission_hash(submitter, counter)
end
@ -921,7 +922,7 @@ class Conference < ApplicationRecord
# * +True+ -> One difficulty level or more
# * +False+ -> No diffculty level
def difficulty_levels_set?
program.difficulty_levels.count > 0
program.difficulty_levels.any?
end
##
@ -931,7 +932,7 @@ class Conference < ApplicationRecord
# * +True+ -> One difficulty level or more
# * +False+ -> No diffculty level
def event_types_set?
program.event_types.count > 0
program.event_types.any?
end
##
@ -941,7 +942,7 @@ class Conference < ApplicationRecord
# * +True+ -> One track or more
# * +False+ -> No track
def tracks_set?
program.tracks.count > 0
program.tracks.any?
end
##
@ -951,7 +952,7 @@ class Conference < ApplicationRecord
# * +True+ -> One room or more
# * +False+ -> No room
def rooms_set?
venue.present? && venue.rooms.count > 0
venue.present? && venue.rooms.any?
end
# Checks if the conference has a venue object.

View file

@ -4,6 +4,7 @@ class Event < ApplicationRecord
include ActionView::Helpers::NumberHelper # for number_with_precision
include ActiveRecord::Transitions
include RevisionCount
has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id }
acts_as_commentable

View file

@ -82,13 +82,13 @@ class EventSchedule < ApplicationRecord
end
def start_after_end_hour
return unless event && start_time && event.program&.conference && event.program.conference.end_hour
return unless event && start_time && event.program&.conference&.end_hour
errors.add(:start_time, "can't be after the conference end hour (#{event.program.conference.end_hour})") if start_time.hour >= event.program.conference.end_hour
end
def start_before_start_hour
return unless event && start_time && event.program&.conference && event.program.conference.start_hour
return unless event && start_time && event.program&.conference&.start_hour
errors.add(:start_time, "can't be before the conference start hour (#{event.program.conference.start_hour})") if start_time.hour < event.program.conference.start_hour
end

View file

@ -2,6 +2,7 @@
class Room < ApplicationRecord
include RevisionCount
belongs_to :venue
has_many :event_schedules, dependent: :destroy
has_many :tracks

View file

@ -25,7 +25,7 @@ class Survey < ActiveRecord::Base
now = Time.current.in_time_zone(timezone)
if start_date && end_date
now >= start_date && now <= end_date
now.between?(start_date, end_date)
elsif start_date && !end_date
now >= start_date
elsif !start_date && end_date

View file

@ -81,7 +81,7 @@ class Ticket < ApplicationRecord
def tickets_of_conference_have_same_currency
tickets = Ticket.where(conference_id: conference_id)
return if tickets.count.zero? || (tickets.count == 1 && self == tickets.first)
return if tickets.none? || (tickets.one? && self == tickets.first)
unless tickets.all?{|t| t.price_currency == price_currency }
errors.add(:price_currency, 'is different from the existing tickets of this conference.')

View file

@ -97,8 +97,6 @@ class TicketPurchase < ApplicationRecord
end
end
private
def set_week
self.week = created_at.strftime('%W')
save!

View file

@ -233,8 +233,8 @@ class Track < ApplicationRecord
(program.tracks.accepted + program.tracks.confirmed - [self]).each do |existing_track|
next unless existing_track.room == room && existing_track.start_date && existing_track.end_date
if start_date >= existing_track.start_date && start_date <= existing_track.end_date ||
end_date >= existing_track.start_date && end_date <= existing_track.end_date ||
if start_date.between?(existing_track.start_date, existing_track.end_date) ||
end_date.between?(existing_track.start_date, existing_track.end_date) ||
start_date <= existing_track.start_date && end_date >= existing_track.end_date
errors.add(:track, 'has overlapping dates with a confirmed or accepted track in the same room')
break

View file

@ -30,6 +30,7 @@ class User < ApplicationRecord
:avatar_content_type, :avatar_file_size, :avatar_updated_at, :updated_at, :confirmation_sent_at, :confirmation_token, :reset_password_token]
include Gravtastic
gravtastic size: 32
before_create :setup_role
@ -238,7 +239,7 @@ class User < ApplicationRecord
end
def registered
if registrations.count == 0
if registrations.none?
'None'
else
registrations.map { |r| r.conference.title }.join ', '
@ -247,7 +248,7 @@ class User < ApplicationRecord
def attended
registrations_attended = registrations.where(attended: true)
if registrations_attended.count == 0
if registrations_attended.none?
'None'
else
registrations_attended.map { |r| r.conference.title }.join ', '
@ -271,7 +272,7 @@ class User < ApplicationRecord
end
def self.empty?
User.count == 1 && User.first.email == 'deleted@localhost.osem'
User.one? && User.first.email == 'deleted@localhost.osem'
end
private