Fixed most rubocop issues (#18048)
* Fixed most rubocop issues * Fixed accidental schema changes * Fixed Vault specs
This commit is contained in:
parent
37cddb97cd
commit
80ce8909ec
10 changed files with 27 additions and 35 deletions
|
|
@ -408,8 +408,6 @@ class Article < ApplicationRecord
|
|||
|
||||
scope :eager_load_serialized_data, -> { includes(:user, :organization, :tags) }
|
||||
|
||||
self.ignored_columns = ["spaminess_rating"]
|
||||
|
||||
def self.seo_boostable(tag = nil, time_ago = 18.days.ago)
|
||||
# Time ago sometimes returns this phrase instead of a date
|
||||
time_ago = 5.days.ago if time_ago == "latest"
|
||||
|
|
|
|||
|
|
@ -91,26 +91,26 @@ module Articles
|
|||
"^ (1.0 / greatest(articles.score, 0.1)) DESC")
|
||||
|
||||
order_by_lever(:published_at_with_randomization_favoring_public_reactions,
|
||||
label: "Favor recent articles with more reactions, "\
|
||||
label: "Favor recent articles with more reactions, " \
|
||||
"but apply randomness to mitigate stagnation.",
|
||||
order_by_fragment: "(cast(extract(epoch FROM published_at) as integer)) * "\
|
||||
"(article_relevancies.randomized_value ^ (1.0 /" \
|
||||
" greatest(0.1, ln(1 + greatest(0, public_reactions_count))))) DESC")
|
||||
order_by_fragment: "(cast(extract(epoch FROM published_at) as integer)) * " \
|
||||
"(article_relevancies.randomized_value ^ (1.0 / " \
|
||||
"greatest(0.1, ln(1 + greatest(0, public_reactions_count))))) DESC")
|
||||
|
||||
order_by_lever(:last_comment_at_with_randomization_favoring_public_reactions,
|
||||
label: "Favor articles with recent comments and more reactions, " \
|
||||
" but apply randomness to mitigate stagnation.",
|
||||
order_by_fragment: "(cast(extract(epoch FROM last_comment_at) as integer)) * "\
|
||||
"but apply randomness to mitigate stagnation.",
|
||||
order_by_fragment: "(cast(extract(epoch FROM last_comment_at) as integer)) * " \
|
||||
"(article_relevancies.randomized_value ^ (1.0 / " \
|
||||
"greatest(0.1, ln(1 + greatest(0, public_reactions_count))))) DESC")
|
||||
|
||||
order_by_lever(:random_pick_of_which_date_to_use_with_randomization_favoring_public_reactions,
|
||||
label: "Favor articles with recent comments or published at and more reactions, " \
|
||||
"but apply randomness to mitigate stagnation.",
|
||||
order_by_fragment: "(cast(extract(epoch FROM "\
|
||||
order_by_fragment: "(cast(extract(epoch FROM " \
|
||||
"(CASE WHEN RANDOM() > 0.5 THEN published_at ELSE last_comment_at END)) " \
|
||||
"as integer)) * "\
|
||||
"(article_relevancies.randomized_value ^ (1.0 / "\
|
||||
"as integer)) * " \
|
||||
"(article_relevancies.randomized_value ^ (1.0 / " \
|
||||
"greatest(0.1, ln(1 + greatest(0, public_reactions_count))))) DESC")
|
||||
|
||||
relevancy_lever(:comments_count_by_those_followed,
|
||||
|
|
|
|||
|
|
@ -120,10 +120,10 @@ module Articles
|
|||
join_fragment = Arel.sql(
|
||||
"INNER JOIN (" \
|
||||
"\n--- The setseed needs to be called independently; later we reference seeder \n" \
|
||||
"WITH seeder AS (SELECT setseed(#{Float(@seed)})) "\
|
||||
"WITH seeder AS (SELECT setseed(#{Float(@seed)})) " \
|
||||
"\n--- We are using the inner logic to build relevancy score" \
|
||||
"\n--- The outer part, with seeder, is to create a stable randomized number \n" \
|
||||
"SELECT inner_article_relevancies.id, "\
|
||||
"SELECT inner_article_relevancies.id, " \
|
||||
"inner_article_relevancies.relevancy_score, " \
|
||||
"RANDOM() AS randomized_value " \
|
||||
"FROM seeder, " \
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ module DataUpdateScripts
|
|||
Rails.logger.error("Could not convert logo_svg for #{Settings::Community.community_name} Forem to a PNG.")
|
||||
|
||||
Honeybadger.notify(e, context: {
|
||||
community_name: Settings::Community.community_name,
|
||||
app_domain: Settings::General.app_domain
|
||||
},
|
||||
community_name: Settings::Community.community_name,
|
||||
app_domain: Settings::General.app_domain
|
||||
},
|
||||
tags: "failed_svg_conversion")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ require "rails_helper"
|
|||
RSpec.describe AppSecrets, type: :lib do
|
||||
let(:namespace) { "secret-namespace" }
|
||||
let(:key) { "SECRET_KEY" }
|
||||
let(:secret_stub) { instance_double("Vault::Kv", data: { value: 1 }) }
|
||||
let(:vault_stub) { instance_double("Vault::Kv", read: secret_stub) }
|
||||
let(:secret_stub) { instance_double(Vault::Secret, data: { value: 1 }) }
|
||||
let(:vault_stub) { instance_double(Vault::KV, read: secret_stub) }
|
||||
|
||||
before do
|
||||
allow(described_class).to receive(:namespace).and_return(namespace)
|
||||
|
|
@ -25,7 +25,7 @@ RSpec.describe AppSecrets, type: :lib do
|
|||
end
|
||||
|
||||
it "fetches keys from ApplicationConfig if not in Vault" do
|
||||
allow(Vault).to receive(:kv) { instance_double("Vault::Kv", read: nil) }
|
||||
allow(Vault).to receive(:kv) { instance_double(Vault::KV, read: nil) }
|
||||
|
||||
described_class[key]
|
||||
expect(ApplicationConfig).to have_received(:[]).with(key)
|
||||
|
|
@ -43,7 +43,7 @@ RSpec.describe AppSecrets, type: :lib do
|
|||
before { allow(described_class).to receive(:vault_enabled?).and_return(false) }
|
||||
|
||||
it "fetches keys from ApplicationConfig" do
|
||||
allow(Vault).to receive(:kv) { instance_double("Vault::Kv", read: nil) }
|
||||
allow(Vault).to receive(:kv) { instance_double(Vault::KV, read: nil) }
|
||||
|
||||
described_class[key]
|
||||
expect(ApplicationConfig).to have_received(:[]).with(key)
|
||||
|
|
@ -54,7 +54,7 @@ RSpec.describe AppSecrets, type: :lib do
|
|||
|
||||
describe "[]=" do
|
||||
it "sets keys in Vault" do
|
||||
write_stub = instance_double("Vault::Kv", write: nil)
|
||||
write_stub = instance_double(Vault::KV, write: nil)
|
||||
allow(Vault).to receive(:kv) { write_stub }
|
||||
|
||||
described_class[key] = "secret-value"
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ RSpec.describe DeviseMailer, type: :mailer do
|
|||
let(:email) { described_class.confirmation_instructions(creator, "faketoken") }
|
||||
|
||||
it "renders the correct body" do
|
||||
expect(email.body.to_s).to include("Hello! Once you've confirmed your email address, you'll be able to setup "\
|
||||
expect(email.body.to_s).to include("Hello! Once you've confirmed your email address, you'll be able to setup " \
|
||||
"your Forem Instance.")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,6 @@ RSpec.describe Article, type: :model do
|
|||
include_examples "#sync_reactions_count", :article
|
||||
it_behaves_like "UserSubscriptionSourceable"
|
||||
|
||||
describe "ignored columns" do
|
||||
it "ignores spaminess rating" do
|
||||
expect(described_class.ignored_columns).to eq ["spaminess_rating"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "validations" do
|
||||
it { is_expected.to belong_to(:collection).optional }
|
||||
it { is_expected.to belong_to(:organization).optional }
|
||||
|
|
|
|||
|
|
@ -538,9 +538,9 @@ end
|
|||
##############################################################################
|
||||
|
||||
seeder.create_if_doesnt_exist(NavigationLink, "url", "/contact") do
|
||||
icon = '<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">'\
|
||||
'<path d="M12 1l9.5 5.5v11L12 23l-9.5-5.5v-11L12 1zm0 2.311L4.5 7.653v8.694l7.5 4.342'\
|
||||
'7.5-4.342V7.653L12 3.311zM12 16a4 4 0 110-8 4 4 0 010 8zm0-2a2 2 0 100-4 2 2 0 000 4z"/>'\
|
||||
icon = '<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' \
|
||||
'<path d="M12 1l9.5 5.5v11L12 23l-9.5-5.5v-11L12 1zm0 2.311L4.5 7.653v8.694l7.5 4.342' \
|
||||
'7.5-4.342V7.653L12 3.311zM12 16a4 4 0 110-8 4 4 0 010 8zm0-2a2 2 0 100-4 2 2 0 000 4z"/>' \
|
||||
'</svg>'
|
||||
6.times do |i|
|
||||
NavigationLink.create!(
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ RSpec.describe "Admin invites user", type: :system do
|
|||
end
|
||||
|
||||
it "shows a banner" do
|
||||
message = "SMTP settings are required so that your Forem can send emails. If you wish to send invites, "\
|
||||
"email digests and activity notifications you will need to specify which email host will relay those "\
|
||||
message = "SMTP settings are required so that your Forem can send emails. If you wish to send invites, " \
|
||||
"email digests and activity notifications you will need to specify which email host will relay those " \
|
||||
"messages for you."
|
||||
expect(page).to have_content(message)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ RSpec.describe "Conditional registration (ForemWebView)", type: :system do
|
|||
"Mozilla/5.0 (iPhone) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 ForemWebView/1.0"
|
||||
end
|
||||
let(:flow_b_fallback_text) do
|
||||
"Unfortunately, we do not support creating new accounts right now on our "\
|
||||
"mobile app. If you want create a new account to join "\
|
||||
"Unfortunately, we do not support creating new accounts right now on our " \
|
||||
"mobile app. If you want create a new account to join " \
|
||||
"#{Settings::Community.community_name}, please do that on the web at"
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue