Merge remote-tracking branch 'parent/main' into kb_migration
This commit is contained in:
commit
558c3c116c
40 changed files with 690 additions and 92 deletions
|
@ -41,7 +41,7 @@ services:
|
|||
- internal_network
|
||||
|
||||
redis:
|
||||
image: redis:6-alpine
|
||||
image: redis:7-alpine
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
|
|
|
@ -25,7 +25,7 @@ jobs:
|
|||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:14.5
|
||||
image: postgres:14-alpine
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_USER: postgres
|
||||
|
@ -38,7 +38,7 @@ jobs:
|
|||
- 5432:5432
|
||||
|
||||
redis:
|
||||
image: redis:7.0
|
||||
image: redis:7-alpine
|
||||
options: >-
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 10s
|
||||
|
|
|
@ -25,7 +25,7 @@ jobs:
|
|||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:14.5
|
||||
image: postgres:14-alpine
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_USER: postgres
|
||||
|
@ -37,7 +37,7 @@ jobs:
|
|||
ports:
|
||||
- 5432:5432
|
||||
redis:
|
||||
image: redis:7.0
|
||||
image: redis:7-alpine
|
||||
options: >-
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 10s
|
||||
|
|
4
.github/workflows/test-ruby.yml
vendored
4
.github/workflows/test-ruby.yml
vendored
|
@ -63,7 +63,7 @@ jobs:
|
|||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:14.5
|
||||
image: postgres:14-alpine
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_USER: postgres
|
||||
|
@ -76,7 +76,7 @@ jobs:
|
|||
- 5432:5432
|
||||
|
||||
redis:
|
||||
image: redis:7.0
|
||||
image: redis:7-alpine
|
||||
options: >-
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 10s
|
||||
|
|
17
.rubocop.yml
17
.rubocop.yml
|
@ -96,9 +96,26 @@ Rails/Exit:
|
|||
- 'lib/mastodon/cli_helper.rb'
|
||||
- 'lib/cli.rb'
|
||||
|
||||
# Reason: Some single letter camel case files shouldn't be split
|
||||
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfilepath
|
||||
RSpec/FilePath:
|
||||
CustomTransform:
|
||||
ActivityPub: activitypub # Ignore the snake_case due to the amount of files to rename
|
||||
DeepL: deepl
|
||||
FetchOEmbedService: fetch_oembed_service
|
||||
JsonLdHelper: jsonld_helper
|
||||
OEmbedController: oembed_controller
|
||||
OStatus: ostatus
|
||||
NodeInfoController: nodeinfo_controller # NodeInfo isn't snake_cased for any of the instances
|
||||
Exclude:
|
||||
- 'spec/config/initializers/rack_attack_spec.rb' # namespaces usually have separate folder
|
||||
- 'spec/lib/sanitize_config_spec.rb' # namespaces usually have separate folder
|
||||
- 'spec/controllers/concerns/account_controller_concern_spec.rb' # Concerns describe ApplicationController and don't fit naming
|
||||
- 'spec/controllers/concerns/export_controller_concern_spec.rb'
|
||||
- 'spec/controllers/concerns/localized_spec.rb'
|
||||
- 'spec/controllers/concerns/rate_limit_headers_spec.rb'
|
||||
- 'spec/controllers/concerns/signature_verification_spec.rb'
|
||||
- 'spec/controllers/concerns/user_tracking_concern_spec.rb'
|
||||
|
||||
RSpec/NotToNot:
|
||||
EnforcedStyle: to_not
|
||||
|
|
|
@ -655,73 +655,6 @@ RSpec/ExpectInHook:
|
|||
- 'spec/controllers/settings/applications_controller_spec.rb'
|
||||
- 'spec/lib/status_filter_spec.rb'
|
||||
|
||||
# Offense count: 61
|
||||
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
||||
# Include: **/*_spec*rb*, **/spec/**/*
|
||||
RSpec/FilePath:
|
||||
Exclude:
|
||||
- 'spec/config/initializers/rack_attack_spec.rb'
|
||||
- 'spec/controllers/activitypub/collections_controller_spec.rb'
|
||||
- 'spec/controllers/activitypub/followers_synchronizations_controller_spec.rb'
|
||||
- 'spec/controllers/activitypub/inboxes_controller_spec.rb'
|
||||
- 'spec/controllers/activitypub/outboxes_controller_spec.rb'
|
||||
- 'spec/controllers/activitypub/replies_controller_spec.rb'
|
||||
- 'spec/controllers/admin/change_email_controller_spec.rb'
|
||||
- 'spec/controllers/admin/users/roles_controller.rb'
|
||||
- 'spec/controllers/api/oembed_controller_spec.rb'
|
||||
- 'spec/controllers/concerns/account_controller_concern_spec.rb'
|
||||
- 'spec/controllers/concerns/export_controller_concern_spec.rb'
|
||||
- 'spec/controllers/concerns/localized_spec.rb'
|
||||
- 'spec/controllers/concerns/rate_limit_headers_spec.rb'
|
||||
- 'spec/controllers/concerns/signature_verification_spec.rb'
|
||||
- 'spec/controllers/concerns/user_tracking_concern_spec.rb'
|
||||
- 'spec/controllers/well_known/nodeinfo_controller_spec.rb'
|
||||
- 'spec/helpers/admin/action_log_helper_spec.rb'
|
||||
- 'spec/helpers/jsonld_helper_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/accept_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/add_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/announce_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/block_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/create_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/delete_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/flag_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/follow_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/like_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/move_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/reject_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/remove_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/undo_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/update_spec.rb'
|
||||
- 'spec/lib/activitypub/adapter_spec.rb'
|
||||
- 'spec/lib/activitypub/dereferencer_spec.rb'
|
||||
- 'spec/lib/activitypub/linked_data_signature_spec.rb'
|
||||
- 'spec/lib/activitypub/tag_manager_spec.rb'
|
||||
- 'spec/lib/ostatus/tag_manager_spec.rb'
|
||||
- 'spec/lib/sanitize_config_spec.rb'
|
||||
- 'spec/serializers/activitypub/note_serializer_spec.rb'
|
||||
- 'spec/serializers/activitypub/update_poll_serializer_spec.rb'
|
||||
- 'spec/services/activitypub/fetch_featured_collection_service_spec.rb'
|
||||
- 'spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb'
|
||||
- 'spec/services/activitypub/fetch_remote_account_service_spec.rb'
|
||||
- 'spec/services/activitypub/fetch_remote_actor_service_spec.rb'
|
||||
- 'spec/services/activitypub/fetch_remote_key_service_spec.rb'
|
||||
- 'spec/services/activitypub/fetch_remote_status_service_spec.rb'
|
||||
- 'spec/services/activitypub/fetch_replies_service_spec.rb'
|
||||
- 'spec/services/activitypub/process_account_service_spec.rb'
|
||||
- 'spec/services/activitypub/process_collection_service_spec.rb'
|
||||
- 'spec/services/activitypub/process_status_update_service_spec.rb'
|
||||
- 'spec/services/activitypub/synchronize_followers_service_spec.rb'
|
||||
- 'spec/services/fetch_oembed_service_spec.rb'
|
||||
- 'spec/services/remove_from_follwers_service_spec.rb'
|
||||
- 'spec/workers/activitypub/delivery_worker_spec.rb'
|
||||
- 'spec/workers/activitypub/distribute_poll_update_worker_spec.rb'
|
||||
- 'spec/workers/activitypub/distribution_worker_spec.rb'
|
||||
- 'spec/workers/activitypub/fetch_replies_worker_spec.rb'
|
||||
- 'spec/workers/activitypub/move_distribution_worker_spec.rb'
|
||||
- 'spec/workers/activitypub/processing_worker_spec.rb'
|
||||
- 'spec/workers/activitypub/status_update_distribution_worker_spec.rb'
|
||||
- 'spec/workers/activitypub/update_distribution_worker_spec.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
|
|
|
@ -483,7 +483,7 @@ GEM
|
|||
pastel (0.8.0)
|
||||
tty-color (~> 0.5)
|
||||
pg (1.4.6)
|
||||
pghero (3.1.0)
|
||||
pghero (3.2.0)
|
||||
activerecord (>= 6)
|
||||
pkg-config (1.5.1)
|
||||
posix-spawn (0.3.15)
|
||||
|
@ -497,7 +497,7 @@ GEM
|
|||
premailer (~> 1.7, >= 1.7.9)
|
||||
private_address_check (0.5.0)
|
||||
public_suffix (5.0.1)
|
||||
puma (6.1.0)
|
||||
puma (6.1.1)
|
||||
nio4r (~> 2.0)
|
||||
pundit (2.3.0)
|
||||
activesupport (>= 3.0.0)
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@testing-library/react": "^12.1.5",
|
||||
"babel-jest": "^29.5.0",
|
||||
"eslint": "^8.33.0",
|
||||
"eslint": "^8.35.0",
|
||||
"eslint-plugin-import": "~2.27.5",
|
||||
"eslint-plugin-jsx-a11y": "~6.7.1",
|
||||
"eslint-plugin-promise": "~6.1.1",
|
||||
|
|
31
spec/chewy/accounts_index_spec.rb
Normal file
31
spec/chewy/accounts_index_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountsIndex do
|
||||
describe 'Searching the index' do
|
||||
before do
|
||||
mock_elasticsearch_response(described_class, raw_response)
|
||||
end
|
||||
|
||||
it 'returns results from a query' do
|
||||
results = described_class.query(match: { name: 'account' })
|
||||
|
||||
expect(results).to eq []
|
||||
end
|
||||
end
|
||||
|
||||
def raw_response
|
||||
{
|
||||
took: 3,
|
||||
hits: {
|
||||
hits: [
|
||||
{
|
||||
_id: '0',
|
||||
_score: 1.6375021,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
31
spec/chewy/statuses_index_spec.rb
Normal file
31
spec/chewy/statuses_index_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe StatusesIndex do
|
||||
describe 'Searching the index' do
|
||||
before do
|
||||
mock_elasticsearch_response(described_class, raw_response)
|
||||
end
|
||||
|
||||
it 'returns results from a query' do
|
||||
results = described_class.query(match: { name: 'status' })
|
||||
|
||||
expect(results).to eq []
|
||||
end
|
||||
end
|
||||
|
||||
def raw_response
|
||||
{
|
||||
took: 3,
|
||||
hits: {
|
||||
hits: [
|
||||
{
|
||||
_id: '0',
|
||||
_score: 1.6375021,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
31
spec/chewy/tags_index_spec.rb
Normal file
31
spec/chewy/tags_index_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe TagsIndex do
|
||||
describe 'Searching the index' do
|
||||
before do
|
||||
mock_elasticsearch_response(described_class, raw_response)
|
||||
end
|
||||
|
||||
it 'returns results from a query' do
|
||||
results = described_class.query(match: { name: 'tag' })
|
||||
|
||||
expect(results).to eq []
|
||||
end
|
||||
end
|
||||
|
||||
def raw_response
|
||||
{
|
||||
took: 3,
|
||||
hits: {
|
||||
hits: [
|
||||
{
|
||||
_id: '0',
|
||||
_score: 1.6375021,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
19
spec/controllers/activitypub/claims_controller_spec.rb
Normal file
19
spec/controllers/activitypub/claims_controller_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ActivityPub::ClaimsController do
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'without signature' do
|
||||
before do
|
||||
post :create, params: { account_username: account.username }, body: '{}'
|
||||
end
|
||||
|
||||
it 'returns http not authorized' do
|
||||
expect(response).to have_http_status(401)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
spec/controllers/api/v2/instances_controller_spec.rb
Normal file
22
spec/controllers/api/v2/instances_controller_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::V2::InstancesController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
22
spec/controllers/api/v2/suggestions_controller_spec.rb
Normal file
22
spec/controllers/api/v2/suggestions_controller_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::V2::SuggestionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read') }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
25
spec/controllers/auth/setup_controller_spec.rb
Normal file
25
spec/controllers/auth/setup_controller_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Auth::SetupController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
context 'with a signed out request' do
|
||||
it 'returns http redirect' do
|
||||
get :show
|
||||
expect(response).to be_redirect
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an unconfirmed signed in user' do
|
||||
before { sign_in Fabricate(:user, confirmed_at: nil) }
|
||||
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
14
spec/controllers/custom_css_controller_spec.rb
Normal file
14
spec/controllers/custom_css_controller_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe CustomCssController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
41
spec/controllers/filters/statuses_controller_spec.rb
Normal file
41
spec/controllers/filters/statuses_controller_spec.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Filters::StatusesController do
|
||||
render_views
|
||||
|
||||
describe 'GET #index' do
|
||||
let(:filter) { Fabricate(:custom_filter) }
|
||||
|
||||
context 'with signed out user' do
|
||||
it 'redirects' do
|
||||
get :index, params: { filter_id: filter }
|
||||
|
||||
expect(response).to be_redirect
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a signed in user' do
|
||||
context 'with the filter user signed in' do
|
||||
before { sign_in(filter.account.user) }
|
||||
|
||||
it 'returns http success' do
|
||||
get :index, params: { filter_id: filter }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with another user signed in' do
|
||||
before { sign_in(Fabricate(:user)) }
|
||||
|
||||
it 'returns http not found' do
|
||||
get :index, params: { filter_id: filter }
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
27
spec/controllers/filters_controller_spec.rb
Normal file
27
spec/controllers/filters_controller_spec.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe FiltersController do
|
||||
render_views
|
||||
|
||||
describe 'GET #index' do
|
||||
context 'with signed out user' do
|
||||
it 'redirects' do
|
||||
get :index
|
||||
|
||||
expect(response).to be_redirect
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a signed in user' do
|
||||
before { sign_in(Fabricate(:user)) }
|
||||
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
14
spec/controllers/health_controller_spec.rb
Normal file
14
spec/controllers/health_controller_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe HealthController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
14
spec/controllers/privacy_controller_spec.rb
Normal file
14
spec/controllers/privacy_controller_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe PrivacyController do
|
||||
render_views
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
7
spec/fabricators/encrypted_message_fabricator.rb
Normal file
7
spec/fabricators/encrypted_message_fabricator.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:encrypted_message) do
|
||||
device
|
||||
from_account { Fabricate(:account) }
|
||||
from_device_id { Faker::Number.number(digits: 5) }
|
||||
end
|
|
@ -2,7 +2,33 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe StatusesHelper, type: :helper do
|
||||
describe StatusesHelper do
|
||||
describe 'status_text_summary' do
|
||||
context 'with blank text' do
|
||||
let(:status) { Status.new(spoiler_text: '') }
|
||||
|
||||
it 'returns immediately with nil' do
|
||||
result = helper.status_text_summary(status)
|
||||
expect(result).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with present text' do
|
||||
let(:status) { Status.new(spoiler_text: 'SPOILERS!!!') }
|
||||
|
||||
it 'returns the content warning' do
|
||||
result = helper.status_text_summary(status)
|
||||
expect(result).to eq(I18n.t('statuses.content_warning', warning: 'SPOILERS!!!'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def status_text_summary(status)
|
||||
return if status.spoiler_text.blank?
|
||||
|
||||
I18n.t('statuses.content_warning', warning: status.spoiler_text)
|
||||
end
|
||||
|
||||
describe 'link_to_newer' do
|
||||
it 'returns a link to newer content' do
|
||||
url = 'https://example.com'
|
||||
|
|
14
spec/lib/importer/base_importer_spec.rb
Normal file
14
spec/lib/importer/base_importer_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Importer::BaseImporter do
|
||||
describe 'import!' do
|
||||
let(:pool) { Concurrent::FixedThreadPool.new(5) }
|
||||
let(:importer) { described_class.new(batch_size: 123, executor: pool) }
|
||||
|
||||
it 'raises an error' do
|
||||
expect { importer.import! }.to raise_error(NotImplementedError)
|
||||
end
|
||||
end
|
||||
end
|
18
spec/lib/search_query_transformer_spec.rb
Normal file
18
spec/lib/search_query_transformer_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe SearchQueryTransformer do
|
||||
describe 'initialization' do
|
||||
let(:parser) { SearchQueryParser.new.parse('query') }
|
||||
|
||||
it 'sets attributes' do
|
||||
transformer = described_class.new.apply(parser)
|
||||
|
||||
expect(transformer.should_clauses.first).to be_a(SearchQueryTransformer::TermClause)
|
||||
expect(transformer.must_clauses.first).to be_nil
|
||||
expect(transformer.must_not_clauses.first).to be_nil
|
||||
expect(transformer.filter_clauses.first).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
16
spec/models/admin/appeal_filter_spec.rb
Normal file
16
spec/models/admin/appeal_filter_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::AppealFilter do
|
||||
describe '#results' do
|
||||
let(:approved_appeal) { Fabricate(:appeal, approved_at: 10.days.ago) }
|
||||
let(:not_approved_appeal) { Fabricate(:appeal, approved_at: nil) }
|
||||
|
||||
it 'returns filtered appeals' do
|
||||
filter = described_class.new(status: 'approved')
|
||||
|
||||
expect(filter.results).to eq([approved_appeal])
|
||||
end
|
||||
end
|
||||
end
|
36
spec/models/form/admin_settings_spec.rb
Normal file
36
spec/models/form/admin_settings_spec.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Form::AdminSettings do
|
||||
describe 'validations' do
|
||||
describe 'site_contact_username' do
|
||||
context 'with no accounts' do
|
||||
it 'is not valid' do
|
||||
setting = described_class.new(site_contact_username: 'Test')
|
||||
setting.valid?
|
||||
|
||||
expect(setting).to model_have_error_on_field(:site_contact_username)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an account' do
|
||||
before { Fabricate(:account, username: 'Glorp') }
|
||||
|
||||
it 'is not valid when account doesnt match' do
|
||||
setting = described_class.new(site_contact_username: 'Test')
|
||||
setting.valid?
|
||||
|
||||
expect(setting).to model_have_error_on_field(:site_contact_username)
|
||||
end
|
||||
|
||||
it 'is valid when account matches' do
|
||||
setting = described_class.new(site_contact_username: 'Glorp')
|
||||
setting.valid?
|
||||
|
||||
expect(setting).to_not model_have_error_on_field(:site_contact_username)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
spec/models/form/status_filter_batch_action_spec.rb
Normal file
13
spec/models/form/status_filter_batch_action_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Form::StatusFilterBatchAction do
|
||||
describe '#save!' do
|
||||
it 'does nothing if status_filter_ids is empty' do
|
||||
batch_action = described_class.new(status_filter_ids: [])
|
||||
|
||||
expect(batch_action.save!).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,6 +10,7 @@ require 'rspec/rails'
|
|||
require 'webmock/rspec'
|
||||
require 'paperclip/matchers'
|
||||
require 'capybara/rspec'
|
||||
require 'chewy/rspec'
|
||||
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
|
||||
|
@ -45,6 +46,7 @@ RSpec.configure do |config|
|
|||
config.include Devise::Test::ControllerHelpers, type: :view
|
||||
config.include Paperclip::Shoulda::Matchers
|
||||
config.include ActiveSupport::Testing::TimeHelpers
|
||||
config.include Chewy::Rspec::Helpers
|
||||
config.include Redisable
|
||||
|
||||
config.before :each, type: :feature do
|
||||
|
|
20
spec/serializers/activitypub/device_serializer_spec.rb
Normal file
20
spec/serializers/activitypub/device_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ActivityPub::DeviceSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { Fabricate(:device) }
|
||||
|
||||
describe 'type' do
|
||||
it 'returns correct serialized type' do
|
||||
expect(serialization['type']).to eq('Device')
|
||||
end
|
||||
end
|
||||
end
|
20
spec/serializers/activitypub/one_time_key_serializer_spec.rb
Normal file
20
spec/serializers/activitypub/one_time_key_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ActivityPub::OneTimeKeySerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { Fabricate(:one_time_key) }
|
||||
|
||||
describe 'type' do
|
||||
it 'returns correct serialized type' do
|
||||
expect(serialization['type']).to eq('Curve25519Key')
|
||||
end
|
||||
end
|
||||
end
|
20
spec/serializers/activitypub/undo_like_serializer_spec.rb
Normal file
20
spec/serializers/activitypub/undo_like_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ActivityPub::UndoLikeSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { Fabricate(:favourite) }
|
||||
|
||||
describe 'type' do
|
||||
it 'returns correct serialized type' do
|
||||
expect(serialization['type']).to eq('Undo')
|
||||
end
|
||||
end
|
||||
end
|
20
spec/serializers/activitypub/vote_serializer_spec.rb
Normal file
20
spec/serializers/activitypub/vote_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ActivityPub::VoteSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { Fabricate(:poll_vote) }
|
||||
|
||||
describe 'type' do
|
||||
it 'returns correct serialized type' do
|
||||
expect(serialization['type']).to eq('Create')
|
||||
end
|
||||
end
|
||||
end
|
20
spec/serializers/rest/encrypted_message_serializer_spec.rb
Normal file
20
spec/serializers/rest/encrypted_message_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe REST::EncryptedMessageSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { Fabricate(:encrypted_message) }
|
||||
|
||||
describe 'account' do
|
||||
it 'returns the associated account' do
|
||||
expect(serialization['account_id']).to eq(record.from_account.id.to_s)
|
||||
end
|
||||
end
|
||||
end
|
20
spec/serializers/rest/instance_serializer_spec.rb
Normal file
20
spec/serializers/rest/instance_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe REST::InstanceSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { InstancePresenter.new }
|
||||
|
||||
describe 'usage' do
|
||||
it 'returns recent usage data' do
|
||||
expect(serialization['usage']).to eq({ 'users' => { 'active_month' => 0 } })
|
||||
end
|
||||
end
|
||||
end
|
20
spec/serializers/rest/keys/claim_result_serializer_spec.rb
Normal file
20
spec/serializers/rest/keys/claim_result_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe REST::Keys::ClaimResultSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { Keys::ClaimService::Result.new(Account.new(id: 123), 456) }
|
||||
|
||||
describe 'account' do
|
||||
it 'returns the associated account' do
|
||||
expect(serialization['account_id']).to eq('123')
|
||||
end
|
||||
end
|
||||
end
|
20
spec/serializers/rest/keys/device_serializer_spec.rb
Normal file
20
spec/serializers/rest/keys/device_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe REST::Keys::DeviceSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { Device.new(name: 'Device name') }
|
||||
|
||||
describe 'name' do
|
||||
it 'returns the name' do
|
||||
expect(serialization['name']).to eq('Device name')
|
||||
end
|
||||
end
|
||||
end
|
20
spec/serializers/rest/keys/query_result_serializer_spec.rb
Normal file
20
spec/serializers/rest/keys/query_result_serializer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe REST::Keys::QueryResultSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { Keys::QueryService::Result.new(Account.new(id: 123), []) }
|
||||
|
||||
describe 'account' do
|
||||
it 'returns the associated account id' do
|
||||
expect(serialization['account_id']).to eq('123')
|
||||
end
|
||||
end
|
||||
end
|
26
spec/serializers/rest/suggestion_serializer_spec.rb
Normal file
26
spec/serializers/rest/suggestion_serializer_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe REST::SuggestionSerializer do
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, serializer: described_class
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) do
|
||||
AccountSuggestions::Suggestion.new(
|
||||
account: account,
|
||||
source: 'SuggestionSource'
|
||||
)
|
||||
end
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'account' do
|
||||
it 'returns the associated account' do
|
||||
expect(serialization['account']['id']).to eq(account.id.to_s)
|
||||
end
|
||||
end
|
||||
end
|
13
spec/workers/verify_account_links_worker_spec.rb
Normal file
13
spec/workers/verify_account_links_worker_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe VerifyAccountLinksWorker do
|
||||
let(:worker) { described_class.new }
|
||||
|
||||
describe 'perform' do
|
||||
it 'runs without error for missing record' do
|
||||
expect { worker.perform(nil) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
34
yarn.lock
34
yarn.lock
|
@ -1201,10 +1201,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz#8eed982e2ee6f7f4e44c253e12962980791efd46"
|
||||
integrity sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==
|
||||
|
||||
"@eslint/eslintrc@^1.4.1":
|
||||
version "1.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.1.tgz#af58772019a2d271b7e2d4c23ff4ddcba3ccfb3e"
|
||||
integrity sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==
|
||||
"@eslint/eslintrc@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.0.tgz#943309d8697c52fc82c076e90c1c74fbbe69dbff"
|
||||
integrity sha512-fluIaaV+GyV24CCu/ggiHdV+j4RNh85yQnAYS/G2mZODZgGmmlrgCydjUcV3YvxCm9x8nMAfThsqTni4KiXT4A==
|
||||
dependencies:
|
||||
ajv "^6.12.4"
|
||||
debug "^4.3.2"
|
||||
|
@ -1216,6 +1216,11 @@
|
|||
minimatch "^3.1.2"
|
||||
strip-json-comments "^3.1.1"
|
||||
|
||||
"@eslint/js@8.35.0":
|
||||
version "8.35.0"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.35.0.tgz#b7569632b0b788a0ca0e438235154e45d42813a7"
|
||||
integrity sha512-JXdzbRiWclLVoD8sNUjR443VVlYqiYmDVT6rGUEIEHU5YJW0gaVZwV2xgM7D4arkvASqD0IlLUVjHiFuxaftRw==
|
||||
|
||||
"@floating-ui/core@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.0.1.tgz#00e64d74e911602c8533957af0cce5af6b2e93c8"
|
||||
|
@ -4667,12 +4672,13 @@ eslint-visitor-keys@^3.3.0:
|
|||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826"
|
||||
integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==
|
||||
|
||||
eslint@^8.33.0:
|
||||
version "8.33.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.33.0.tgz#02f110f32998cb598c6461f24f4d306e41ca33d7"
|
||||
integrity sha512-WjOpFQgKK8VrCnAtl8We0SUOy/oVZ5NHykyMiagV1M9r8IFpIJX7DduK6n1mpfhlG7T1NLWm2SuD8QB7KFySaA==
|
||||
eslint@^8.35.0:
|
||||
version "8.35.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.35.0.tgz#fffad7c7e326bae606f0e8f436a6158566d42323"
|
||||
integrity sha512-BxAf1fVL7w+JLRQhWl2pzGeSiGqbWumV4WNvc9Rhp6tiCtm4oHnyPBSEtMGZwrQgudFQ+otqzWoPB7x+hxoWsw==
|
||||
dependencies:
|
||||
"@eslint/eslintrc" "^1.4.1"
|
||||
"@eslint/eslintrc" "^2.0.0"
|
||||
"@eslint/js" "8.35.0"
|
||||
"@humanwhocodes/config-array" "^0.11.8"
|
||||
"@humanwhocodes/module-importer" "^1.0.1"
|
||||
"@nodelib/fs.walk" "^1.2.8"
|
||||
|
@ -4686,7 +4692,7 @@ eslint@^8.33.0:
|
|||
eslint-utils "^3.0.0"
|
||||
eslint-visitor-keys "^3.3.0"
|
||||
espree "^9.4.0"
|
||||
esquery "^1.4.0"
|
||||
esquery "^1.4.2"
|
||||
esutils "^2.0.2"
|
||||
fast-deep-equal "^3.1.3"
|
||||
file-entry-cache "^6.0.1"
|
||||
|
@ -4726,10 +4732,10 @@ esprima@^4.0.0, esprima@^4.0.1:
|
|||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
|
||||
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
|
||||
|
||||
esquery@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5"
|
||||
integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==
|
||||
esquery@^1.4.2:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b"
|
||||
integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==
|
||||
dependencies:
|
||||
estraverse "^5.1.0"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue