Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `README.md`:
  Upstream README has been changed, but we have a completely different one.
  Kept our `README.md`.
- `lib/sanitize_ext/sanitize_config.rb`:
  Upstream added support for more incoming HTML tags (a large subset of what
  glitch-soc accepts).
  Change the code style to match upstream's but otherwise do not change our
  code.
- `spec/lib/sanitize_config_spec.rb`:
  Upstream added support for more incoming HTML tags (a large subset of what
  glitch-soc accepts).
  Kept our version, since the tests are mostly glitch-soc's, except for cases
  which are purposefuly different.
This commit is contained in:
Claire
2023-03-05 20:43:48 +01:00
216 changed files with 3107 additions and 557 deletions

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::AccountActionsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #new' do
let(:account) { Fabricate(:account) }
it 'returns http success' do
get :new, params: { account_id: account.id }
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::AnnouncementsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::FollowRecommendationsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::IpBlocksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::RelationshipsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
let(:account) { Fabricate(:account) }
it 'returns http success' do
get :index, params: { account_id: account.id }
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::RelaysController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -57,6 +57,9 @@ describe Admin::Reports::ActionsController do
let!(:media) { Fabricate(:media_attachment, account: target_account, status: statuses[0]) }
let(:report) { Fabricate(:report, target_account: target_account, status_ids: statuses.map(&:id)) }
let(:text) { 'hello' }
let(:common_params) do
{ report_id: report.id, text: text }
end
shared_examples 'common behavior' do
it 'closes the report' do
@@ -72,6 +75,26 @@ describe Admin::Reports::ActionsController do
subject
expect(response).to redirect_to(admin_reports_path)
end
context 'when text is unset' do
let(:common_params) do
{ report_id: report.id }
end
it 'closes the report' do
expect { subject }.to change { report.reload.action_taken? }.from(false).to(true)
end
it 'creates a strike with the expected text' do
expect { subject }.to change { report.target_account.strikes.count }.by(1)
expect(report.target_account.strikes.last.text).to eq ''
end
it 'redirects' do
subject
expect(response).to redirect_to(admin_reports_path)
end
end
end
shared_examples 'all action types' do
@@ -124,13 +147,13 @@ describe Admin::Reports::ActionsController do
end
context 'action as submit button' do
subject { post :create, params: { report_id: report.id, text: text, action => '' } }
subject { post :create, params: common_params.merge({ action => '' }) }
it_behaves_like 'all action types'
end
context 'action as submit button' do
subject { post :create, params: { report_id: report.id, text: text, moderation_action: action } }
subject { post :create, params: common_params.merge({ moderation_action: action }) }
it_behaves_like 'all action types'
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::RulesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Settings::AboutController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Settings::AppearanceController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Settings::ContentRetentionController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Settings::DiscoveryController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Settings::RegistrationsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::SiteUploadsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'DELETE #destroy' do
let(:site_upload) { Fabricate(:site_upload, var: 'thumbnail') }
it 'returns http success' do
delete :destroy, params: { id: site_upload.id }
expect(response).to redirect_to(admin_settings_path)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Trends::Links::PreviewCardProvidersController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Trends::LinksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Trends::StatusesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Trends::TagsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::WarningPresetsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::Webhooks::SecretsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'POST #rotate' do
let(:webhook) { Fabricate(:webhook) }
it 'returns http success' do
post :rotate, params: { webhook_id: webhook.id }
expect(response).to redirect_to(admin_webhook_path(webhook))
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::WebhooksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Accounts::FamiliarFollowersController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:follows') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Accounts::FeaturedTagsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Accounts::IdentityProofsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Accounts::LookupController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #show' do
it 'returns http success' do
get :show, params: { account_id: account.id, acct: account.acct }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::CanonicalEmailBlocksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::DimensionsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
it 'returns http success' do
post :create, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::EmailDomainBlocksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::IpBlocksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::MeasuresController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
it 'returns http success' do
post :create, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::RetentionController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
it 'returns http success' do
post :create, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::Trends::LinksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::Trends::StatusesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Admin::Trends::TagsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'admin:read') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::DirectoriesController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:follows') }
let(:account) { Fabricate(:account) }
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

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::FeaturedTags::SuggestionsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::FeaturedTagsController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'GET #index' do
it 'returns http success' do
get :index, params: { account_id: account.id, limit: 2 }
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Instances::DomainBlocksController do
render_views
describe 'GET #index' do
it 'returns http success' do
Setting.show_domain_blocks = 'all'
get :index
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Instances::ExtendedDescriptionsController do
render_views
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Instances::PrivacyPoliciesController do
render_views
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Instances::RulesController do
render_views
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::PreferencesController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
let(:account) { Fabricate(:account) }
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

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::ScheduledStatusesController do
render_views
let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses') }
let(:account) { Fabricate(:account) }
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

View File

@@ -0,0 +1,33 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Statuses::TranslationsController do
render_views
let(:user) { Fabricate(:user) }
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses', application: app) }
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
let(:status) { Fabricate(:status, account: user.account, text: 'Hola', language: 'es') }
before do
translation = TranslationService::Translation.new(text: 'Hello')
service = instance_double(TranslationService::DeepL, translate: translation, supported?: true)
allow(TranslationService).to receive(:configured?).and_return(true)
allow(TranslationService).to receive(:configured).and_return(service)
post :create, params: { status_id: status.id }
end
it 'returns http success' do
expect(response).to have_http_status(200)
end
end
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Trends::LinksController do
render_views
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::Trends::StatusesController do
render_views
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
end
end
end

View File

@@ -58,7 +58,7 @@ describe RelationshipsController do
end
context 'when select parameter is provided' do
subject { patch :update, params: { form_account_batch: { account_ids: [poopfeast.id] }, block_domains: '' } }
subject { patch :update, params: { form_account_batch: { account_ids: [poopfeast.id] }, remove_domains_from_followers: '' } }
it 'soft-blocks followers from selected domains' do
poopfeast.follow!(user.account)
@@ -69,6 +69,15 @@ describe RelationshipsController do
expect(poopfeast.following?(user.account)).to be false
end
it 'does not unfollow users from selected domains' do
user.account.follow!(poopfeast)
sign_in user, scope: :user
subject
expect(user.account.following?(poopfeast)).to be true
end
include_examples 'authenticate user'
include_examples 'redirects back to followers page'
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Settings::AliasesController do
render_views
let!(:user) { Fabricate(:user) }
let(:account) { user.account }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'rails_helper'
describe Settings::Exports::BlockedDomainsController do
render_views
describe 'GET #index' do
it 'returns a csv of the domains' do
account = Fabricate(:account, domain: 'example.com')
user = Fabricate(:user, account: account)
Fabricate(:account_domain_block, domain: 'example.com', account: account)
sign_in user, scope: :user
get :index, format: :csv
expect(response.body).to eq "example.com\n"
end
end
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
describe Settings::Exports::ListsController do
render_views
describe 'GET #index' do
it 'returns a csv of the domains' do
account = Fabricate(:account)
user = Fabricate(:user, account: account)
list = Fabricate(:list, account: account, title: 'The List')
Fabricate(:list_account, list: list, account: account)
sign_in user, scope: :user
get :index, format: :csv
expect(response.body).to match 'The List'
end
end
end

View File

@@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'rails_helper'
describe Settings::LoginActivitiesController do
render_views
let!(:user) { Fabricate(:user) }
before do
sign_in user, scope: :user
end
describe 'GET #index' do
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'rails_helper'
describe Settings::Migration::RedirectsController do
render_views
let!(:user) { Fabricate(:user) }
before do
sign_in user, scope: :user
end
describe 'GET #new' do
it 'returns http success' do
get :new
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'
describe Settings::PicturesController do
render_views
let!(:user) { Fabricate(:user) }
before do
sign_in user, scope: :user
end
describe 'DELETE #destroy' do
context 'with invalid picture id' do
it 'returns http bad request' do
delete :destroy, params: { id: 'invalid' }
expect(response).to have_http_status(400)
end
end
end
end

View File

@@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'rails_helper'
describe Settings::Preferences::AppearanceController do
render_views
let!(:user) { Fabricate(:user) }
before do
sign_in user, scope: :user
end
describe 'GET #show' do
it 'returns http success' do
get :show
expect(response).to have_http_status(200)
end
end
end

View File

@@ -1,7 +0,0 @@
# frozen_string_literal: true
Fabricator(:account_alias) do
account
acct 'test@example.com'
uri 'https://example.com/users/test'
end

View File

@@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:account_deletion_request) do
account
end

View File

@@ -5,4 +5,5 @@ Fabricator(:account_migration) do
target_account { |attrs| Fabricate(:account, also_known_as: [ActivityPub::TagManager.instance.uri_for(attrs[:account])]) }
acct { |attrs| attrs[:target_account].acct }
followers_count 1234
created_at { 60.days.ago }
end

View File

@@ -2,5 +2,6 @@
Fabricator(:account_moderation_note) do
content 'MyText'
account nil
account
target_account { Fabricate(:account) }
end

View File

@@ -1,6 +1,7 @@
# frozen_string_literal: true
Fabricator(:account_pin) do
account nil
target_account nil
account
target_account(fabricator: :account)
before_create { |account_pin, _| account_pin.account.follow!(account_pin.target_account) }
end

View File

@@ -1,8 +1,8 @@
# frozen_string_literal: true
Fabricator(:account_stat) do
account nil
statuses_count ''
following_count ''
followers_count ''
account
statuses_count '123'
following_count '456'
followers_count '789'
end

View File

@@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:account_tag_stat) do
accounts_count ''
end

View File

@@ -1,5 +1,5 @@
# frozen_string_literal: true
Fabricator(:account_warning_preset) do
text 'MyText'
text { Faker::Lorem.paragraph }
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
Fabricator('Admin::ActionLog') do
account nil
account
action 'MyString'
target nil
end

View File

@@ -1,6 +0,0 @@
# frozen_string_literal: true
Fabricator(:announcement_mute) do
account
announcement
end

View File

@@ -1,7 +0,0 @@
# frozen_string_literal: true
Fabricator(:announcement_reaction) do
account
announcement
name '🌿'
end

View File

@@ -1,8 +0,0 @@
# frozen_string_literal: true
Fabricator(:conversation_account) do
account nil
conversation nil
participant_account_ids ''
last_status nil
end

View File

@@ -1,4 +0,0 @@
# frozen_string_literal: true
Fabricator(:conversation_mute) do
end

View File

@@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:custom_emoji_category) do
name 'MyString'
end

View File

@@ -1,10 +0,0 @@
# frozen_string_literal: true
Fabricator(:encrypted_message) do
device
from_account
from_device_id { Faker::Number.number(digits: 5) }
type 0
body ''
message_franking ''
end

View File

@@ -1,8 +0,0 @@
# frozen_string_literal: true
Fabricator(:featured_tag) do
account
tag
statuses_count 1_337
last_status_at Time.now.utc
end

View File

@@ -1,5 +0,0 @@
# frozen_string_literal: true
Fabricator(:follow_recommendation_suppression) do
account
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
Fabricator(:identity) do
user nil
user
provider 'MyString'
uid 'MyString'
end

View File

@@ -1,4 +0,0 @@
# frozen_string_literal: true
Fabricator(:import) do
end

View File

@@ -1,8 +0,0 @@
# frozen_string_literal: true
Fabricator(:ip_block) do
ip ''
severity ''
expires_at '2020-10-08 22:20:37'
comment 'MyText'
end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
Fabricator(:list_account) do
list nil
account nil
follow nil
list
account
before_create { |list_account, _| list_account.list.account.follow!(account) }
end

View File

@@ -3,7 +3,7 @@
Fabricator(:one_time_key) do
device
key_id { Faker::Alphanumeric.alphanumeric(number: 10) }
key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
signature do |attrs|
signing_key = Ed25519::SigningKey.generate

View File

@@ -0,0 +1,5 @@
# frozen_string_literal: true
Fabricator(:preview_card_provider) do
domain { Faker::Internet.domain_name }
end

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
Fabricator(:setting) do
var 'var'
end

View File

@@ -2,4 +2,5 @@
Fabricator(:site_upload) do
file { Rails.root.join('spec', 'fabricators', 'assets', 'utah_teapot.png').open }
var 'thumbnail'
end

View File

@@ -1,9 +0,0 @@
# frozen_string_literal: true
Fabricator(:status_edit) do
status nil
account nil
text 'MyText'
spoiler_text 'MyText'
media_attachments_changed false
end

View File

@@ -1,8 +0,0 @@
# frozen_string_literal: true
Fabricator(:status_stat) do
status_id nil
replies_count ''
reblogs_count ''
favourites_count ''
end

View File

@@ -1,5 +1,5 @@
# frozen_string_literal: true
Fabricator(:unavailable_domain) do
domain { Faker::Internet.domain }
domain { Faker::Internet.domain_name }
end

View File

@@ -1,6 +0,0 @@
# frozen_string_literal: true
Fabricator(:user_invite_request) do
user
text { Faker::Lorem.sentence }
end

View File

@@ -1,4 +0,0 @@
# frozen_string_literal: true
Fabricator(:web_setting, from: Web::Setting) do
end

12
spec/fabricators_spec.rb Normal file
View File

@@ -0,0 +1,12 @@
require 'rails_helper'
Fabrication.manager.load_definitions if Fabrication.manager.empty?
Fabrication.manager.schematics.map(&:first).each do |factory_name|
describe "The #{factory_name} factory" do
it 'is valid' do
factory = Fabricate(factory_name)
expect(factory).to be_valid
end
end
end

View File

@@ -42,13 +42,11 @@ RSpec.describe Admin::AccountModerationNotesHelper, type: :helper do
let(:account) { Fabricate(:account) }
it 'calls #link_to' do
expect(helper).to receive(:link_to).with(
admin_account_path(account.id),
class: name_tag_classes(account, true),
title: account.acct
)
result = helper.admin_account_inline_link_to(account)
helper.admin_account_inline_link_to(account)
expect(result).to match(name_tag_classes(account, true))
expect(result).to match(account.acct)
expect(result).to match(admin_account_path(account.id))
end
end
end

View File

@@ -0,0 +1,69 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::DashboardHelper do
describe 'relevant_account_timestamp' do
context 'with an account with older sign in' do
let(:account) { Fabricate(:account) }
let(:stamp) { 10.days.ago }
it 'returns a time element' do
account.user.update(current_sign_in_at: stamp)
result = helper.relevant_account_timestamp(account)
expect(result).to match('time-ago')
expect(result).to match(I18n.l(stamp))
end
end
context 'with an account with newer sign in' do
let(:account) { Fabricate(:account) }
it 'returns a time element' do
account.user.update(current_sign_in_at: 10.hours.ago)
result = helper.relevant_account_timestamp(account)
expect(result).to eq(I18n.t('generic.today'))
end
end
context 'with an account where the user is pending' do
let(:account) { Fabricate(:account) }
it 'returns a time element' do
account.user.update(current_sign_in_at: nil)
account.user.update(approved: false)
result = helper.relevant_account_timestamp(account)
expect(result).to match('time-ago')
expect(result).to match(I18n.l(account.user.created_at))
end
end
context 'with an account with a last status value' do
let(:account) { Fabricate(:account) }
let(:stamp) { 5.minutes.ago }
it 'returns a time element' do
account.user.update(current_sign_in_at: nil)
account.account_stat.update(last_status_at: stamp)
result = helper.relevant_account_timestamp(account)
expect(result).to match('time-ago')
expect(result).to match(I18n.l(stamp))
end
end
context 'with an account without sign in or last status or pending' do
let(:account) { Fabricate(:account) }
it 'returns a time element' do
account.user.update(current_sign_in_at: nil)
result = helper.relevant_account_timestamp(account)
expect(result).to eq('-')
end
end
end
end

View File

@@ -10,14 +10,54 @@ describe LanguagesHelper do
end
describe 'native_locale_name' do
it 'finds the human readable native name from a key' do
expect(helper.native_locale_name(:de)).to eq('Deutsch')
context 'with a blank locale' do
it 'defaults to a generic value' do
expect(helper.native_locale_name(nil)).to eq(I18n.t('generic.none'))
end
end
context 'with a locale of `und`' do
it 'defaults to a generic value' do
expect(helper.native_locale_name('und')).to eq(I18n.t('generic.none'))
end
end
context 'with a supported locale' do
it 'finds the human readable native name from a key' do
expect(helper.native_locale_name(:de)).to eq('Deutsch')
end
end
context 'with a regional locale' do
it 'finds the human readable regional name from a key' do
expect(helper.native_locale_name('en-GB')).to eq('English (British)')
end
end
context 'with a non-existent locale' do
it 'returns the supplied locale value' do
expect(helper.native_locale_name(:xxx)).to eq(:xxx)
end
end
end
describe 'standard_locale_name' do
it 'finds the human readable standard name from a key' do
expect(helper.standard_locale_name(:de)).to eq('German')
context 'with a blank locale' do
it 'defaults to a generic value' do
expect(helper.standard_locale_name(nil)).to eq(I18n.t('generic.none'))
end
end
context 'with a non-existent locale' do
it 'returns the supplied locale value' do
expect(helper.standard_locale_name(:xxx)).to eq(:xxx)
end
end
context 'with a supported locale' do
it 'finds the human readable standard name from a key' do
expect(helper.standard_locale_name(:de)).to eq('German')
end
end
end
end

View File

@@ -0,0 +1,37 @@
# frozen_string_literal: true
require 'rails_helper'
describe SettingsHelper do
describe 'session_device_icon' do
context 'with a mobile device' do
let(:session) { SessionActivation.new(user_agent: 'Mozilla/5.0 (iPhone)') }
it 'detects the device and returns a descriptive string' do
result = helper.session_device_icon(session)
expect(result).to eq('mobile')
end
end
context 'with a tablet device' do
let(:session) { SessionActivation.new(user_agent: 'Mozilla/5.0 (iPad)') }
it 'detects the device and returns a descriptive string' do
result = helper.session_device_icon(session)
expect(result).to eq('tablet')
end
end
context 'with a desktop device' do
let(:session) { SessionActivation.new(user_agent: 'Mozilla/5.0 (Macintosh)') }
it 'detects the device and returns a descriptive string' do
result = helper.session_device_icon(session)
expect(result).to eq('desktop')
end
end
end
end

View File

@@ -3,6 +3,68 @@
require 'rails_helper'
RSpec.describe StatusesHelper, type: :helper do
describe 'link_to_newer' do
it 'returns a link to newer content' do
url = 'https://example.com'
result = helper.link_to_newer(url)
expect(result).to match('load-more')
expect(result).to match(I18n.t('statuses.show_newer'))
end
end
describe 'link_to_older' do
it 'returns a link to older content' do
url = 'https://example.com'
result = helper.link_to_older(url)
expect(result).to match('load-more')
expect(result).to match(I18n.t('statuses.show_older'))
end
end
describe 'fa_visibility_icon' do
context 'with a status that is public' do
let(:status) { Status.new(visibility: 'public') }
it 'returns the correct fa icon' do
result = helper.fa_visibility_icon(status)
expect(result).to match('fa-globe')
end
end
context 'with a status that is unlisted' do
let(:status) { Status.new(visibility: 'unlisted') }
it 'returns the correct fa icon' do
result = helper.fa_visibility_icon(status)
expect(result).to match('fa-unlock')
end
end
context 'with a status that is private' do
let(:status) { Status.new(visibility: 'private') }
it 'returns the correct fa icon' do
result = helper.fa_visibility_icon(status)
expect(result).to match('fa-lock')
end
end
context 'with a status that is direct' do
let(:status) { Status.new(visibility: 'direct') }
it 'returns the correct fa icon' do
result = helper.fa_visibility_icon(status)
expect(result).to match('fa-at')
end
end
end
describe '#stream_link_target' do
it 'returns nil if it is not an embedded view' do
set_not_embedded_view

View File

@@ -0,0 +1,100 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe TranslationService::DeepL do
subject(:service) { described_class.new(plan, 'my-api-key') }
let(:plan) { 'advanced' }
before do
stub_request(:get, 'https://api.deepl.com/v2/languages?type=source').to_return(
body: '[{"language":"EN","name":"English"},{"language":"UK","name":"Ukrainian"}]'
)
stub_request(:get, 'https://api.deepl.com/v2/languages?type=target').to_return(
body: '[{"language":"EN-GB","name":"English (British)"},{"language":"ZH","name":"Chinese"}]'
)
end
describe '#supported?' do
it 'supports included languages as source and target languages' do
expect(service.supported?('uk', 'en')).to be true
end
it 'supports auto-detecting source language' do
expect(service.supported?(nil, 'en')).to be true
end
it 'supports "en" and "pt" as target languages though not included in language list' do
expect(service.supported?('uk', 'en')).to be true
expect(service.supported?('uk', 'pt')).to be true
end
it 'does not support non-included language as target language' do
expect(service.supported?('uk', 'nl')).to be false
end
it 'does not support non-included language as source language' do
expect(service.supported?('da', 'en')).to be false
end
end
describe '#translate' do
it 'returns translation with specified source language' do
stub_request(:post, 'https://api.deepl.com/v2/translate')
.with(body: 'text=Hasta+la+vista&source_lang=ES&target_lang=en&tag_handling=html')
.to_return(body: '{"translations":[{"detected_source_language":"ES","text":"See you soon"}]}')
translation = service.translate('Hasta la vista', 'es', 'en')
expect(translation.detected_source_language).to eq 'es'
expect(translation.provider).to eq 'DeepL.com'
expect(translation.text).to eq 'See you soon'
end
it 'returns translation with auto-detected source language' do
stub_request(:post, 'https://api.deepl.com/v2/translate')
.with(body: 'text=Guten+Tag&source_lang&target_lang=en&tag_handling=html')
.to_return(body: '{"translations":[{"detected_source_language":"DE","text":"Good Morning"}]}')
translation = service.translate('Guten Tag', nil, 'en')
expect(translation.detected_source_language).to eq 'de'
expect(translation.provider).to eq 'DeepL.com'
expect(translation.text).to eq 'Good Morning'
end
end
describe '#languages?' do
it 'returns source languages' do
expect(service.send(:languages, 'source')).to eq ['en', 'uk', nil]
end
it 'returns target languages' do
expect(service.send(:languages, 'target')).to eq %w(en-gb zh en pt)
end
end
describe '#request' do
before do
stub_request(:any, //)
# rubocop:disable Lint/EmptyBlock
service.send(:request, :get, '/v2/languages') { |res| }
# rubocop:enable Lint/EmptyBlock
end
it 'uses paid plan base URL' do
expect(a_request(:get, 'https://api.deepl.com/v2/languages')).to have_been_made.once
end
context 'with free plan' do
let(:plan) { 'free' }
it 'uses free plan base URL' do
expect(a_request(:get, 'https://api-free.deepl.com/v2/languages')).to have_been_made.once
end
end
it 'sends API key' do
expect(a_request(:get, 'https://api.deepl.com/v2/languages').with(headers: { Authorization: 'DeepL-Auth-Key my-api-key' })).to have_been_made.once
end
end
end

View File

@@ -0,0 +1,71 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe TranslationService::LibreTranslate do
subject(:service) { described_class.new('https://libretranslate.example.com', 'my-api-key') }
before do
stub_request(:get, 'https://libretranslate.example.com/languages').to_return(
body: '[{"code": "en","name": "English","targets": ["de","es"]},{"code": "da","name": "Danish","targets": ["en","de"]}]'
)
end
describe '#supported?' do
it 'supports included language pair' do
expect(service.supported?('en', 'de')).to be true
end
it 'does not support reversed language pair' do
expect(service.supported?('de', 'en')).to be false
end
it 'supports auto-detecting source language' do
expect(service.supported?(nil, 'de')).to be true
end
it 'does not support auto-detecting for unsupported target language' do
expect(service.supported?(nil, 'pt')).to be false
end
end
describe '#languages' do
subject(:languages) { service.send(:languages) }
it 'includes supported source languages' do
expect(languages.keys).to eq ['en', 'da', nil]
end
it 'includes supported target languages for source language' do
expect(languages['en']).to eq %w(de es)
end
it 'includes supported target languages for auto-detected language' do
expect(languages[nil]).to eq %w(de es en)
end
end
describe '#translate' do
it 'returns translation with specified source language' do
stub_request(:post, 'https://libretranslate.example.com/translate')
.with(body: '{"q":"Hasta la vista","source":"es","target":"en","format":"html","api_key":"my-api-key"}')
.to_return(body: '{"translatedText": "See you"}')
translation = service.translate('Hasta la vista', 'es', 'en')
expect(translation.detected_source_language).to eq 'es'
expect(translation.provider).to eq 'LibreTranslate'
expect(translation.text).to eq 'See you'
end
it 'returns translation with auto-detected source language' do
stub_request(:post, 'https://libretranslate.example.com/translate')
.with(body: '{"q":"Guten Morgen","source":"auto","target":"en","format":"html","api_key":"my-api-key"}')
.to_return(body: '{"detectedLanguage":{"confidence":92,"language":"de"},"translatedText":"Good morning"}')
translation = service.translate('Guten Morgen', nil, 'en')
expect(translation.detected_source_language).to be_nil
expect(translation.provider).to eq 'LibreTranslate'
expect(translation.text).to eq 'Good morning'
end
end
end

View File

@@ -94,4 +94,52 @@ describe UserMailer, type: :mailer do
expect(mail.body.encoded).to include strike.text
end
end
describe 'webauthn_credential_deleted' do
let(:credential) { Fabricate(:webauthn_credential, user_id: receiver.id) }
let(:mail) { UserMailer.webauthn_credential_deleted(receiver, credential) }
it 'renders webauthn credential deleted notification' do
receiver.update!(locale: nil)
expect(mail.body.encoded).to include I18n.t('devise.mailer.webauthn_credential.deleted.title')
end
include_examples 'localized subject',
'devise.mailer.webauthn_credential.deleted.subject'
end
describe 'suspicious_sign_in' do
let(:ip) { '192.168.0.1' }
let(:agent) { 'NCSA_Mosaic/2.0 (Windows 3.1)' }
let(:timestamp) { Time.now.utc }
let(:mail) { UserMailer.suspicious_sign_in(receiver, ip, agent, timestamp) }
it 'renders suspicious sign in notification' do
receiver.update!(locale: nil)
expect(mail.body.encoded).to include I18n.t('user_mailer.suspicious_sign_in.explanation')
end
include_examples 'localized subject',
'user_mailer.suspicious_sign_in.subject'
end
describe 'appeal_approved' do
let(:appeal) { Fabricate(:appeal, account: receiver.account, approved_at: Time.now.utc) }
let(:mail) { UserMailer.appeal_approved(receiver, appeal) }
it 'renders appeal_approved notification' do
expect(mail.subject).to eq I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at))
expect(mail.body.encoded).to include I18n.t('user_mailer.appeal_approved.title')
end
end
describe 'appeal_rejected' do
let(:appeal) { Fabricate(:appeal, account: receiver.account, rejected_at: Time.now.utc) }
let(:mail) { UserMailer.appeal_rejected(receiver, appeal) }
it 'renders appeal_rejected notification' do
expect(mail.subject).to eq I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at))
expect(mail.body.encoded).to include I18n.t('user_mailer.appeal_rejected.title')
end
end
end

View File

@@ -704,12 +704,6 @@ RSpec.describe Account, type: :model do
end
describe 'validations' do
it 'has a valid fabricator' do
account = Fabricate.build(:account)
account.valid?
expect(account).to be_valid
end
it 'is invalid without a username' do
account = Fabricate.build(:account, username: nil)
account.valid?

View File

@@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'rails_helper'
describe AccountWarningPreset do
describe 'alphabetical' do
let(:first) { Fabricate(:account_warning_preset, title: 'aaa', text: 'aaa') }
let(:second) { Fabricate(:account_warning_preset, title: 'bbb', text: 'aaa') }
let(:third) { Fabricate(:account_warning_preset, title: 'bbb', text: 'bbb') }
it 'returns records in order of title and text' do
results = described_class.alphabetic
expect(results).to eq([first, second, third])
end
end
end

View File

@@ -2,6 +2,37 @@
require 'rails_helper'
RSpec.describe Appeal, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
describe Appeal do
describe 'scopes' do
describe 'approved' do
let(:approved_appeal) { Fabricate(:appeal, approved_at: 10.days.ago) }
let(:not_approved_appeal) { Fabricate(:appeal, approved_at: nil) }
it 'finds the correct records' do
results = described_class.approved
expect(results).to eq([approved_appeal])
end
end
describe 'rejected' do
let(:rejected_appeal) { Fabricate(:appeal, rejected_at: 10.days.ago) }
let(:not_rejected_appeal) { Fabricate(:appeal, rejected_at: nil) }
it 'finds the correct records' do
results = described_class.rejected
expect(results).to eq([rejected_appeal])
end
end
describe 'pending' do
let(:approved_appeal) { Fabricate(:appeal, approved_at: 10.days.ago) }
let(:rejected_appeal) { Fabricate(:appeal, rejected_at: 10.days.ago) }
let(:pending_appeal) { Fabricate(:appeal, rejected_at: nil, approved_at: nil) }
it 'finds the correct records' do
results = described_class.pending
expect(results).to eq([pending_appeal])
end
end
end
end

View File

@@ -4,11 +4,6 @@ require 'rails_helper'
RSpec.describe Block, type: :model do
describe 'validations' do
it 'has a valid fabricator' do
block = Fabricate.build(:block)
expect(block).to be_valid
end
it 'is invalid without an account' do
block = Fabricate.build(:block, account: nil)
block.valid?

View File

@@ -2,6 +2,13 @@
require 'rails_helper'
RSpec.describe CustomEmojiCategory, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
describe CustomEmojiCategory do
describe 'validations' do
it 'validates name presence' do
record = described_class.new(name: nil)
expect(record).to_not be_valid
expect(record).to model_have_error_on_field(:name)
end
end
end

View File

@@ -2,6 +2,17 @@
require 'rails_helper'
RSpec.describe DomainAllow, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
describe DomainAllow do
describe 'scopes' do
describe 'matches_domain' do
let(:domain) { Fabricate(:domain_allow, domain: 'example.com') }
let(:other_domain) { Fabricate(:domain_allow, domain: 'example.biz') }
it 'returns the correct records' do
results = described_class.matches_domain('example.com')
expect(results).to eq([domain])
end
end
end
end

View File

@@ -4,11 +4,6 @@ require 'rails_helper'
RSpec.describe DomainBlock, type: :model do
describe 'validations' do
it 'has a valid fabricator' do
domain_block = Fabricate.build(:domain_block)
expect(domain_block).to be_valid
end
it 'is invalid without a domain' do
domain_block = Fabricate.build(:domain_block, domain: nil)
domain_block.valid?

Some files were not shown because too many files have changed in this diff Show More