Merge remote-tracking branch 'parent/main' into kb_migration
This commit is contained in:
commit
f289e1ce4d
6 changed files with 174 additions and 26 deletions
|
@ -41,9 +41,9 @@ module HomeHelper
|
|||
|
||||
def obscured_counter(count)
|
||||
if count <= 0
|
||||
0
|
||||
'0'
|
||||
elsif count == 1
|
||||
1
|
||||
'1'
|
||||
else
|
||||
'1+'
|
||||
end
|
||||
|
@ -57,14 +57,6 @@ module HomeHelper
|
|||
end
|
||||
end
|
||||
|
||||
def optional_link_to(condition, path, options = {}, &block)
|
||||
if condition
|
||||
link_to(path, options, &block)
|
||||
else
|
||||
content_tag(:div, &block)
|
||||
end
|
||||
end
|
||||
|
||||
def sign_up_message
|
||||
if closed_registrations?
|
||||
t('auth.registration_closed', instance: site_hostname)
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"@babel/preset-react": "^7.18.6",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@gamestdio/websocket": "^0.3.2",
|
||||
"@github/webauthn-json": "^0.5.7",
|
||||
"@github/webauthn-json": "^2.1.1",
|
||||
"@rails/ujs": "^6.1.7",
|
||||
"abortcontroller-polyfill": "^1.7.5",
|
||||
"array-includes": "^3.1.6",
|
||||
|
@ -47,7 +47,7 @@
|
|||
"blurhash": "^2.0.5",
|
||||
"classnames": "^2.3.2",
|
||||
"cocoon-js-vanilla": "^1.3.0",
|
||||
"color-blend": "^3.0.1",
|
||||
"color-blend": "^4.0.0",
|
||||
"compression-webpack-plugin": "^6.1.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"css-loader": "^5.2.7",
|
||||
|
@ -61,7 +61,7 @@
|
|||
"express": "^4.18.2",
|
||||
"file-loader": "^6.2.0",
|
||||
"font-awesome": "^4.7.0",
|
||||
"fuzzysort": "^1.9.0",
|
||||
"fuzzysort": "^2.0.4",
|
||||
"glob": "^8.1.0",
|
||||
"history": "^4.10.1",
|
||||
"http-link-header": "^1.1.0",
|
||||
|
|
|
@ -5,5 +5,6 @@ Fabricator(:user) do
|
|||
email { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } }
|
||||
password '123456789'
|
||||
confirmed_at { Time.zone.now }
|
||||
agreement true
|
||||
current_sign_in_at { Time.zone.now }
|
||||
agreement true
|
||||
end
|
||||
|
|
|
@ -8,4 +8,116 @@ RSpec.describe HomeHelper, type: :helper do
|
|||
expect(helper.default_props).to eq locale: I18n.locale
|
||||
end
|
||||
end
|
||||
|
||||
describe 'account_link_to' do
|
||||
context 'with a missing account' do
|
||||
let(:account) { nil }
|
||||
|
||||
it 'returns a button' do
|
||||
result = helper.account_link_to(account)
|
||||
|
||||
expect(result).to match t('about.contact_missing')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a valid account' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
it 'returns a link to the account' do
|
||||
without_partial_double_verification do
|
||||
allow(helper).to receive(:current_account).and_return(account)
|
||||
allow(helper).to receive(:prefers_autoplay?).and_return(false)
|
||||
result = helper.account_link_to(account)
|
||||
|
||||
expect(result).to match "@#{account.acct}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'obscured_counter' do
|
||||
context 'with a value of less than zero' do
|
||||
let(:count) { -10 }
|
||||
|
||||
it 'returns the correct string' do
|
||||
expect(helper.obscured_counter(count)).to eq '0'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a value of zero' do
|
||||
let(:count) { 0 }
|
||||
|
||||
it 'returns the correct string' do
|
||||
expect(helper.obscured_counter(count)).to eq '0'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a value of one' do
|
||||
let(:count) { 1 }
|
||||
|
||||
it 'returns the correct string' do
|
||||
expect(helper.obscured_counter(count)).to eq '1'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a value of more than one' do
|
||||
let(:count) { 10 }
|
||||
|
||||
it 'returns the correct string' do
|
||||
expect(helper.obscured_counter(count)).to eq '1+'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'custom_field_classes' do
|
||||
context 'with a verified field' do
|
||||
let(:field) { instance_double(Account::Field, verified?: true) }
|
||||
|
||||
it 'returns verified string' do
|
||||
result = helper.custom_field_classes(field)
|
||||
expect(result).to eq 'verified'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a non-verified field' do
|
||||
let(:field) { instance_double(Account::Field, verified?: false) }
|
||||
|
||||
it 'returns verified string' do
|
||||
result = helper.custom_field_classes(field)
|
||||
expect(result).to eq 'emojify'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sign_up_messages' do
|
||||
context 'with closed registrations' do
|
||||
it 'returns correct sign up message' do
|
||||
allow(helper).to receive(:closed_registrations?).and_return(true)
|
||||
result = helper.sign_up_message
|
||||
|
||||
expect(result).to eq t('auth.registration_closed', instance: 'cb6e6126.ngrok.io')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with open registrations' do
|
||||
it 'returns correct sign up message' do
|
||||
allow(helper).to receive(:closed_registrations?).and_return(false)
|
||||
allow(helper).to receive(:open_registrations?).and_return(true)
|
||||
result = helper.sign_up_message
|
||||
|
||||
expect(result).to eq t('auth.register')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with approved registrations' do
|
||||
it 'returns correct sign up message' do
|
||||
allow(helper).to receive(:closed_registrations?).and_return(false)
|
||||
allow(helper).to receive(:open_registrations?).and_return(false)
|
||||
allow(helper).to receive(:approved_registrations?).and_return(true)
|
||||
result = helper.sign_up_message
|
||||
|
||||
expect(result).to eq t('auth.apply_for_account')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Scheduler::FollowRecommendationsScheduler do
|
||||
let!(:target_accounts) do
|
||||
Fabricate.times(3, :account) do
|
||||
statuses(count: 6)
|
||||
end
|
||||
end
|
||||
let!(:follower_accounts) do
|
||||
Fabricate.times(5, :account) do
|
||||
statuses(count: 6)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#perform' do
|
||||
subject(:scheduled_run) { described_class.new.perform }
|
||||
|
||||
context 'when there are accounts to recommend' do
|
||||
before do
|
||||
# Follow the target accounts by follow accounts to make them recommendable
|
||||
follower_accounts.each do |follower_account|
|
||||
target_accounts.each do |target_account|
|
||||
Fabricate(:follow, account: follower_account, target_account: target_account)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'creates recommendations' do
|
||||
expect { scheduled_run }.to change(FollowRecommendation, :count).from(0).to(target_accounts.size)
|
||||
expect(redis.zrange('follow_recommendations:en', 0, -1)).to match_array(target_accounts.pluck(:id).map(&:to_s))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are no accounts to recommend' do
|
||||
it 'does not create follow recommendations' do
|
||||
expect { scheduled_run }.to_not change(FollowRecommendation, :count)
|
||||
expect(redis.zrange('follow_recommendations:en', 0, -1)).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
yarn.lock
24
yarn.lock
|
@ -1245,10 +1245,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@gamestdio/websocket/-/websocket-0.3.2.tgz#321ba0976ee30fd14e51dbf8faa85ce7b325f76a"
|
||||
integrity sha512-J3n5SKim+ZoLbe44hRGI/VYAwSMCeIJuBy+FfP6EZaujEpNchPRFcIsVQLWAwpU1bP2Ji63rC+rEUOd1vjUB6Q==
|
||||
|
||||
"@github/webauthn-json@^0.5.7":
|
||||
version "0.5.7"
|
||||
resolved "https://registry.yarnpkg.com/@github/webauthn-json/-/webauthn-json-0.5.7.tgz#143bc67f6e0f75f8d188e565741507bb08c31214"
|
||||
integrity sha512-SUYsttDxFSvWvvJssJpwzjmRCqYfdfqC9VCmAHQYfdKCVelyJteCHo9/lK1CB72mx/jrl6cFNY08aua4J2jIyg==
|
||||
"@github/webauthn-json@^2.1.1":
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@github/webauthn-json/-/webauthn-json-2.1.1.tgz#648e63fc28050917d2882cc2b27817a88cb420fc"
|
||||
integrity sha512-XrftRn4z75SnaJOmZQbt7Mk+IIjqVHw+glDGOxuHwXkZBZh/MBoRS7MHjSZMDaLhT4RjN2VqiEU7EOYleuJWSQ==
|
||||
|
||||
"@humanwhocodes/config-array@^0.11.8":
|
||||
version "0.11.8"
|
||||
|
@ -3373,10 +3373,10 @@ collection-visit@^1.0.0:
|
|||
map-visit "^1.0.0"
|
||||
object-visit "^1.0.0"
|
||||
|
||||
color-blend@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/color-blend/-/color-blend-3.0.1.tgz#3882ed1190ca18760ffe11570d8537960171172b"
|
||||
integrity sha512-KueDvNiKHAvVeApic0SxHZLyy4x3NELfTLzMHRpRRLi+9e2kWhpeWvtuH3Sjb92mOJYEUhRjb8z7lr4OqDv17Q==
|
||||
color-blend@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/color-blend/-/color-blend-4.0.0.tgz#e9950e9fa5d6e552ff8bb107c39f7e83a0c1a3bb"
|
||||
integrity sha512-fYODTHhI/NG+B5GnzvuL3kiFrK/UnkUezWFTgEPBTY5V+kpyfAn95Vn9sJeeCX6omrCOdxnqCL3CvH+6sXtIbw==
|
||||
|
||||
color-convert@^1.9.0, color-convert@^1.9.1:
|
||||
version "1.9.3"
|
||||
|
@ -5263,10 +5263,10 @@ functions-have-names@^1.2.2:
|
|||
resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834"
|
||||
integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==
|
||||
|
||||
fuzzysort@^1.9.0:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/fuzzysort/-/fuzzysort-1.9.0.tgz#d36d27949eae22340bb6f7ba30ea6751b92a181c"
|
||||
integrity sha512-MOxCT0qLTwLqmEwc7UtU045RKef7mc8Qz8eR4r2bLNEq9dy/c3ZKMEFp6IEst69otkQdFZ4FfgH2dmZD+ddX1g==
|
||||
fuzzysort@^2.0.4:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/fuzzysort/-/fuzzysort-2.0.4.tgz#a21d1ce8947eaf2797dc3b7c28c36db9d1165f84"
|
||||
integrity sha512-Api1mJL+Ad7W7vnDZnWq5pGaXJjyencT+iKGia2PlHUcSsSzWwIQ3S1isiMpwpavjYtGd2FzhUIhnnhOULZgDw==
|
||||
|
||||
gauge@^5.0.0:
|
||||
version "5.0.0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue