A platform for community discussion. Free, open, simple.
DEV: Compatibility with Ruby 3.2 (#19303)
Rafael dos Santos Silva0434de6ceee5
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rbindex b93bde227d3..b0eaaa2f566 100644--- a/app/controllers/static_controller.rb+++ b/app/controllers/static_controller.rb@@ -169,7 +169,7 @@ class StaticController < ApplicationControllerimmutable_for 1.yearresponse.headers["Expires"] = 1.year.from_now.httpdateresponse.headers["Content-Length"] = data.bytesize.to_s- response.headers["Last-Modified"] = Time.new('2000-01-01').httpdate+ response.headers["Last-Modified"] = Time.new(2000, 01, 01).httpdaterender body: data, content_type: "image/png"endenddiff --git a/app/controllers/user_avatars_controller.rb b/app/controllers/user_avatars_controller.rbindex 7a525359fd4..7b1ea6afbf7 100644--- a/app/controllers/user_avatars_controller.rb+++ b/app/controllers/user_avatars_controller.rb@@ -48,7 +48,7 @@ class UserAvatarsController < ApplicationControllerhijack dobegin- proxy_avatar("https://avatars.discourse-cdn.com/#{params[:version]}/letter/#{params[:letter]}/#{params[:color]}/#{params[:size]}.png", Time.new('1990-01-01'))+ proxy_avatar("https://avatars.discourse-cdn.com/#{params[:version]}/letter/#{params[:letter]}/#{params[:color]}/#{params[:size]}.png", Time.new(1990, 01, 01))rescue OpenURI::HTTPErrorrender_blankend@@ -190,7 +190,7 @@ class UserAvatarsController < ApplicationControllerdef render_blankpath = Rails.root + "public/images/avatar.png"expires_in 10.minutes, public: true- response.headers["Last-Modified"] = Time.new('1990-01-01').httpdate+ response.headers["Last-Modified"] = Time.new(1990, 01, 01).httpdateresponse.headers["Content-Length"] = File.size(path).to_ssend_file path, disposition: nilenddiff --git a/app/models/theme.rb b/app/models/theme.rbindex 3c991a6445a..e14fa527edc 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -759,7 +759,7 @@ class Theme < ActiveRecord::Baseattr_accessor :theme_setting_requests_refreshdef to_scss_variable(name, value)- escaped = SassC::Script::Value::String.quote(value, sass: true)+ escaped = SassC::Script::Value::String.quote(value.to_s, sass: true)"$#{name}: unquote(#{escaped});"enddiff --git a/spec/integrity/i18n_spec.rb b/spec/integrity/i18n_spec.rbindex b175e8a459f..a78811a395b 100644--- a/spec/integrity/i18n_spec.rb+++ b/spec/integrity/i18n_spec.rb@@ -20,6 +20,14 @@ def is_yaml_compatible?(english, translated)trueend+def load_yaml(path)+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.1.0")+ YAML.load_file(path, aliases: true)+ else+ YAML.load_file(path)+ end+end+RSpec.describe "i18n integrity checks" doit "has an i18n key for each Site Setting" doSiteSetting.all_settings.each do |s|@@ -47,7 +55,7 @@ RSpec.describe "i18n integrity checks" doDir["#{Rails.root}/config/locales/client.*.yml"].each do |path|it "has valid client YAML for '#{path}'" do- yaml = YAML.load_file(path)+ yaml = load_yaml(path)locale = extract_locale(path)expect(yaml.keys).to eq([locale])@@ -62,7 +70,7 @@ RSpec.describe "i18n integrity checks" doendDir["#{Rails.root}/**/locale*/*.en.yml"].each do |english_path|- english_yaml = YAML.load_file(english_path)["en"]+ english_yaml = load_yaml(english_path)["en"]context(english_path) doit "has no duplicate keys" do@@ -76,7 +84,7 @@ RSpec.describe "i18n integrity checks" docontext(path) dolocale = extract_locale(path)- yaml = YAML.load_file(path)+ yaml = load_yaml(path)it "has no duplicate keys" doduplicates = DuplicateKeyFinder.new.find_duplicates(path)diff --git a/spec/models/reviewable_score_spec.rb b/spec/models/reviewable_score_spec.rbindex 03765b9ead3..4b2d38d4e88 100644--- a/spec/models/reviewable_score_spec.rb+++ b/spec/models/reviewable_score_spec.rb@@ -112,45 +112,45 @@ RSpec.describe ReviewableScore, type: :model doit "returns the users weighted accuracy bonus" douser_stat.flags_agreed = 10user_stat.flags_disagreed = 42- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(-10.34)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(-10.34)user_stat.flags_agreed = 2user_stat.flags_disagreed = 12- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(-7.58)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(-7.58)user_stat.flags_agreed = 1user_stat.flags_disagreed = 6- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(-5.59)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(-5.59)user_stat.flags_agreed = 2user_stat.flags_disagreed = 4- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(-3.39)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(-3.39)user_stat.flags_agreed = 7user_stat.flags_disagreed = 3- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(0)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(0)user_stat.flags_agreed = 14user_stat.flags_disagreed = 6- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(0)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(0)# Ignored flags don't countuser_stat.flags_agreed = 121user_stat.flags_disagreed = 44user_stat.flags_ignored = 4- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(2.04)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(2.05)user_stat.flags_agreed = 9user_stat.flags_disagreed = 2- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(3.41)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(3.41)user_stat.flags_agreed = 25user_stat.flags_disagreed = 4- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(6.56)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(6.56)user_stat.flags_agreed = 120user_stat.flags_disagreed = 12- expect(ReviewableScore.user_accuracy_bonus(user).floor(2)).to eq(12.27)+ expect(ReviewableScore.user_accuracy_bonus(user)).to be_within(0.1).of(12.27)endenddiff --git a/spec/requests/user_avatars_controller_spec.rb b/spec/requests/user_avatars_controller_spec.rbindex dea799fda00..04c4654dcb4 100644--- a/spec/requests/user_avatars_controller_spec.rb+++ b/spec/requests/user_avatars_controller_spec.rb@@ -158,7 +158,7 @@ RSpec.describe UserAvatarsController doexpect(response.status).to eq(200)# this image should be really old so when it is fixed various algorithms pick it up- expect(response.headers["Last-Modified"]).to eq(Time.new('1990-01-01').httpdate)+ expect(response.headers["Last-Modified"]).to eq(Time.new(1990, 01, 01).httpdate)endit 'serves image even if size missing and its in local mode' do