FIX: Support Ruby 3 keyword arguments
This commit is contained in:
parent
5569723321
commit
dbbfad7ed0
|
@ -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
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|||
|
||||
it "creates a multipart upload and creates an external upload stub that is marked as multipart" do
|
||||
stub_create_multipart_request
|
||||
post "/uploads/create-multipart.json", {
|
||||
post "/uploads/create-multipart.json", **{
|
||||
params: {
|
||||
file_name: "test.png",
|
||||
file_size: 1024,
|
||||
|
@ -879,7 +879,7 @@ describe UploadsController do
|
|||
"test.png", "image/png", metadata: { "sha1-checksum" => "testing" }
|
||||
).returns({ key: "test" })
|
||||
|
||||
post "/uploads/create-multipart.json", {
|
||||
post "/uploads/create-multipart.json", **{
|
||||
params: {
|
||||
file_name: "test.png",
|
||||
file_size: 1024,
|
||||
|
|
|
@ -50,7 +50,7 @@ describe UserAuthenticator do
|
|||
|
||||
authentication = github_auth(true)
|
||||
|
||||
UserAuthenticator.new(user, authentication: authentication).finish
|
||||
UserAuthenticator.new(user, { authentication: authentication }).finish
|
||||
expect(user.email_confirmed?).to be_truthy
|
||||
expect(group.usernames).to include(user.username)
|
||||
end
|
||||
|
@ -60,7 +60,7 @@ describe UserAuthenticator do
|
|||
|
||||
authentication = github_auth(false)
|
||||
|
||||
UserAuthenticator.new(user, authentication: authentication).finish
|
||||
UserAuthenticator.new(user, { authentication: authentication }).finish
|
||||
expect(user.email_confirmed?).to be_falsey
|
||||
expect(group.usernames).not_to include(user.username)
|
||||
end
|
||||
|
@ -70,7 +70,7 @@ describe UserAuthenticator do
|
|||
|
||||
authentication = github_auth(true)
|
||||
|
||||
UserAuthenticator.new(user, authentication: authentication).finish
|
||||
UserAuthenticator.new(user, { authentication: authentication }).finish
|
||||
expect(user.email_confirmed?).to be_falsey
|
||||
expect(group.usernames).not_to include(user.username)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue