FIX: Support Ruby 3 keyword arguments

FIX: Support Ruby 3 keyword arguments

diff --git a/app/models/theme.rb b/app/models/theme.rb
index 494e6fa..e6c81bb 100644
--- a/app/models/theme.rb
+++ b/app/models/theme.rb
@@ -679,10 +679,10 @@ class Theme < ActiveRecord::Base
     keys = schema["items"]["properties"].keys
     return if !keys
 
-    current_values = CSV.parse(setting_row.value, { col_sep: '|' }).flatten
+    current_values = CSV.parse(setting_row.value, **{ col_sep: '|' }).flatten
     new_values = []
     current_values.each do |item|
-      parts = CSV.parse(item, { col_sep: ',' }).flatten
+      parts = CSV.parse(item, **{ col_sep: ',' }).flatten
       props = parts.map.with_index { |p, idx| [keys[idx], p] }.to_h
       new_values << props
     end
diff --git a/app/views/about/index.html.erb b/app/views/about/index.html.erb
index 2caba68..fc0e22a 100644
--- a/app/views/about/index.html.erb
+++ b/app/views/about/index.html.erb
@@ -2,7 +2,7 @@
 
 <section itemscope itemtype="https://schema.org/AboutPage">
   <h1 itemprop="name">
-    <%=t "js.about.title", {title: @about.title} %>
+    <%=t "js.about.title", **{title: @about.title} %>
   </h1>
 
   <div itemprop="text">
diff --git a/lib/discourse_redis.rb b/lib/discourse_redis.rb
index 45902dc..341f3d1 100644
--- a/lib/discourse_redis.rb
+++ b/lib/discourse_redis.rb
@@ -94,12 +94,12 @@ class DiscourseRedis
         end
 
       if block
-        @redis.scan_each(options) do |key|
+        @redis.scan_each(**options) do |key|
           key = remove_namespace(key) if @namespace
           block.call(key)
         end
       else
-        @redis.scan_each(options).map do |key|
+        @redis.scan_each(**options).map do |key|
           key = remove_namespace(key) if @namespace
           key
         end
diff --git a/lib/seed_data/categories.rb b/lib/seed_data/categories.rb
index c4e2948..b697b7b 100644
--- a/lib/seed_data/categories.rb
+++ b/lib/seed_data/categories.rb
@@ -21,7 +21,7 @@ module SeedData
         categories(site_setting_names).each do |params|
           params.slice!(:site_setting_name, :name, :description)
           params[:skip_changed] = skip_changed
-          update_category(params)
+          update_category(**params)
         end
       end
     end
diff --git a/lib/seed_data/topics.rb b/lib/seed_data/topics.rb
index 03936ce..7ebd2bd 100644
--- a/lib/seed_data/topics.rb
+++ b/lib/seed_data/topics.rb
@@ -23,7 +23,7 @@ module SeedData
         topics(site_setting_names).each do |params|
           params.except!(:category, :after_create)
           params[:skip_changed] = skip_changed
-          update_topic(params)
+          update_topic(**params)
         end
       end
     end
diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake
index 4abfaf0..955fa97 100644
--- a/lib/tasks/posts.rake
+++ b/lib/tasks/posts.rake
@@ -137,7 +137,7 @@ def rebake_post(post, opts = {})
   if !opts[:priority]
     opts[:priority] = :ultra_low
   end
-  post.rebake!(opts)
+  post.rebake!(**opts)
 rescue => e
   puts "", "Failed to rebake (topic_id: #{post.topic_id}, post_id: #{post.id})", e, e.backtrace.join("\n")
 end
diff --git a/lib/upload_recovery.rb b/lib/upload_recovery.rb
index 9092ee0..04f5ea9 100644
--- a/lib/upload_recovery.rb
+++ b/lib/upload_recovery.rb
@@ -60,9 +60,9 @@ class UploadRecovery
     }
 
     if Discourse.store.external?
-      recover_post_upload_from_s3(attributes)
+      recover_post_upload_from_s3(**attributes)
     else
-      recover_post_upload_from_local(attributes)
+      recover_post_upload_from_local(**attributes)
     end
   end
 
diff --git a/lib/validators/post_validator.rb b/lib/validators/post_validator.rb
index 8428bed..5a65d74 100644
--- a/lib/validators/post_validator.rb
+++ b/lib/validators/post_validator.rb
@@ -20,11 +20,11 @@ class PostValidator < ActiveModel::Validator
 
   def presence(post)
     unless options[:skip_topic]
-      post.errors.add(:topic_id, :blank, options) if post.topic_id.blank?
+      post.errors.add(:topic_id, :blank, **options) if post.topic_id.blank?
     end
 
     if post.new_record? && post.user_id.nil?
-      post.errors.add(:user_id, :blank, options)
+      post.errors.add(:user_id, :blank, **options)
     end
   end
 
diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rb
index 59f76e5..2f4c26f 100644
--- a/spec/requests/posts_controller_spec.rb
+++ b/spec/requests/posts_controller_spec.rb
@@ -72,7 +72,7 @@ end
 
 shared_examples 'action requires login' do |method, url, params = {}|
   it 'raises an exception when not logged in' do
-    self.public_send(method, url, params)
+    self.public_send(method, url, **params)
     expect(response.status).to eq(403)
   end
 end
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index 456ab0a..281b3ae 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -3369,7 +3369,7 @@ RSpec.describe TopicsController do
 
         TopicTrackingState.expects(:publish_dismiss_new).with(user.id, topic_ids: [topic2.id, topic3.id]).at_least_once
 
-        put "/topics/reset-new.json", { params: { topic_ids: [topic2.id, topic3.id] } }
+        put "/topics/reset-new.json", **{ params: { topic_ids: [topic2.id, topic3.id] } }
         expect(response.status).to eq(200)
         user.reload
         expect(user.user_stat.new_since.to_date).not_to eq(old_date.to_date)
@@ -3391,7 +3391,7 @@ RSpec.describe TopicsController do
           old_date = 2.years.ago
           user.user_stat.update_column(:new_since, old_date)
 
-          put "/topics/reset-new.json?tracked=true", { params: { topic_ids: [topic2.id, topic3.id] } }
+          put "/topics/reset-new.json?tracked=true", **{ params: { topic_ids: [topic2.id, topic3.id] } }
           expect(response.status).to eq(200)
           user.reload
           expect(user.user_stat.new_since.to_date).to eq(old_date.to_date)
@@ -3412,7 +3412,7 @@ RSpec.describe TopicsController do
 
           create_post # This is a new post, but is not tracked so a record will not be created for it
           expect do
-            put "/topics/reset-new.json?tracked=true", { params: { topic_ids: [tracked_topic.id, topic2.id, topic3.id] } }
+            put "/topics/reset-new.json?tracked=true", **{ params: { topic_ids: [tracked_topic.id, topic2.id, topic3.id] } }
           end.to change { DismissedTopicUser.where(user_id: user.id).count }.by(2)
           expect(DismissedTopicUser.where(user_id: user.id).pluck(:topic_id)).to match_array([tracked_topic.id, topic2.id])
         end
diff --git a/spec/requests/uploads_controller_spec.rb b/spec/requests/uploads_controller_spec.rb
index 8fbb686..b142eed 100644
--- a/spec/requests/uploads_controller_spec.rb
+++ b/spec/requests/uploads_controller_spec.rb
@@ -742,7 +742,7 @@ describe UploadsController do
       end
 
       it "includes accepted metadata in the presigned url when provided" do
-        post "/uploads/generate-presigned-put.json", {
+        post "/uploads/generate-presigned-put.json", **{
           params: {
             file_name: "test.png",
             file_size: 1024,
@@ -806,7 +806,7 @@ describe UploadsController do
 
       it "returns 422 when the create request errors" do
         FileStore::S3Store.any_instance.stubs(:create_multipart).raises(Aws::S3::Errors::ServiceError.new({}, "test"))
-        post "/uploads/create-multipart.json", {
+        post "/uploads/create-multipart.json", **{
           params: {
             file_name: "test.png",
             file_size: 1024,
@@ -818,7 +818,7 @@ describe UploadsController do
 
       it "returns 422 when the file is an attachment and it's too big" do
         SiteSetting.max_attachment_size_kb = 1024
-        post "/uploads/create-multipart.json", {
+        post "/uploads/create-multipart.json", **{
           params: {
             file_name: "test.zip",
             file_size: 9999999,
@@ -846,7 +846,7 @@ describe UploadsController do
 

[... diff too long, it was truncated ...]

GitHub sha: dbbfad7ed07c47674f9dee4ac7021ca51cc04e2e

This commit appears in #14516 which was approved by eviltrout. It was merged by eviltrout.