From 54f165beae0c8ff9c96b9b0375df50b57e449143 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 2 Feb 2023 12:24:42 +0000 Subject: [PATCH] DEV: Correct syntax_tree violations --- .../search_ranking_weights_validator.rb | 3 +- .../search_ranking_weights_validator_spec.rb | 28 +++++++++---------- spec/script/import_scripts/base_spec.rb | 14 +++------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/lib/validators/search_ranking_weights_validator.rb b/lib/validators/search_ranking_weights_validator.rb index da5f1e2ab86..58e7c25c221 100644 --- a/lib/validators/search_ranking_weights_validator.rb +++ b/lib/validators/search_ranking_weights_validator.rb @@ -6,7 +6,8 @@ class SearchRankingWeightsValidator end WEIGHT_REGEXP = "1\.0|0\.[0-9]+" - WEIGHTS_REGEXP = /{(?#{WEIGHT_REGEXP}),(?#{WEIGHT_REGEXP}),(?#{WEIGHT_REGEXP}),(?#{WEIGHT_REGEXP})}/ + WEIGHTS_REGEXP = + /{(?#{WEIGHT_REGEXP}),(?#{WEIGHT_REGEXP}),(?#{WEIGHT_REGEXP}),(?#{WEIGHT_REGEXP})}/ def valid_value?(value) return true if value.blank? diff --git a/spec/lib/validators/search_ranking_weights_validator_spec.rb b/spec/lib/validators/search_ranking_weights_validator_spec.rb index 02de3d46ac7..8845e3cc55d 100644 --- a/spec/lib/validators/search_ranking_weights_validator_spec.rb +++ b/spec/lib/validators/search_ranking_weights_validator_spec.rb @@ -1,25 +1,23 @@ # frozen_string_literal: true RSpec.describe SearchRankingWeightsValidator do - it 'allows a blank value to be set' do - expect do - SiteSetting.search_ranking_weights = '' - end.not_to raise_error + it "allows a blank value to be set" do + expect { SiteSetting.search_ranking_weights = "" }.not_to raise_error end - it 'raises the right error when value is invalid' do - expect do - SiteSetting.search_ranking_weights = 'test' - end.to raise_error(Discourse::InvalidParameters, /#{I18n.t("site_settings.errors.invalid_search_ranking_weights")}/) + it "raises the right error when value is invalid" do + expect { SiteSetting.search_ranking_weights = "test" }.to raise_error( + Discourse::InvalidParameters, + /#{I18n.t("site_settings.errors.invalid_search_ranking_weights")}/, + ) - expect do - SiteSetting.search_ranking_weights = '{1.1,0.1,0.2,0.3}' - end.to raise_error(Discourse::InvalidParameters, /#{I18n.t("site_settings.errors.invalid_search_ranking_weights")}/) + expect { SiteSetting.search_ranking_weights = "{1.1,0.1,0.2,0.3}" }.to raise_error( + Discourse::InvalidParameters, + /#{I18n.t("site_settings.errors.invalid_search_ranking_weights")}/, + ) end - it 'sets the site setting when value is valid' do - expect do - SiteSetting.search_ranking_weights = '{0.001,0.2,0.003,1.0}' - end.to_not raise_error + it "sets the site setting when value is valid" do + expect { SiteSetting.search_ranking_weights = "{0.001,0.2,0.003,1.0}" }.to_not raise_error end end diff --git a/spec/script/import_scripts/base_spec.rb b/spec/script/import_scripts/base_spec.rb index 86a9ba42df2..a90ccf3c03d 100644 --- a/spec/script/import_scripts/base_spec.rb +++ b/spec/script/import_scripts/base_spec.rb @@ -58,18 +58,12 @@ RSpec.describe ImportScripts::Base do describe "#create_post" do let(:importer) { described_class.new } fab!(:user) { Fabricate(:user) } - let(:post_params) { - { - user_id: user.id, - raw: "Test post [b]content[/b]", - title: "Test topic for post" - } - } + let(:post_params) do + { user_id: user.id, raw: "Test post [b]content[/b]", title: "Test topic for post" } + end it "creates a Post" do - expect { - importer.create_post(post_params, 123) - }.to change { Post.count }.by(1) + expect { importer.create_post(post_params, 123) }.to change { Post.count }.by(1) end if ENV["IMPORT"] == "1"