Commit 7ebadfe3 authored by Matthias Kaeppler's avatar Matthias Kaeppler

Prepare Ruby 3 support

This commit contains numerous Ruby 3 related fixes
and will make the cut-over easier once it is due.
parent 4b6cd48a
...@@ -83,7 +83,7 @@ module Clusters ...@@ -83,7 +83,7 @@ module Clusters
project_id: clusterable.id project_id: clusterable.id
} }
model.sanitize_sql_array([Arel.sql(order), values]) Arel.sql(model.sanitize_sql_array([Arel.sql(order), values]))
end end
def group_clusters_base_query def group_clusters_base_query
......
...@@ -15,10 +15,10 @@ class AddVerificationToMergeRequestDiffRegistry < ActiveRecord::Migration[6.0] ...@@ -15,10 +15,10 @@ class AddVerificationToMergeRequestDiffRegistry < ActiveRecord::Migration[6.0]
add_column_unless_exists :verification_failure, :string, limit: 255 # rubocop:disable Migration/PreventStrings because https://gitlab.com/gitlab-org/gitlab/-/issues/323806 add_column_unless_exists :verification_failure, :string, limit: 255 # rubocop:disable Migration/PreventStrings because https://gitlab.com/gitlab-org/gitlab/-/issues/323806
end end
def add_column_unless_exists(column, *args) def add_column_unless_exists(column_name, type, **options)
return if column_exists?(:merge_request_diff_registry, column) return if column_exists?(:merge_request_diff_registry, column_name)
add_column REGISTRY, column, *args add_column REGISTRY, column_name, type, **options
end end
def down def down
......
...@@ -88,11 +88,15 @@ module Gitlab ...@@ -88,11 +88,15 @@ module Gitlab
end end
def build_attributes def build_attributes
@attributes_finder.included_attributes.each(&method(:add_permitted_attributes)) @attributes_finder.included_attributes.each do |model_name, attributes|
add_permitted_attributes(model_name, attributes)
end
end end
def build_methods def build_methods
@attributes_finder.methods.each(&method(:add_permitted_attributes)) @attributes_finder.methods.each do |model_name, attributes|
add_permitted_attributes(model_name, attributes)
end
end end
def add_permitted_attributes(model_name, attributes) def add_permitted_attributes(model_name, attributes)
......
...@@ -61,7 +61,9 @@ module Gitlab ...@@ -61,7 +61,9 @@ module Gitlab
# the configuration yaml file too. # the configuration yaml file too.
# Finally, it updates each attribute in the newly imported project/group. # Finally, it updates each attribute in the newly imported project/group.
def create_relations! def create_relations!
relations.each(&method(:process_relation!)) relations.each do |relation_key, relation_definition|
process_relation!(relation_key, relation_definition)
end
end end
def process_relation!(relation_key, relation_definition) def process_relation!(relation_key, relation_definition)
......
...@@ -6,7 +6,8 @@ module Gitlab ...@@ -6,7 +6,8 @@ module Gitlab
original_record_timestamps = model.record_timestamps original_record_timestamps = model.record_timestamps
model.record_timestamps = false model.record_timestamps = false
if block.arity.abs == 1 # negative arity means arguments are optional
if block.arity == 1 || block.arity < 0
block.call(model) block.call(model)
else else
block.call block.call
......
...@@ -111,7 +111,7 @@ namespace :gitlab do ...@@ -111,7 +111,7 @@ namespace :gitlab do
desc 'GitLab | GraphQL | Generate GraphQL docs' desc 'GitLab | GraphQL | Generate GraphQL docs'
task compile_docs: [:environment, :enable_feature_flags] do task compile_docs: [:environment, :enable_feature_flags] do
renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, render_options) renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, **render_options)
renderer.write renderer.write
...@@ -120,7 +120,7 @@ namespace :gitlab do ...@@ -120,7 +120,7 @@ namespace :gitlab do
desc 'GitLab | GraphQL | Check if GraphQL docs are up to date' desc 'GitLab | GraphQL | Check if GraphQL docs are up to date'
task check_docs: [:environment, :enable_feature_flags] do task check_docs: [:environment, :enable_feature_flags] do
renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, render_options) renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, **render_options)
doc = File.read(Rails.root.join(OUTPUT_DIR, 'index.md')) doc = File.read(Rails.root.join(OUTPUT_DIR, 'index.md'))
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'set' require 'set'
require 'fileutils'
class String class String
def red def red
......
...@@ -13,7 +13,7 @@ RSpec.describe UpdateMinimumPasswordLength do ...@@ -13,7 +13,7 @@ RSpec.describe UpdateMinimumPasswordLength do
before do before do
stub_const('ApplicationSetting::DEFAULT_MINIMUM_PASSWORD_LENGTH', 10) stub_const('ApplicationSetting::DEFAULT_MINIMUM_PASSWORD_LENGTH', 10)
allow(Devise.password_length).to receive(:min).and_return(12) allow(Devise).to receive(:password_length).and_return(12..20)
end end
it 'correctly migrates minimum_password_length' do it 'correctly migrates minimum_password_length' do
......
...@@ -931,12 +931,8 @@ RSpec.describe User do ...@@ -931,12 +931,8 @@ RSpec.describe User do
end end
context 'maximum value' do context 'maximum value' do
before do
allow(Devise.password_length).to receive(:max).and_return(201)
end
it 'is determined by the current value of `Devise.password_length.max`' do it 'is determined by the current value of `Devise.password_length.max`' do
expect(password_length.max).to eq(201) expect(password_length.max).to eq(Devise.password_length.max)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment