mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
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
|
keys = schema["items"]["properties"].keys
|
||||||
return if !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 = []
|
new_values = []
|
||||||
current_values.each do |item|
|
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
|
props = parts.map.with_index { |p, idx| [keys[idx], p] }.to_h
|
||||||
new_values << props
|
new_values << props
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<section itemscope itemtype="https://schema.org/AboutPage">
|
<section itemscope itemtype="https://schema.org/AboutPage">
|
||||||
<h1 itemprop="name">
|
<h1 itemprop="name">
|
||||||
<%=t "js.about.title", {title: @about.title} %>
|
<%=t "js.about.title", **{title: @about.title} %>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div itemprop="text">
|
<div itemprop="text">
|
||||||
|
|
|
@ -94,12 +94,12 @@ class DiscourseRedis
|
||||||
end
|
end
|
||||||
|
|
||||||
if block
|
if block
|
||||||
@redis.scan_each(options) do |key|
|
@redis.scan_each(**options) do |key|
|
||||||
key = remove_namespace(key) if @namespace
|
key = remove_namespace(key) if @namespace
|
||||||
block.call(key)
|
block.call(key)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@redis.scan_each(options).map do |key|
|
@redis.scan_each(**options).map do |key|
|
||||||
key = remove_namespace(key) if @namespace
|
key = remove_namespace(key) if @namespace
|
||||||
key
|
key
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ module SeedData
|
||||||
categories(site_setting_names).each do |params|
|
categories(site_setting_names).each do |params|
|
||||||
params.slice!(:site_setting_name, :name, :description)
|
params.slice!(:site_setting_name, :name, :description)
|
||||||
params[:skip_changed] = skip_changed
|
params[:skip_changed] = skip_changed
|
||||||
update_category(params)
|
update_category(**params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ module SeedData
|
||||||
topics(site_setting_names).each do |params|
|
topics(site_setting_names).each do |params|
|
||||||
params.except!(:category, :after_create)
|
params.except!(:category, :after_create)
|
||||||
params[:skip_changed] = skip_changed
|
params[:skip_changed] = skip_changed
|
||||||
update_topic(params)
|
update_topic(**params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -137,7 +137,7 @@ def rebake_post(post, opts = {})
|
||||||
if !opts[:priority]
|
if !opts[:priority]
|
||||||
opts[:priority] = :ultra_low
|
opts[:priority] = :ultra_low
|
||||||
end
|
end
|
||||||
post.rebake!(opts)
|
post.rebake!(**opts)
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "", "Failed to rebake (topic_id: #{post.topic_id}, post_id: #{post.id})", e, e.backtrace.join("\n")
|
puts "", "Failed to rebake (topic_id: #{post.topic_id}, post_id: #{post.id})", e, e.backtrace.join("\n")
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,9 +60,9 @@ class UploadRecovery
|
||||||
}
|
}
|
||||||
|
|
||||||
if Discourse.store.external?
|
if Discourse.store.external?
|
||||||
recover_post_upload_from_s3(attributes)
|
recover_post_upload_from_s3(**attributes)
|
||||||
else
|
else
|
||||||
recover_post_upload_from_local(attributes)
|
recover_post_upload_from_local(**attributes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ class PostValidator < ActiveModel::Validator
|
||||||
|
|
||||||
def presence(post)
|
def presence(post)
|
||||||
unless options[:skip_topic]
|
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
|
end
|
||||||
|
|
||||||
if post.new_record? && post.user_id.nil?
|
if post.new_record? && post.user_id.nil?
|
||||||
post.errors.add(:user_id, :blank, options)
|
post.errors.add(:user_id, :blank, **options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ end
|
||||||
|
|
||||||
shared_examples 'action requires login' do |method, url, params = {}|
|
shared_examples 'action requires login' do |method, url, params = {}|
|
||||||
it 'raises an exception when not logged in' do
|
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)
|
expect(response.status).to eq(403)
|
||||||
end
|
end
|
||||||
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
|
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)
|
expect(response.status).to eq(200)
|
||||||
user.reload
|
user.reload
|
||||||
expect(user.user_stat.new_since.to_date).not_to eq(old_date.to_date)
|
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
|
old_date = 2.years.ago
|
||||||
user.user_stat.update_column(:new_since, old_date)
|
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)
|
expect(response.status).to eq(200)
|
||||||
user.reload
|
user.reload
|
||||||
expect(user.user_stat.new_since.to_date).to eq(old_date.to_date)
|
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
|
create_post # This is a new post, but is not tracked so a record will not be created for it
|
||||||
expect do
|
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)
|
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])
|
expect(DismissedTopicUser.where(user_id: user.id).pluck(:topic_id)).to match_array([tracked_topic.id, topic2.id])
|
||||||
end
|
end
|
||||||
|
|
|
@ -742,7 +742,7 @@ describe UploadsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "includes accepted metadata in the presigned url when provided" do
|
it "includes accepted metadata in the presigned url when provided" do
|
||||||
post "/uploads/generate-presigned-put.json", {
|
post "/uploads/generate-presigned-put.json", **{
|
||||||
params: {
|
params: {
|
||||||
file_name: "test.png",
|
file_name: "test.png",
|
||||||
file_size: 1024,
|
file_size: 1024,
|
||||||
|
@ -806,7 +806,7 @@ describe UploadsController do
|
||||||
|
|
||||||
it "returns 422 when the create request errors" do
|
it "returns 422 when the create request errors" do
|
||||||
FileStore::S3Store.any_instance.stubs(:create_multipart).raises(Aws::S3::Errors::ServiceError.new({}, "test"))
|
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: {
|
params: {
|
||||||
file_name: "test.png",
|
file_name: "test.png",
|
||||||
file_size: 1024,
|
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
|
it "returns 422 when the file is an attachment and it's too big" do
|
||||||
SiteSetting.max_attachment_size_kb = 1024
|
SiteSetting.max_attachment_size_kb = 1024
|
||||||
post "/uploads/create-multipart.json", {
|
post "/uploads/create-multipart.json", **{
|
||||||
params: {
|
params: {
|
||||||
file_name: "test.zip",
|
file_name: "test.zip",
|
||||||
file_size: 9999999,
|
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
|
it "creates a multipart upload and creates an external upload stub that is marked as multipart" do
|
||||||
stub_create_multipart_request
|
stub_create_multipart_request
|
||||||
post "/uploads/create-multipart.json", {
|
post "/uploads/create-multipart.json", **{
|
||||||
params: {
|
params: {
|
||||||
file_name: "test.png",
|
file_name: "test.png",
|
||||||
file_size: 1024,
|
file_size: 1024,
|
||||||
|
@ -879,7 +879,7 @@ describe UploadsController do
|
||||||
"test.png", "image/png", metadata: { "sha1-checksum" => "testing" }
|
"test.png", "image/png", metadata: { "sha1-checksum" => "testing" }
|
||||||
).returns({ key: "test" })
|
).returns({ key: "test" })
|
||||||
|
|
||||||
post "/uploads/create-multipart.json", {
|
post "/uploads/create-multipart.json", **{
|
||||||
params: {
|
params: {
|
||||||
file_name: "test.png",
|
file_name: "test.png",
|
||||||
file_size: 1024,
|
file_size: 1024,
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe UserAuthenticator do
|
||||||
|
|
||||||
authentication = github_auth(true)
|
authentication = github_auth(true)
|
||||||
|
|
||||||
UserAuthenticator.new(user, authentication: authentication).finish
|
UserAuthenticator.new(user, { authentication: authentication }).finish
|
||||||
expect(user.email_confirmed?).to be_truthy
|
expect(user.email_confirmed?).to be_truthy
|
||||||
expect(group.usernames).to include(user.username)
|
expect(group.usernames).to include(user.username)
|
||||||
end
|
end
|
||||||
|
@ -60,7 +60,7 @@ describe UserAuthenticator do
|
||||||
|
|
||||||
authentication = github_auth(false)
|
authentication = github_auth(false)
|
||||||
|
|
||||||
UserAuthenticator.new(user, authentication: authentication).finish
|
UserAuthenticator.new(user, { authentication: authentication }).finish
|
||||||
expect(user.email_confirmed?).to be_falsey
|
expect(user.email_confirmed?).to be_falsey
|
||||||
expect(group.usernames).not_to include(user.username)
|
expect(group.usernames).not_to include(user.username)
|
||||||
end
|
end
|
||||||
|
@ -70,7 +70,7 @@ describe UserAuthenticator do
|
||||||
|
|
||||||
authentication = github_auth(true)
|
authentication = github_auth(true)
|
||||||
|
|
||||||
UserAuthenticator.new(user, authentication: authentication).finish
|
UserAuthenticator.new(user, { authentication: authentication }).finish
|
||||||
expect(user.email_confirmed?).to be_falsey
|
expect(user.email_confirmed?).to be_falsey
|
||||||
expect(group.usernames).not_to include(user.username)
|
expect(group.usernames).not_to include(user.username)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user