Skip to content

Commit

Permalink
Update Ruby 3.1 (#207)
Browse files Browse the repository at this point in the history
* Update Ruby 3.1.2

Mit Ruby 3.1 ist u.a. 'net-smtp' aus den Standardabhängigkeiten
entfallen. 'mail' benötigt diese Abhängigkeit und löst diese jedoch erst
ab Version 2.8.0 selbst auf (mikel/mail#1472),
das bisher noch nicht veröffentlicht wurde (nur als RC1).

Co-authored-by: Niels Bennke <[email protected]>
  • Loading branch information
ro3t and nbennke authored Jun 30, 2022
1 parent a75b2cc commit 7879d37
Show file tree
Hide file tree
Showing 76 changed files with 313 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .ruby-gemset
Original file line number Diff line number Diff line change
@@ -1 +1 @@
klarschiff-backoffice-r02
klarschiff-backoffice-r03
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.0.4
ruby-3.1.2
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '~> 3.0.1'
ruby '~> 3.1.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1'
Expand Down Expand Up @@ -63,7 +63,10 @@ gem 'font-awesome-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'kaminari'
gem 'net-imap', require: false # drop after gem mail >= v2.8.0
gem 'net-ldap'
gem 'net-pop', require: false # drop after gem mail >= v2.8.0
gem 'net-smtp', require: false # drop after gem mail >= v2.8.0
gem 'pdfkit'
gem 'rails-i18n'
gem 'rubyXL'
24 changes: 22 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.1.10)
crass (1.0.6)
digest (3.1.0)
erb_lint (0.1.1)
activesupport
better_html (~> 1.0.7)
Expand Down Expand Up @@ -191,7 +192,21 @@ GEM
minitest (5.16.0)
msgpack (1.5.2)
multi_xml (0.6.0)
net-imap (0.2.3)
digest
net-protocol
strscan
net-ldap (0.17.1)
net-pop (0.1.1)
digest
net-protocol
timeout
net-protocol (0.1.3)
timeout
net-smtp (0.3.1)
digest
net-protocol
timeout
nio4r (2.5.8)
nokogiri (1.13.6)
mini_portile2 (~> 2.8.0)
Expand Down Expand Up @@ -316,10 +331,12 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
strscan (3.0.1)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.2.1)
tilt (2.0.10)
timeout (0.3.0)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
Expand Down Expand Up @@ -368,7 +385,10 @@ DEPENDENCIES
jquery-ui-rails
kaminari
listen (~> 3.2)
net-imap
net-ldap
net-pop
net-smtp
pdfkit
pg (~> 1.2)
pronto-rubocop
Expand All @@ -385,7 +405,7 @@ DEPENDENCIES
webdrivers

RUBY VERSION
ruby 3.0.1p64
ruby 3.1.2p20

BUNDLED WITH
2.2.33
2.3.16
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def respond_with_execption(message, skip_internal_error_prefix: false)
def respond_with_forbidden(layout: 'application')
respond_to do |format|
format.any(:csv, :json, :xlsx, :pdf) { head :forbidden }
format.html { render template: 'application/denied', layout: layout, status: :forbidden }
format.html { render template: 'application/denied', layout:, status: :forbidden }
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/citysdk/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def confirm_request(request)
end

def confirm_photo(confirmation_hash)
return unless (photo = Citysdk::Photo.unscoped.find_by(confirmation_hash: confirmation_hash))
return unless (photo = Citysdk::Photo.unscoped.find_by(confirmation_hash:))
pho = photo.becomes(::Photo)
pho.update!(confirmed_at: Time.current)
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/concerns/user_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module UserLogin
private

def login(group_kind: nil)
user = login_user(@credentials[:login], group_kind: group_kind)
user = login_user(@credentials[:login], group_kind:)
if user&.ldap.present?
return login_success(user) if Ldap.login(user.ldap, @credentials[:password])
elsif user&.authenticate(@credentials[:password])
Expand All @@ -27,11 +27,11 @@ def login_success(user)
end

def find_users(login, group_kind: nil)
user_condition(Citysdk::User.active, login: login, group_kind: group_kind)
user_condition(Citysdk::User.active, login:, group_kind:)
end

def login_user(login, group_kind: nil)
user_condition(User.active, login: login, group_kind: group_kind).first
user_condition(User.active, login:, group_kind:).first
end

def user_condition(users, login:, group_kind:)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def update_statuses
date = jobs.first.date
group = jobs.first.group
jobs.update params.require(:job).permit(:status)
@jobs = Job.includes({ issue: :category }, %i[group]).where(group: group, date: date).by_order
@jobs = Job.includes({ issue: :category }, %i[group]).where(group:, date:).by_order
render :reload
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/places_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def address_response(issue)
'issues.external_map.coordinates', x: issue.lon_external&.round, y: issue.lat_external&.round
)
json_response = { address: issue.address, parcel: issue.parcel, property_owner: issue.property_owner,
external_coords: external_coords }
external_coords: }
render json: json_response, status: :ok
end
end
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def icon(color, kind: 'blank')
end

def order_link(label, controller, col)
url = url_for(request_params.merge({ controller: controller,
url = url_for(request_params.merge({ controller:,
order_by: { column: col, dir: order_link_dir(col) } }))
tag.a((label + order_dir_icon(col)).html_safe, href: url) # rubocop:disable Rails/OutputSafety
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/issues_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def grouped_categories(kind_or_isse)

def nav_item(tab, issue, current_tab, issue_or_delegation = :issue)
css_class = "nav-link switch-tab #{:active if tab == current_tab}"
path = send("edit_#{issue_or_delegation}_path", issue, tab: tab)
path = send("edit_#{issue_or_delegation}_path", issue, tab:)
tag.li link_to(t("issues.form.tab.#{tab}"), '#', data: { url: path }, class: css_class), class: 'nav-item'
end

Expand Down Expand Up @@ -111,7 +111,7 @@ def delegation_tooltip(issue)
private

def grouped_categories_for_kind(kind)
Category.includes(:main_category, :sub_category).where(main_category: { kind: kind })
Category.includes(:main_category, :sub_category).where(main_category: { kind: })
.order(MainCategory.arel_table[:name], SubCategory.arel_table[:name])
.to_a.group_by(&:main_category_name).map do |mc, categories|
[mc, categories.map { |c| [c.sub_category_name, c.id] }]
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/inform_on_delegated_issues_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def perform
.group_by(&:delegation).each do |delegation, issues|
recipients, auth_codes = recipients_and_auth_codes(delegation, issues)
IssueMailer.delegation(
to: recipients, issues: issues, auth_codes: auth_codes
to: recipients, issues:, auth_codes:
).deliver_now
end
end
Expand All @@ -19,7 +19,7 @@ def perform
def recipients_and_auth_codes(group, issues)
return [group.users.pluck(:email)] if group.users.exists?
return [group.main_user.email] if group.main_user
[group.email, issues.map { |issue| AuthCode.find_or_create_by(group: group, issue: issue) }]
[group.email, issues.map { |issue| AuthCode.find_or_create_by(group:, issue:) }]
end

def delegated_issues(time)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/notify_on_closed_issues_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class NotifyOnClosedIssuesJob < ApplicationJob

def perform
issues_with_status_changes(Time.current - JobSettings::Issue.status_change_days.days).find_each do |issue|
IssueMailer.closed(to: issue.author, issue: issue).deliver_now
IssueMailer.closed(to: issue.author, issue:).deliver_now
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/jobs/notify_on_group_assigned_responsibility_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class NotifyOnGroupAssignedResponsibilityJob < ApplicationJob
def perform
unaccepted_issues.group_by(&:group).each do |group, issues|
next if (recipients = group.responsibility_notification_recipients).blank?
ResponsibilityMailer.remind_group(group, to: recipients, issues: issues).deliver_later
ResponsibilityMailer.remind_group(group, to: recipients, issues:).deliver_later
Issue.where(id: issues).update_all group_responsibility_notified_at: Time.current # rubocop:disable Rails/SkipsModelValidations
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/notify_on_issues_in_process_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class NotifyOnIssuesInProcessJob < ApplicationJob

def perform
issues_with_status_changes(Time.current - JobSettings::Issue.status_change_days.days).find_each do |issue|
IssueMailer.in_process(to: issue.author, issue: issue).deliver_now
IssueMailer.in_process(to: issue.author, issue:).deliver_now
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/mailers/confirmation_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ def issue(to:, issue_id:, confirmation_hash:, with_photo: false)
@confirmation_url = "#{mailer_config[:confirmation_base_url]}/#{confirmation_hash}/issue"
@delete_url = "#{mailer_config[:confirmation_base_url]}/#{confirmation_hash}/revoke_issue"
@issue_url = Settings::Instance.frontend_issue_url % issue_id
mail(to: to, interpolation: { subject: { number: issue_id } })
mail(to:, interpolation: { subject: { number: issue_id } })
end

def supporter(to:, issue_id:, confirmation_hash:)
@url = "#{mailer_config[:confirmation_base_url]}/#{confirmation_hash}/vote"
mail(to: to, interpolation: { subject: { number: issue_id } })
mail(to:, interpolation: { subject: { number: issue_id } })
end

def abuse_report(to:, issue_id:, confirmation_hash:)
@url = "#{mailer_config[:confirmation_base_url]}/#{confirmation_hash}/abuse"
mail(to: to, interpolation: { subject: { number: issue_id } })
mail(to:, interpolation: { subject: { number: issue_id } })
end

def photo(to:, issue_id:, confirmation_hash:)
@url = "#{mailer_config[:confirmation_base_url]}/#{confirmation_hash}/photo"
mail(to: to, interpolation: { subject: { number: issue_id } })
mail(to:, interpolation: { subject: { number: issue_id } })
end
end
2 changes: 1 addition & 1 deletion app/mailers/feedback_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ def notification(issue:, to: nil, auth_code: nil)
to ||= mailer_config.dig(:feedback_mailer, :notification, :to)
@issue = issue
@link = auth_code ? issue_url(issue.id, auth_code: auth_code.uuid) : issue_url(issue.id)
mail(to: to, interpolation: { subject: { number: issue.id } })
mail(to:, interpolation: { subject: { number: issue.id } })
end
end
8 changes: 4 additions & 4 deletions app/mailers/issue_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ def forward(issue_email:)

def in_process(to:, issue:)
@issue = issue
mail(to: to, interpolation: { subject: { number: @issue.id } })
mail(to:, interpolation: { subject: { number: @issue.id } })
end

def closed(to:, issue:)
@issue = issue
mail(to: to, interpolation: { subject: { number: @issue.id } })
mail(to:, interpolation: { subject: { number: @issue.id } })
end

def delegation(to:, issues:, auth_codes: [])
@issues = issues
@auth_codes = auth_codes
mail to: to
mail to:
end

def inform_editorial_staff(to:, issues:, days:)
@days = days
@issues = issues
mail(to: to, interpolation: { subject: { title: Settings::Instance.name } })
mail(to:, interpolation: { subject: { title: Settings::Instance.name } })
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/responsibility_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class ResponsibilityMailer < ApplicationMailer
def issue(issue, to:, auth_code: nil)
@issue = issue
@issue_url = auth_code ? issues_url(auth_code: auth_code.uuid) : edit_issue_url(issue)
mail to: to, interpolation: { subject: { number: @issue.id } }
mail to:, interpolation: { subject: { number: @issue.id } }
end

def remind_group(group, to:, issues:)
@issues = issues
@days = JobSettings::Issue.group_responsibility_notification_deadline_days
mail to: to, interpolation: { subject: { group: group.short_name } }
mail to:, interpolation: { subject: { group: group.short_name } }
end
end
2 changes: 1 addition & 1 deletion app/mailers/test_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
class TestMailer < ApplicationMailer
def test(to:)
headers['X-Override-Consolidation'] = true
mail to: to
mail to:
end
end
4 changes: 2 additions & 2 deletions app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def to_s
end

def group(lat:, lon:)
responsibilities.regional(lat: lat, lon: lon).first&.group ||
Group.regional(lat: lat, lon: lon).find_by(reference_default: true)
responsibilities.regional(lat:, lon:).first&.group ||
Group.regional(lat:, lon:).find_by(reference_default: true)
end
end
10 changes: 3 additions & 7 deletions app/models/citysdk/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,10 @@ def delegation_name
private

def extended_attributes
ea = { detailed_status: detailed_status, detailed_status_datetime: detailed_status_datetime,
description_public: description_public, expected_closure: expected_closure,
priority: priority_before_type_cast, media_urls: media_urls, photo_required: photo_required,
trust: trust_level_before_type_cast, votes: votes }
ea = { detailed_status:, detailed_status_datetime:, description_public:, expected_closure:, votes:,
priority: priority_before_type_cast, media_urls:, photo_required:, trust: trust_level_before_type_cast }
ea[:property_owner] = property_owner if @property_attributes
if @job_detail_attributes
ea.merge! delegation: delegation_name, job_status: job_status, job_priority: job_priority
end
ea.merge!(delegation: delegation_name, job_status:, job_priority:) if @job_detail_attributes
ea
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/citysdk/request_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RequestFilter
attr_reader :collection

def initialize(params = {}, tips:)
@collection = Citysdk::Request.authorized(tips: tips).includes(includes).references(includes).eager_load(
@collection = Citysdk::Request.authorized(tips:).includes(includes).references(includes).eager_load(
:external_photos, :supporters
)
filter_collection(params)
Expand Down Expand Up @@ -45,7 +45,7 @@ def default_filter_status(params)

def default_filter_area(params)
return if (lat = params[:lat]).blank? || (long = params[:long]).blank? || (radius = params[:radius]).blank?
@collection = @collection.where(<<~SQL.squish, lat: lat, long: long, radius: radius.to_f / 100_000)
@collection = @collection.where(<<~SQL.squish, lat:, long:, radius: radius.to_f / 100_000)
ST_Within(#{Issue.quoted_table_name}."position",
ST_Buffer(ST_SetSRID(ST_MakePoint(:lat, :long), 4326), :radius))
SQL
Expand Down
2 changes: 1 addition & 1 deletion app/models/citysdk/request_setter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def media=(value)

filename = 'filename.jpg'
mime_type = Mime::Type.lookup_by_extension(File.extname(filename)[1..]).to_s
self.new_photo = ActionDispatch::Http::UploadedFile.new(tempfile: tempfile, filename: filename, type: mime_type)
self.new_photo = ActionDispatch::Http::UploadedFile.new(tempfile:, filename:, type: mime_type)
self.photo_requested = false
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/confirmation_with_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def confirm

def send_confirmation
return if respond_to?(:skip_email_notification) && skip_email_notification
options = { to: author, issue_id: respond_to?(:issue_id) ? issue_id : id, confirmation_hash: confirmation_hash }
options = { to: author, issue_id: respond_to?(:issue_id) ? issue_id : id, confirmation_hash: }
ConfirmationMailer.send(self.class.model_name.singular, **options).deliver_later
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def generate(attr, _action_key, old_value, new_value)
subject = proxy_association.owner
old, new = converted_changes(attr, subject, old_value, new_value)
return if old.blank? && new.blank?
create table: subject.model_name.element, attr: attr, issue_id: Logging.issue_id(subject),
create table: subject.model_name.element, attr:, issue_id: Logging.issue_id(subject),
subject_id: subject.id, subject_name: subject.logging_subject_name,
action: Logging.generate_action(subject.class, attr, :update, old, new),
user: Current.user, auth_code: Current.user&.auth_code,
Expand Down Expand Up @@ -85,7 +85,7 @@ def log_habtm_remove(obj)

def log_assoc(action)
return unless id
log_entries.create table: model_name.element, action: action, user: Current.user,
log_entries.create table: model_name.element, action:, user: Current.user,
auth_code: Current.user&.auth_code, subject_id: id, subject_name: logging_subject_name,
issue_id: Logging.issue_id(self)
end
Expand Down
Loading

0 comments on commit 7879d37

Please sign in to comment.