Fix RSpec/ContextWording cop (#24739)
parent
cf18cc2891
commit
710745e16b
|
@ -328,115 +328,6 @@ RSpec/AnyInstance:
|
|||
- 'spec/workers/activitypub/delivery_worker_spec.rb'
|
||||
- 'spec/workers/web/push_notification_worker_spec.rb'
|
||||
|
||||
# Configuration parameters: Prefixes, AllowedPatterns.
|
||||
# Prefixes: when, with, without
|
||||
RSpec/ContextWording:
|
||||
Exclude:
|
||||
- 'spec/config/initializers/rack_attack_spec.rb'
|
||||
- 'spec/controllers/accounts_controller_spec.rb'
|
||||
- 'spec/controllers/activitypub/collections_controller_spec.rb'
|
||||
- 'spec/controllers/activitypub/inboxes_controller_spec.rb'
|
||||
- 'spec/controllers/admin/domain_blocks_controller_spec.rb'
|
||||
- 'spec/controllers/admin/reports/actions_controller_spec.rb'
|
||||
- 'spec/controllers/admin/statuses_controller_spec.rb'
|
||||
- 'spec/controllers/api/v1/accounts/relationships_controller_spec.rb'
|
||||
- 'spec/controllers/api/v1/accounts_controller_spec.rb'
|
||||
- 'spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb'
|
||||
- 'spec/controllers/api/v1/emails/confirmations_controller_spec.rb'
|
||||
- 'spec/controllers/api/v1/instances/activity_controller_spec.rb'
|
||||
- 'spec/controllers/api/v1/instances/peers_controller_spec.rb'
|
||||
- 'spec/controllers/api/v1/media_controller_spec.rb'
|
||||
- 'spec/controllers/api/v2/filters_controller_spec.rb'
|
||||
- 'spec/controllers/application_controller_spec.rb'
|
||||
- 'spec/controllers/auth/registrations_controller_spec.rb'
|
||||
- 'spec/controllers/auth/sessions_controller_spec.rb'
|
||||
- 'spec/controllers/concerns/cache_concern_spec.rb'
|
||||
- 'spec/controllers/concerns/challengable_concern_spec.rb'
|
||||
- 'spec/controllers/concerns/localized_spec.rb'
|
||||
- 'spec/controllers/concerns/rate_limit_headers_spec.rb'
|
||||
- 'spec/controllers/instance_actors_controller_spec.rb'
|
||||
- 'spec/controllers/settings/applications_controller_spec.rb'
|
||||
- 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb'
|
||||
- 'spec/controllers/statuses_controller_spec.rb'
|
||||
- 'spec/helpers/admin/account_moderation_notes_helper_spec.rb'
|
||||
- 'spec/helpers/jsonld_helper_spec.rb'
|
||||
- 'spec/helpers/routing_helper_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/accept_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/announce_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/create_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/follow_spec.rb'
|
||||
- 'spec/lib/activitypub/activity/reject_spec.rb'
|
||||
- 'spec/lib/emoji_formatter_spec.rb'
|
||||
- 'spec/lib/entity_cache_spec.rb'
|
||||
- 'spec/lib/feed_manager_spec.rb'
|
||||
- 'spec/lib/html_aware_formatter_spec.rb'
|
||||
- 'spec/lib/link_details_extractor_spec.rb'
|
||||
- 'spec/lib/ostatus/tag_manager_spec.rb'
|
||||
- 'spec/lib/scope_transformer_spec.rb'
|
||||
- 'spec/lib/status_cache_hydrator_spec.rb'
|
||||
- 'spec/lib/status_reach_finder_spec.rb'
|
||||
- 'spec/lib/text_formatter_spec.rb'
|
||||
- 'spec/models/account/field_spec.rb'
|
||||
- 'spec/models/account_spec.rb'
|
||||
- 'spec/models/admin/account_action_spec.rb'
|
||||
- 'spec/models/concerns/account_interactions_spec.rb'
|
||||
- 'spec/models/concerns/remotable_spec.rb'
|
||||
- 'spec/models/custom_emoji_filter_spec.rb'
|
||||
- 'spec/models/custom_emoji_spec.rb'
|
||||
- 'spec/models/email_domain_block_spec.rb'
|
||||
- 'spec/models/media_attachment_spec.rb'
|
||||
- 'spec/models/notification_spec.rb'
|
||||
- 'spec/models/remote_follow_spec.rb'
|
||||
- 'spec/models/report_spec.rb'
|
||||
- 'spec/models/session_activation_spec.rb'
|
||||
- 'spec/models/setting_spec.rb'
|
||||
- 'spec/models/status_spec.rb'
|
||||
- 'spec/models/web/push_subscription_spec.rb'
|
||||
- 'spec/policies/account_moderation_note_policy_spec.rb'
|
||||
- 'spec/policies/account_policy_spec.rb'
|
||||
- 'spec/policies/backup_policy_spec.rb'
|
||||
- 'spec/policies/custom_emoji_policy_spec.rb'
|
||||
- 'spec/policies/domain_block_policy_spec.rb'
|
||||
- 'spec/policies/email_domain_block_policy_spec.rb'
|
||||
- 'spec/policies/instance_policy_spec.rb'
|
||||
- 'spec/policies/invite_policy_spec.rb'
|
||||
- 'spec/policies/relay_policy_spec.rb'
|
||||
- 'spec/policies/report_note_policy_spec.rb'
|
||||
- 'spec/policies/report_policy_spec.rb'
|
||||
- 'spec/policies/settings_policy_spec.rb'
|
||||
- 'spec/policies/tag_policy_spec.rb'
|
||||
- 'spec/policies/user_policy_spec.rb'
|
||||
- 'spec/presenters/account_relationships_presenter_spec.rb'
|
||||
- 'spec/presenters/status_relationships_presenter_spec.rb'
|
||||
- 'spec/services/account_search_service_spec.rb'
|
||||
- 'spec/services/account_statuses_cleanup_service_spec.rb'
|
||||
- 'spec/services/activitypub/fetch_remote_status_service_spec.rb'
|
||||
- 'spec/services/activitypub/process_account_service_spec.rb'
|
||||
- 'spec/services/activitypub/process_status_update_service_spec.rb'
|
||||
- 'spec/services/fetch_link_card_service_spec.rb'
|
||||
- 'spec/services/fetch_oembed_service_spec.rb'
|
||||
- 'spec/services/fetch_remote_status_service_spec.rb'
|
||||
- 'spec/services/follow_service_spec.rb'
|
||||
- 'spec/services/import_service_spec.rb'
|
||||
- 'spec/services/notify_service_spec.rb'
|
||||
- 'spec/services/process_mentions_service_spec.rb'
|
||||
- 'spec/services/reblog_service_spec.rb'
|
||||
- 'spec/services/report_service_spec.rb'
|
||||
- 'spec/services/resolve_account_service_spec.rb'
|
||||
- 'spec/services/resolve_url_service_spec.rb'
|
||||
- 'spec/services/search_service_spec.rb'
|
||||
- 'spec/services/unallow_domain_service_spec.rb'
|
||||
- 'spec/services/verify_link_service_spec.rb'
|
||||
- 'spec/validators/disallowed_hashtags_validator_spec.rb'
|
||||
- 'spec/validators/email_mx_validator_spec.rb'
|
||||
- 'spec/validators/follow_limit_validator_spec.rb'
|
||||
- 'spec/validators/poll_validator_spec.rb'
|
||||
- 'spec/validators/status_pin_validator_spec.rb'
|
||||
- 'spec/validators/unreserved_username_validator_spec.rb'
|
||||
- 'spec/validators/url_validator_spec.rb'
|
||||
- 'spec/workers/move_worker_spec.rb'
|
||||
- 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb'
|
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: SkipBlocks, EnforcedStyle.
|
||||
# SupportedStyles: described_class, explicit
|
||||
|
|
|
@ -46,36 +46,36 @@ describe Rack::Attack, type: :request do
|
|||
let(:remote_ip) { '1.2.3.5' }
|
||||
|
||||
describe 'throttle excessive sign-up requests by IP address' do
|
||||
context 'through the website' do
|
||||
context 'when accessed through the website' do
|
||||
let(:limit) { 25 }
|
||||
let(:period) { 5.minutes }
|
||||
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
|
||||
|
||||
context 'for exact path' do
|
||||
context 'with exact path' do
|
||||
let(:path) { '/auth' }
|
||||
|
||||
it_behaves_like 'throttled endpoint'
|
||||
end
|
||||
|
||||
context 'for path with format' do
|
||||
context 'with path with format' do
|
||||
let(:path) { '/auth.html' }
|
||||
|
||||
it_behaves_like 'throttled endpoint'
|
||||
end
|
||||
end
|
||||
|
||||
context 'through the API' do
|
||||
context 'when accessed through the API' do
|
||||
let(:limit) { 5 }
|
||||
let(:period) { 30.minutes }
|
||||
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
|
||||
|
||||
context 'for exact path' do
|
||||
context 'with exact path' do
|
||||
let(:path) { '/api/v1/accounts' }
|
||||
|
||||
it_behaves_like 'throttled endpoint'
|
||||
end
|
||||
|
||||
context 'for path with format' do
|
||||
context 'with path with format' do
|
||||
let(:path) { '/api/v1/accounts.json' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -91,13 +91,13 @@ describe Rack::Attack, type: :request do
|
|||
let(:period) { 5.minutes }
|
||||
let(:request) { -> { post path, headers: { 'REMOTE_ADDR' => remote_ip } } }
|
||||
|
||||
context 'for exact path' do
|
||||
context 'with exact path' do
|
||||
let(:path) { '/auth/sign_in' }
|
||||
|
||||
it_behaves_like 'throttled endpoint'
|
||||
end
|
||||
|
||||
context 'for path with format' do
|
||||
context 'with path with format' do
|
||||
let(:path) { '/auth/sign_in.html' }
|
||||
|
||||
it_behaves_like 'throttled endpoint'
|
||||
|
|
|
@ -57,7 +57,7 @@ RSpec.describe AccountsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it_behaves_like 'preliminary checks'
|
||||
|
@ -140,7 +140,7 @@ RSpec.describe AccountsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:authorized_fetch_mode) { false }
|
||||
let(:format) { 'json' }
|
||||
|
||||
|
@ -193,7 +193,7 @@ RSpec.describe AccountsController, type: :controller do
|
|||
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
||||
end
|
||||
|
||||
context 'in authorized fetch mode' do
|
||||
context 'with authorized fetch mode' do
|
||||
let(:authorized_fetch_mode) { true }
|
||||
|
||||
it 'returns http unauthorized' do
|
||||
|
@ -251,7 +251,7 @@ RSpec.describe AccountsController, type: :controller do
|
|||
expect(json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
|
||||
end
|
||||
|
||||
context 'in authorized fetch mode' do
|
||||
context 'with authorized fetch mode' do
|
||||
let(:authorized_fetch_mode) { true }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -278,7 +278,7 @@ RSpec.describe AccountsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as RSS' do
|
||||
context 'with RSS' do
|
||||
let(:format) { 'rss' }
|
||||
|
||||
it_behaves_like 'preliminary checks'
|
||||
|
|
|
@ -119,7 +119,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'in authorized fetch mode' do
|
||||
context 'with authorized fetch mode' do
|
||||
before do
|
||||
allow(controller).to receive(:authorized_fetch_mode?).and_return(true)
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do
|
|||
expect(response).to have_http_status(202)
|
||||
end
|
||||
|
||||
context 'for a specific account' do
|
||||
context 'with a specific account' do
|
||||
subject(:response) { post :create, params: { account_username: account.username }, body: '{}' }
|
||||
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
|
|
@ -83,7 +83,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do
|
|||
BlockDomainService.new.call(domain_block)
|
||||
end
|
||||
|
||||
context 'downgrading a domain suspension to silence' do
|
||||
context 'when downgrading a domain suspension to silence' do
|
||||
let(:original_severity) { 'suspend' }
|
||||
let(:new_severity) { 'silence' }
|
||||
|
||||
|
@ -100,7 +100,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'upgrading a domain silence to suspend' do
|
||||
context 'when upgrading a domain silence to suspend' do
|
||||
let(:original_severity) { 'silence' }
|
||||
let(:new_severity) { 'suspend' }
|
||||
|
||||
|
|
|
@ -146,13 +146,13 @@ describe Admin::Reports::ActionsController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'action as submit button' do
|
||||
context 'with Action as submit button' do
|
||||
subject { post :create, params: common_params.merge({ action => '' }) }
|
||||
|
||||
it_behaves_like 'all action types'
|
||||
end
|
||||
|
||||
context 'action as submit button' do
|
||||
context 'with Action as submit button' do
|
||||
subject { post :create, params: common_params.merge({ moderation_action: action }) }
|
||||
|
||||
it_behaves_like 'all action types'
|
||||
|
|
|
@ -30,7 +30,7 @@ describe Admin::StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'filtering by media' do
|
||||
context 'when filtering by media' do
|
||||
before do
|
||||
get :index, params: { account_id: account.id, media: '1' }
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Api::V1::Accounts::RelationshipsController do
|
|||
lewis.follow!(user.account)
|
||||
end
|
||||
|
||||
context 'provided only one ID' do
|
||||
context 'when provided only one ID' do
|
||||
before do
|
||||
get :index, params: { id: simon.id }
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ describe Api::V1::Accounts::RelationshipsController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'provided multiple IDs' do
|
||||
context 'when provided multiple IDs' do
|
||||
before do
|
||||
get :index, params: { id: [simon.id, lewis.id] }
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
|
|||
post :create, params: { username: 'test', password: '12345678', email: 'hello@world.tld', agreement: agreement }
|
||||
end
|
||||
|
||||
context 'given truthy agreement' do
|
||||
context 'when given truthy agreement' do
|
||||
let(:agreement) { 'true' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -48,7 +48,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given no agreement' do
|
||||
context 'when given no agreement' do
|
||||
it 'returns http unprocessable entity' do
|
||||
expect(response).to have_http_status(422)
|
||||
end
|
||||
|
@ -121,7 +121,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'modifying follow options' do
|
||||
context 'when modifying follow options' do
|
||||
let(:locked) { false }
|
||||
|
||||
before do
|
||||
|
|
|
@ -84,7 +84,7 @@ RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do
|
|||
BlockDomainService.new.call(domain_block)
|
||||
end
|
||||
|
||||
context 'downgrading a domain suspension to silence' do
|
||||
context 'when downgrading a domain suspension to silence' do
|
||||
let(:original_severity) { 'suspend' }
|
||||
let(:new_severity) { 'silence' }
|
||||
|
||||
|
@ -101,7 +101,7 @@ RSpec.describe Api::V1::Admin::DomainBlocksController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'upgrading a domain silence to suspend' do
|
||||
context 'when upgrading a domain silence to suspend' do
|
||||
let(:original_severity) { 'silence' }
|
||||
let(:new_severity) { 'suspend' }
|
||||
|
||||
|
|
|
@ -15,14 +15,14 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
|
|||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
context 'from a random app' do
|
||||
context 'when from a random app' do
|
||||
it 'returns http forbidden' do
|
||||
post :create
|
||||
expect(response).to have_http_status(403)
|
||||
end
|
||||
end
|
||||
|
||||
context 'from an app that created the account' do
|
||||
context 'when from an app that created the account' do
|
||||
before do
|
||||
user.update(created_by_application: token.application)
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ RSpec.describe Api::V1::Emails::ConfirmationsController, type: :controller do
|
|||
expect(response).to have_http_status(403)
|
||||
end
|
||||
|
||||
context 'but user changed e-mail and has not confirmed it' do
|
||||
context 'with user changed e-mail and has not confirmed it' do
|
||||
before do
|
||||
user.update(email: 'foo@bar.com')
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ RSpec.describe Api::V1::Instances::ActivityController, type: :controller do
|
|||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context '!Setting.activity_api_enabled' do
|
||||
context 'with !Setting.activity_api_enabled' do
|
||||
it 'returns 404' do
|
||||
Setting.activity_api_enabled = false
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ RSpec.describe Api::V1::Instances::PeersController, type: :controller do
|
|||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context '!Setting.peers_api_enabled' do
|
||||
context 'with !Setting.peers_api_enabled' do
|
||||
it 'returns 404' do
|
||||
Setting.peers_api_enabled = false
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'image/jpeg' do
|
||||
context 'with image/jpeg' do
|
||||
before do
|
||||
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'image/gif' do
|
||||
context 'with image/gif' do
|
||||
before do
|
||||
post :create, params: { file: fixture_file_upload('attachment.gif', 'image/gif') }
|
||||
end
|
||||
|
@ -81,7 +81,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'video/webm' do
|
||||
context 'with video/webm' do
|
||||
before do
|
||||
post :create, params: { file: fixture_file_upload('attachment.webm', 'video/webm') }
|
||||
end
|
||||
|
|
|
@ -66,7 +66,7 @@ RSpec.describe Api::V2::FiltersController, type: :controller do
|
|||
let!(:filter) { Fabricate(:custom_filter, account: user.account) }
|
||||
let!(:keyword) { Fabricate(:custom_filter_keyword, custom_filter: filter) }
|
||||
|
||||
context 'updating filter parameters' do
|
||||
context 'when updating filter parameters' do
|
||||
before do
|
||||
put :update, params: { id: filter.id, title: 'updated', context: %w(home public) }
|
||||
end
|
||||
|
@ -84,7 +84,7 @@ RSpec.describe Api::V2::FiltersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'updating keywords in bulk' do
|
||||
context 'when updating keywords in bulk' do
|
||||
before do
|
||||
allow(redis).to receive_messages(publish: nil)
|
||||
put :update, params: { id: filter.id, keywords_attributes: [{ id: keyword.id, keyword: 'updated' }] }
|
||||
|
|
|
@ -32,7 +32,7 @@ describe ApplicationController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'forgery' do
|
||||
context 'with a forgery' do
|
||||
subject do
|
||||
ActionController::Base.allow_forgery_protection = true
|
||||
routes.draw { post 'success' => 'anonymous#success' }
|
||||
|
@ -105,7 +105,7 @@ describe ApplicationController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'ActionController::RoutingError' do
|
||||
context 'with ActionController::RoutingError' do
|
||||
subject do
|
||||
routes.draw { get 'routing_error' => 'anonymous#routing_error' }
|
||||
get 'routing_error'
|
||||
|
@ -114,7 +114,7 @@ describe ApplicationController, type: :controller do
|
|||
include_examples 'respond_with_error', 404
|
||||
end
|
||||
|
||||
context 'ActiveRecord::RecordNotFound' do
|
||||
context 'with ActiveRecord::RecordNotFound' do
|
||||
subject do
|
||||
routes.draw { get 'record_not_found' => 'anonymous#record_not_found' }
|
||||
get 'record_not_found'
|
||||
|
@ -123,7 +123,7 @@ describe ApplicationController, type: :controller do
|
|||
include_examples 'respond_with_error', 404
|
||||
end
|
||||
|
||||
context 'ActionController::InvalidAuthenticityToken' do
|
||||
context 'with ActionController::InvalidAuthenticityToken' do
|
||||
subject do
|
||||
routes.draw { get 'invalid_authenticity_token' => 'anonymous#invalid_authenticity_token' }
|
||||
get 'invalid_authenticity_token'
|
||||
|
@ -252,7 +252,7 @@ describe ApplicationController, type: :controller do
|
|||
expect(subject.new.cache_collection(raw, Object)).to eq raw
|
||||
end
|
||||
|
||||
context 'Status' do
|
||||
context 'with a Status' do
|
||||
include_examples 'cacheable', :status, Status
|
||||
end
|
||||
end
|
||||
|
|
|
@ -157,7 +157,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'approval-based registrations without invite' do
|
||||
context 'with Approval-based registrations without invite' do
|
||||
subject do
|
||||
Setting.registrations_mode = 'approved'
|
||||
request.headers['Accept-Language'] = accept_language
|
||||
|
@ -184,7 +184,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'approval-based registrations with expired invite' do
|
||||
context 'with Approval-based registrations with expired invite' do
|
||||
subject do
|
||||
Setting.registrations_mode = 'approved'
|
||||
request.headers['Accept-Language'] = accept_language
|
||||
|
@ -212,7 +212,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'approval-based registrations with valid invite and required invite text' do
|
||||
context 'with Approval-based registrations with valid invite and required invite text' do
|
||||
subject do
|
||||
inviter = Fabricate(:user, confirmed_at: 2.days.ago)
|
||||
Setting.registrations_mode = 'approved'
|
||||
|
|
|
@ -51,8 +51,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
|
||||
context 'using a valid password' do
|
||||
context 'when using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
|
||||
context 'when using a valid password' do
|
||||
before do
|
||||
post :create, params: { user: { email: 'pam_user1', password: '123456' } }
|
||||
end
|
||||
|
@ -66,7 +66,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using an invalid password' do
|
||||
context 'when using an invalid password' do
|
||||
before do
|
||||
post :create, params: { user: { email: 'pam_user1', password: 'WRONGPW' } }
|
||||
end
|
||||
|
@ -80,7 +80,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid email and existing user' do
|
||||
context 'when using a valid email and existing user' do
|
||||
let!(:user) do
|
||||
account = Fabricate.build(:account, username: 'pam_user1', user: nil)
|
||||
account.save!(validate: false)
|
||||
|
@ -102,10 +102,10 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using password authentication' do
|
||||
context 'when using password authentication' do
|
||||
let(:user) { Fabricate(:user, email: 'foo@bar.com', password: 'abcdefgh') }
|
||||
|
||||
context 'using a valid password' do
|
||||
context 'when using a valid password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
@ -119,7 +119,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid password on a previously-used account with a new IP address' do
|
||||
context 'when using a valid password on a previously-used account with a new IP address' do
|
||||
let(:previous_ip) { '1.2.3.4' }
|
||||
let(:current_ip) { '4.3.2.1' }
|
||||
|
||||
|
@ -145,7 +145,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using email with uppercase letters' do
|
||||
context 'when using email with uppercase letters' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email.upcase, password: user.password } }
|
||||
end
|
||||
|
@ -159,7 +159,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using an invalid password' do
|
||||
context 'when using an invalid password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email, password: 'wrongpw' } }
|
||||
end
|
||||
|
@ -173,7 +173,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using an unconfirmed password' do
|
||||
context 'when using an unconfirmed password' do
|
||||
before do
|
||||
request.headers['Accept-Language'] = accept_language
|
||||
post :create, params: { user: { email: unconfirmed_user.email, password: unconfirmed_user.password } }
|
||||
|
@ -187,14 +187,14 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context "logging in from the user's page" do
|
||||
context "when logging in from the user's page" do
|
||||
before do
|
||||
allow(controller).to receive(:single_user_mode?).and_return(single_user_mode)
|
||||
allow(controller).to receive(:stored_location_for).with(:user).and_return("/@#{user.account.username}")
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
||||
context 'in single user mode' do
|
||||
context 'with single user mode' do
|
||||
let(:single_user_mode) { true }
|
||||
|
||||
it 'redirects to home' do
|
||||
|
@ -202,7 +202,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'in non-single user mode' do
|
||||
context 'with non-single user mode' do
|
||||
let(:single_user_mode) { false }
|
||||
|
||||
it "redirects back to the user's page" do
|
||||
|
@ -212,7 +212,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using two-factor authentication' do
|
||||
context 'when using two-factor authentication' do
|
||||
context 'with OTP enabled as second factor' do
|
||||
let!(:user) do
|
||||
Fabricate(:user, email: 'x@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
|
||||
|
@ -224,7 +224,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
return codes
|
||||
end
|
||||
|
||||
context 'using email and password' do
|
||||
context 'when using email and password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
@ -235,7 +235,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using email and password after an unfinished log-in attempt to a 2FA-protected account' do
|
||||
context 'when using email and password after an unfinished log-in attempt to a 2FA-protected account' do
|
||||
let!(:other_user) do
|
||||
Fabricate(:user, email: 'z@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
|
||||
end
|
||||
|
@ -251,7 +251,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using upcase email and password' do
|
||||
context 'when using upcase email and password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email.upcase, password: user.password } }
|
||||
end
|
||||
|
@ -262,7 +262,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid OTP' do
|
||||
context 'when using a valid OTP' do
|
||||
before do
|
||||
post :create, params: { user: { otp_attempt: user.current_otp } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
|
||||
end
|
||||
|
@ -291,7 +291,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid recovery code' do
|
||||
context 'when using a valid recovery code' do
|
||||
before do
|
||||
post :create, params: { user: { otp_attempt: recovery_codes.first } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
|
||||
end
|
||||
|
@ -305,7 +305,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using an invalid OTP' do
|
||||
context 'when using an invalid OTP' do
|
||||
before do
|
||||
post :create, params: { user: { otp_attempt: 'wrongotp' } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
|
||||
end
|
||||
|
@ -353,7 +353,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
|
||||
let(:fake_credential) { fake_client.get(challenge: challenge, sign_count: sign_count) }
|
||||
|
||||
context 'using email and password' do
|
||||
context 'when using email and password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
@ -364,7 +364,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using upcase email and password' do
|
||||
context 'when using upcase email and password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email.upcase, password: user.password } }
|
||||
end
|
||||
|
@ -375,7 +375,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid webauthn credential' do
|
||||
context 'when using a valid webauthn credential' do
|
||||
before do
|
||||
@controller.session[:webauthn_challenge] = challenge
|
||||
|
||||
|
|
|
@ -23,14 +23,14 @@ RSpec.describe CacheConcern, type: :controller do
|
|||
end
|
||||
|
||||
describe '#cache_collection' do
|
||||
context 'given an empty array' do
|
||||
context 'when given an empty array' do
|
||||
it 'returns an empty array' do
|
||||
get :empty_array
|
||||
expect(response.body).to eq '0'
|
||||
end
|
||||
end
|
||||
|
||||
context 'given an empty relation' do
|
||||
context 'when given an empty relation' do
|
||||
it 'returns an empty array' do
|
||||
get :empty_relation
|
||||
expect(response.body).to eq '0'
|
||||
|
|
|
@ -31,7 +31,7 @@ RSpec.describe ChallengableConcern, type: :controller do
|
|||
sign_in user
|
||||
end
|
||||
|
||||
context 'for GET requests' do
|
||||
context 'with GET requests' do
|
||||
before { get :foo }
|
||||
|
||||
it 'does not ask for password' do
|
||||
|
@ -39,7 +39,7 @@ RSpec.describe ChallengableConcern, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for POST requests' do
|
||||
context 'with POST requests' do
|
||||
before { post :bar }
|
||||
|
||||
it 'does not ask for password' do
|
||||
|
@ -56,7 +56,7 @@ RSpec.describe ChallengableConcern, type: :controller do
|
|||
sign_in user
|
||||
end
|
||||
|
||||
context 'for GET requests' do
|
||||
context 'with GET requests' do
|
||||
before { get :foo, session: { challenge_passed_at: Time.now.utc } }
|
||||
|
||||
it 'does not ask for password' do
|
||||
|
@ -64,7 +64,7 @@ RSpec.describe ChallengableConcern, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for POST requests' do
|
||||
context 'with POST requests' do
|
||||
before { post :bar, session: { challenge_passed_at: Time.now.utc } }
|
||||
|
||||
it 'does not ask for password' do
|
||||
|
@ -81,7 +81,7 @@ RSpec.describe ChallengableConcern, type: :controller do
|
|||
sign_in user
|
||||
end
|
||||
|
||||
context 'for GET requests' do
|
||||
context 'with GET requests' do
|
||||
before { get :foo }
|
||||
|
||||
it 'renders challenge' do
|
||||
|
@ -91,7 +91,7 @@ RSpec.describe ChallengableConcern, type: :controller do
|
|||
# See Auth::ChallengesControllerSpec
|
||||
end
|
||||
|
||||
context 'for POST requests' do
|
||||
context 'with POST requests' do
|
||||
before { post :bar }
|
||||
|
||||
it 'renders challenge' do
|
||||
|
|
|
@ -41,7 +41,7 @@ describe ApplicationController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'user with valid locale has signed in' do
|
||||
context 'with a user with valid locale has signed in' do
|
||||
it "sets user's locale" do
|
||||
user = Fabricate(:user, locale: :ca)
|
||||
|
||||
|
@ -52,7 +52,7 @@ describe ApplicationController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'user with invalid locale has signed in' do
|
||||
context 'with a user with invalid locale has signed in' do
|
||||
before do
|
||||
user = Fabricate.build(:user, locale: :invalid)
|
||||
user.save!(validate: false)
|
||||
|
@ -62,7 +62,7 @@ describe ApplicationController, type: :controller do
|
|||
include_examples 'default locale'
|
||||
end
|
||||
|
||||
context 'user has not signed in' do
|
||||
context 'with a user who has not signed in' do
|
||||
include_examples 'default locale'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe ApplicationController do
|
|||
end
|
||||
|
||||
describe 'rate limiting' do
|
||||
context 'throttling is off' do
|
||||
context 'when throttling is off' do
|
||||
before do
|
||||
request.env['rack.attack.throttle_data'] = nil
|
||||
end
|
||||
|
@ -30,7 +30,7 @@ describe ApplicationController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'throttling is on' do
|
||||
context 'when throttling is on' do
|
||||
let(:start_time) { DateTime.new(2017, 1, 1, 12, 0, 0).utc }
|
||||
|
||||
before do
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe InstanceActorsController, type: :controller do
|
||||
describe 'GET #show' do
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
shared_examples 'shared behavior' do
|
||||
|
|
|
@ -50,7 +50,7 @@ describe Settings::ApplicationsController do
|
|||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'success (passed scopes as a String)' do
|
||||
context 'when success (passed scopes as a String)' do
|
||||
def call_create
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
|
@ -72,7 +72,7 @@ describe Settings::ApplicationsController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'success (passed scopes as an Array)' do
|
||||
context 'when success (passed scopes as an Array)' do
|
||||
def call_create
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
|
@ -94,7 +94,7 @@ describe Settings::ApplicationsController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'failure' do
|
||||
context 'with failure request' do
|
||||
before do
|
||||
post :create, params: {
|
||||
doorkeeper_application: {
|
||||
|
@ -117,7 +117,7 @@ describe Settings::ApplicationsController do
|
|||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
context 'success' do
|
||||
context 'when success' do
|
||||
let(:opts) do
|
||||
{
|
||||
website: 'https://foo.bar/',
|
||||
|
@ -142,7 +142,7 @@ describe Settings::ApplicationsController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'failure' do
|
||||
context 'with failure request' do
|
||||
before do
|
||||
patch :update, params: {
|
||||
id: app.id,
|
||||
|
|
|
@ -275,7 +275,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
|
|||
end
|
||||
|
||||
context 'when user have not enabled webauthn' do
|
||||
context 'creation succeeds' do
|
||||
context 'when creation succeeds' do
|
||||
it 'creates a webauthn credential' do
|
||||
@controller.session[:webauthn_challenge] = challenge
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -97,7 +97,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -132,7 +132,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -140,7 +140,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -156,7 +156,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -164,7 +164,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -196,7 +196,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -221,7 +221,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -260,7 +260,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -285,7 +285,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -320,7 +320,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -328,7 +328,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -347,7 +347,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -372,7 +372,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -407,7 +407,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -415,7 +415,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -460,7 +460,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -485,7 +485,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -522,7 +522,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -547,7 +547,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -582,7 +582,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -590,7 +590,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -609,7 +609,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -634,7 +634,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http success' do
|
||||
|
@ -669,7 +669,7 @@ describe StatusesController do
|
|||
get :show, params: { account_username: status.account.username, id: status.id, format: format }
|
||||
end
|
||||
|
||||
context 'as JSON' do
|
||||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
@ -677,7 +677,7 @@ describe StatusesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as HTML' do
|
||||
context 'with HTML' do
|
||||
let(:format) { 'html' }
|
||||
|
||||
it 'returns http not found' do
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe Admin::AccountModerationNotesHelper, type: :helper do
|
|||
include AccountsHelper
|
||||
|
||||
describe '#admin_account_link_to' do
|
||||
context 'account is nil' do
|
||||
context 'when Account is nil' do
|
||||
let(:account) { nil }
|
||||
|
||||
it 'returns nil' do
|
||||
|
@ -30,7 +30,7 @@ RSpec.describe Admin::AccountModerationNotesHelper, type: :helper do
|
|||
end
|
||||
|
||||
describe '#admin_account_inline_link_to' do
|
||||
context 'account is nil' do
|
||||
context 'when Account is nil' do
|
||||
let(:account) { nil }
|
||||
|
||||
it 'returns nil' do
|
||||
|
|
|
@ -22,14 +22,14 @@ describe JsonLdHelper do
|
|||
end
|
||||
|
||||
describe '#first_of_value' do
|
||||
context 'value.is_a?(Array)' do
|
||||
context 'when value.is_a?(Array)' do
|
||||
it 'returns value.first' do
|
||||
value = ['a']
|
||||
expect(helper.first_of_value(value)).to be 'a'
|
||||
end
|
||||
end
|
||||
|
||||
context '!value.is_a?(Array)' do
|
||||
context 'with !value.is_a?(Array)' do
|
||||
it 'returns value' do
|
||||
value = 'a'
|
||||
expect(helper.first_of_value(value)).to be 'a'
|
||||
|
@ -38,14 +38,14 @@ describe JsonLdHelper do
|
|||
end
|
||||
|
||||
describe '#supported_context?' do
|
||||
context "!json.nil? && equals_or_includes?(json['@context'], ActivityPub::TagManager::CONTEXT)" do
|
||||
context 'when json is present and in an activitypub tagmanager context' do
|
||||
it 'returns true' do
|
||||
json = { '@context' => ActivityPub::TagManager::CONTEXT }.as_json
|
||||
expect(helper.supported_context?(json)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'else' do
|
||||
context 'when not in activitypub tagmanager context' do
|
||||
it 'returns false' do
|
||||
json = nil
|
||||
expect(helper.supported_context?(json)).to be false
|
||||
|
@ -90,7 +90,7 @@ describe JsonLdHelper do
|
|||
end
|
||||
end
|
||||
|
||||
context 'compaction and forwarding' do
|
||||
context 'with compaction and forwarding' do
|
||||
let(:json) do
|
||||
{
|
||||
'@context' => [
|
||||
|
|
|
@ -24,7 +24,7 @@ RSpec.describe RoutingHelper, type: :helper do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Do not use S3' do
|
||||
context 'when not using S3' do
|
||||
before do
|
||||
Rails.configuration.x.use_s3 = false
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ RSpec.describe RoutingHelper, type: :helper do
|
|||
it_behaves_like 'returns full path URL'
|
||||
end
|
||||
|
||||
context 'Use S3' do
|
||||
context 'when using S3' do
|
||||
before do
|
||||
Rails.configuration.x.use_s3 = true
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe ActivityPub::Activity::Accept do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a relay' do
|
||||
context 'when given a relay' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
|
||||
|
|
|
@ -39,7 +39,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
subject.perform
|
||||
end
|
||||
|
||||
context 'a known status' do
|
||||
context 'with known status' do
|
||||
let(:object_json) do
|
||||
ActivityPub::TagManager.instance.uri_for(status)
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
end
|
||||
end
|
||||
|
||||
context 'an unknown status' do
|
||||
context 'with unknown status' do
|
||||
let(:object_json) { 'https://example.com/actor/hello-world' }
|
||||
|
||||
it 'creates a reblog by sender of status' do
|
||||
|
@ -60,7 +60,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
end
|
||||
end
|
||||
|
||||
context 'self-boost of a previously unknown status with correct attributedTo' do
|
||||
context 'when self-boost of a previously unknown status with correct attributedTo' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: 'https://example.com/actor#bar',
|
||||
|
@ -76,7 +76,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
end
|
||||
end
|
||||
|
||||
context 'self-boost of a previously unknown status with correct attributedTo, inlined Collection in audience' do
|
||||
context 'when self-boost of a previously unknown status with correct attributedTo, inlined Collection in audience' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: 'https://example.com/actor#bar',
|
||||
|
@ -123,7 +123,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json))
|
||||
end
|
||||
|
||||
context 'and the relay is enabled' do
|
||||
context 'when the relay is enabled' do
|
||||
before do
|
||||
relay.update(state: :accepted)
|
||||
subject.perform
|
||||
|
@ -135,7 +135,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
|||
end
|
||||
end
|
||||
|
||||
context 'and the relay is disabled' do
|
||||
context 'when the relay is disabled' do
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
subject.perform
|
||||
end
|
||||
|
||||
context 'object has been edited' do
|
||||
context 'when object has been edited' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -57,7 +57,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'object has update date equal to creation date' do
|
||||
context 'when object has update date equal to creation date' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -83,7 +83,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'unknown object type' do
|
||||
context 'with an unknown object type' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -97,7 +97,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'standalone' do
|
||||
context 'with a standalone' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -121,7 +121,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'public with explicit public address' do
|
||||
context 'when public with explicit public address' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -139,7 +139,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'public with as:Public' do
|
||||
context 'when public with as:Public' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -157,7 +157,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'public with Public' do
|
||||
context 'when public with Public' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -175,7 +175,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'unlisted with explicit public address' do
|
||||
context 'when unlisted with explicit public address' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -193,7 +193,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'unlisted with as:Public' do
|
||||
context 'when unlisted with as:Public' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -211,7 +211,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'unlisted with Public' do
|
||||
context 'when unlisted with Public' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -229,7 +229,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'private' do
|
||||
context 'when private' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -247,7 +247,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'private with inlined Collection in audience' do
|
||||
context 'when private with inlined Collection in audience' do
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
|
@ -269,7 +269,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'limited' do
|
||||
context 'when limited' do
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
|
||||
let(:object_json) do
|
||||
|
@ -294,7 +294,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'direct' do
|
||||
context 'when direct' do
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
|
||||
let(:object_json) do
|
||||
|
@ -318,7 +318,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
end
|
||||
end
|
||||
|
||||
context 'as a reply' do
|
||||
context 'with a reply' do
|
||||
let(:original_status) { Fabricate(:status) }
|
||||
|
||||
let(:object_json) do
|
||||
|
|
|
@ -20,7 +20,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
subject { described_class.new(json, sender) }
|
||||
|
||||
context 'with no prior follow' do
|
||||
context 'unlocked account' do
|
||||
context 'with an unlocked account' do
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'silenced account following an unlocked account' do
|
||||
context 'when silenced account following an unlocked account' do
|
||||
before do
|
||||
sender.touch(:silenced_at)
|
||||
subject.perform
|
||||
|
@ -51,7 +51,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'unlocked account muting the sender' do
|
||||
context 'with an unlocked account muting the sender' do
|
||||
before do
|
||||
recipient.mute!(sender)
|
||||
subject.perform
|
||||
|
@ -67,7 +67,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'locked account' do
|
||||
context 'when locked account' do
|
||||
before do
|
||||
recipient.update(locked: true)
|
||||
subject.perform
|
||||
|
@ -89,7 +89,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
sender.active_relationships.create!(target_account: recipient, uri: 'bar')
|
||||
end
|
||||
|
||||
context 'unlocked account' do
|
||||
context 'with an unlocked account' do
|
||||
before do
|
||||
subject.perform
|
||||
end
|
||||
|
@ -103,7 +103,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'silenced account following an unlocked account' do
|
||||
context 'when silenced account following an unlocked account' do
|
||||
before do
|
||||
sender.touch(:silenced_at)
|
||||
subject.perform
|
||||
|
@ -118,7 +118,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'unlocked account muting the sender' do
|
||||
context 'with an unlocked account muting the sender' do
|
||||
before do
|
||||
recipient.mute!(sender)
|
||||
subject.perform
|
||||
|
@ -133,7 +133,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'locked account' do
|
||||
context 'when locked account' do
|
||||
before do
|
||||
recipient.update(locked: true)
|
||||
subject.perform
|
||||
|
@ -154,7 +154,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
sender.follow_requests.create!(target_account: recipient, uri: 'bar')
|
||||
end
|
||||
|
||||
context 'silenced account following an unlocked account' do
|
||||
context 'when silenced account following an unlocked account' do
|
||||
before do
|
||||
sender.touch(:silenced_at)
|
||||
subject.perform
|
||||
|
@ -170,7 +170,7 @@ RSpec.describe ActivityPub::Activity::Follow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'locked account' do
|
||||
context 'when locked account' do
|
||||
before do
|
||||
recipient.update(locked: true)
|
||||
subject.perform
|
||||
|
|
|
@ -27,7 +27,7 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||
describe '#perform' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
context 'rejecting a pending follow request by target' do
|
||||
context 'when rejecting a pending follow request by target' do
|
||||
before do
|
||||
Fabricate(:follow_request, account: recipient, target_account: sender)
|
||||
subject.perform
|
||||
|
@ -42,7 +42,7 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||
end
|
||||
end
|
||||
|
||||
context 'rejecting a pending follow request by uri' do
|
||||
context 'when rejecting a pending follow request by uri' do
|
||||
before do
|
||||
Fabricate(:follow_request, account: recipient, target_account: sender, uri: 'bar')
|
||||
subject.perform
|
||||
|
@ -57,7 +57,7 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||
end
|
||||
end
|
||||
|
||||
context 'rejecting a pending follow request by uri only' do
|
||||
context 'when rejecting a pending follow request by uri only' do
|
||||
let(:object_json) { 'bar' }
|
||||
|
||||
before do
|
||||
|
@ -74,7 +74,7 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||
end
|
||||
end
|
||||
|
||||
context 'rejecting an existing follow relationship by target' do
|
||||
context 'when rejecting an existing follow relationship by target' do
|
||||
before do
|
||||
Fabricate(:follow, account: recipient, target_account: sender)
|
||||
subject.perform
|
||||
|
@ -89,7 +89,7 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||
end
|
||||
end
|
||||
|
||||
context 'rejecting an existing follow relationship by uri' do
|
||||
context 'when rejecting an existing follow relationship by uri' do
|
||||
before do
|
||||
Fabricate(:follow, account: recipient, target_account: sender, uri: 'bar')
|
||||
subject.perform
|
||||
|
@ -104,7 +104,7 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||
end
|
||||
end
|
||||
|
||||
context 'rejecting an existing follow relationship by uri only' do
|
||||
context 'when rejecting an existing follow relationship by uri only' do
|
||||
let(:object_json) { 'bar' }
|
||||
|
||||
before do
|
||||
|
@ -122,7 +122,7 @@ RSpec.describe ActivityPub::Activity::Reject do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a relay' do
|
||||
context 'when given a relay' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe EmojiFormatter do
|
|||
|
||||
let(:emojis) { [emoji] }
|
||||
|
||||
context 'given text that is not marked as html-safe' do
|
||||
context 'when given text that is not marked as html-safe' do
|
||||
let(:text) { 'Foo' }
|
||||
|
||||
it 'raises an argument error' do
|
||||
|
@ -22,7 +22,7 @@ RSpec.describe EmojiFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text with an emoji shortcode at the start' do
|
||||
context 'when given text with an emoji shortcode at the start' do
|
||||
let(:text) { preformat_text(':coolcat: Beep boop') }
|
||||
|
||||
it 'converts the shortcode to an image tag' do
|
||||
|
@ -30,7 +30,7 @@ RSpec.describe EmojiFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text with an emoji shortcode in the middle' do
|
||||
context 'when given text with an emoji shortcode in the middle' do
|
||||
let(:text) { preformat_text('Beep :coolcat: boop') }
|
||||
|
||||
it 'converts the shortcode to an image tag' do
|
||||
|
@ -38,7 +38,7 @@ RSpec.describe EmojiFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text with concatenated emoji shortcodes' do
|
||||
context 'when given text with concatenated emoji shortcodes' do
|
||||
let(:text) { preformat_text(':coolcat::coolcat:') }
|
||||
|
||||
it 'does not touch the shortcodes' do
|
||||
|
@ -46,7 +46,7 @@ RSpec.describe EmojiFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text with an emoji shortcode at the end' do
|
||||
context 'when given text with an emoji shortcode at the end' do
|
||||
let(:text) { preformat_text('Beep boop :coolcat:') }
|
||||
|
||||
it 'converts the shortcode to an image tag' do
|
||||
|
|
|
@ -9,7 +9,7 @@ RSpec.describe EntityCache do
|
|||
describe '#emoji' do
|
||||
subject { EntityCache.instance.emoji(shortcodes, domain) }
|
||||
|
||||
context 'called with an empty list of shortcodes' do
|
||||
context 'when called with an empty list of shortcodes' do
|
||||
let(:shortcodes) { [] }
|
||||
let(:domain) { 'example.org' }
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ RSpec.describe FeedManager do
|
|||
let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
||||
let(:jeff) { Fabricate(:account, username: 'jeff') }
|
||||
|
||||
context 'for home feed' do
|
||||
context 'with home feed' do
|
||||
it 'returns false for followee\'s status' do
|
||||
status = Fabricate(:status, text: 'Hello world', account: alice)
|
||||
bob.follow!(alice)
|
||||
|
@ -155,7 +155,7 @@ RSpec.describe FeedManager do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for mentions feed' do
|
||||
context 'with mentions feed' do
|
||||
it 'returns true for status that mentions blocked account' do
|
||||
bob.block!(jeff)
|
||||
status = PostStatusService.new.call(alice, text: 'Hey @jeff')
|
||||
|
@ -196,7 +196,7 @@ RSpec.describe FeedManager do
|
|||
expect(redis.zcard("feed:home:#{account.id}")).to eq FeedManager::MAX_ITEMS
|
||||
end
|
||||
|
||||
context 'reblogs' do
|
||||
context 'with reblogs' do
|
||||
it 'saves reblogs of unseen statuses' do
|
||||
account = Fabricate(:account)
|
||||
reblogged = Fabricate(:status)
|
||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe HtmlAwareFormatter do
|
|||
context 'when remote' do
|
||||
let(:local) { false }
|
||||
|
||||
context 'given plain text' do
|
||||
context 'when given plain text' do
|
||||
let(:text) { 'Beep boop' }
|
||||
|
||||
it 'keeps the plain text' do
|
||||
|
@ -26,7 +26,7 @@ RSpec.describe HtmlAwareFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing script tags' do
|
||||
context 'when given text containing script tags' do
|
||||
let(:text) { '<script>alert("Hello")</script>' }
|
||||
|
||||
it 'strips the scripts' do
|
||||
|
@ -34,7 +34,7 @@ RSpec.describe HtmlAwareFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing malicious classes' do
|
||||
context 'when given text containing malicious classes' do
|
||||
let(:text) { '<span class="mention status__content__spoiler-link">Show more</span>' }
|
||||
|
||||
it 'strips the malicious classes' do
|
||||
|
|
|
@ -40,7 +40,7 @@ RSpec.describe LinkDetailsExtractor do
|
|||
context 'when structured data is present' do
|
||||
let(:original_url) { 'https://example.com/page.html' }
|
||||
|
||||
context 'and is wrapped in CDATA tags' do
|
||||
context 'when is wrapped in CDATA tags' do
|
||||
let(:html) { <<~HTML }
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
@ -79,7 +79,7 @@ RSpec.describe LinkDetailsExtractor do
|
|||
end
|
||||
end
|
||||
|
||||
context 'but the first tag is invalid JSON' do
|
||||
context 'with the first tag is invalid JSON' do
|
||||
let(:html) { <<~HTML }
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
|
|
@ -40,7 +40,7 @@ describe OStatus::TagManager do
|
|||
describe '#uri_for' do
|
||||
subject { OStatus::TagManager.instance.uri_for(target) }
|
||||
|
||||
context 'comment object' do
|
||||
context 'with comment object' do
|
||||
let(:target) { Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reply: true) }
|
||||
|
||||
it 'returns the unique tag for status' do
|
||||
|
@ -49,7 +49,7 @@ describe OStatus::TagManager do
|
|||
end
|
||||
end
|
||||
|
||||
context 'note object' do
|
||||
context 'with note object' do
|
||||
let(:target) { Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reply: false, thread: nil) }
|
||||
|
||||
it 'returns the unique tag for status' do
|
||||
|
@ -58,7 +58,7 @@ describe OStatus::TagManager do
|
|||
end
|
||||
end
|
||||
|
||||
context 'person object' do
|
||||
context 'when person object' do
|
||||
let(:target) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
it 'returns the URL for account' do
|
||||
|
|
|
@ -20,67 +20,67 @@ describe ScopeTransformer do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for scope "read"' do
|
||||
context 'with scope "read"' do
|
||||
let(:input) { 'read' }
|
||||
|
||||
it_behaves_like 'a scope', nil, 'all', 'read'
|
||||
end
|
||||
|
||||
context 'for scope "write"' do
|
||||
context 'with scope "write"' do
|
||||
let(:input) { 'write' }
|
||||
|
||||
it_behaves_like 'a scope', nil, 'all', 'write'
|
||||
end
|
||||
|
||||
context 'for scope "follow"' do
|
||||
context 'with scope "follow"' do
|
||||
let(:input) { 'follow' }
|
||||
|
||||
it_behaves_like 'a scope', nil, 'follow', 'read/write'
|
||||
end
|
||||
|
||||
context 'for scope "crypto"' do
|
||||
context 'with scope "crypto"' do
|
||||
let(:input) { 'crypto' }
|
||||
|
||||
it_behaves_like 'a scope', nil, 'crypto', 'read/write'
|
||||
end
|
||||
|
||||
context 'for scope "push"' do
|
||||
context 'with scope "push"' do
|
||||
let(:input) { 'push' }
|
||||
|
||||
it_behaves_like 'a scope', nil, 'push', 'read/write'
|
||||
end
|
||||
|
||||
context 'for scope "admin:read"' do
|
||||
context 'with scope "admin:read"' do
|
||||
let(:input) { 'admin:read' }
|
||||
|
||||
it_behaves_like 'a scope', 'admin', 'all', 'read'
|
||||
end
|
||||
|
||||
context 'for scope "admin:write"' do
|
||||
context 'with scope "admin:write"' do
|
||||
let(:input) { 'admin:write' }
|
||||
|
||||
it_behaves_like 'a scope', 'admin', 'all', 'write'
|
||||
end
|
||||
|
||||
context 'for scope "admin:read:accounts"' do
|
||||
context 'with scope "admin:read:accounts"' do
|
||||
let(:input) { 'admin:read:accounts' }
|
||||
|
||||
it_behaves_like 'a scope', 'admin', 'accounts', 'read'
|
||||
end
|
||||
|
||||
context 'for scope "admin:write:accounts"' do
|
||||
context 'with scope "admin:write:accounts"' do
|
||||
let(:input) { 'admin:write:accounts' }
|
||||
|
||||
it_behaves_like 'a scope', 'admin', 'accounts', 'write'
|
||||
end
|
||||
|
||||
context 'for scope "read:accounts"' do
|
||||
context 'with scope "read:accounts"' do
|
||||
let(:input) { 'read:accounts' }
|
||||
|
||||
it_behaves_like 'a scope', nil, 'accounts', 'read'
|
||||
end
|
||||
|
||||
context 'for scope "write:accounts"' do
|
||||
context 'with scope "write:accounts"' do
|
||||
let(:input) { 'write:accounts' }
|
||||
|
||||
it_behaves_like 'a scope', nil, 'accounts', 'write'
|
||||
|
|
|
@ -44,7 +44,7 @@ describe StatusCacheHydrator do
|
|||
let(:reblog) { Fabricate(:status) }
|
||||
let(:status) { Fabricate(:status, reblog: reblog) }
|
||||
|
||||
context 'that has been favourited' do
|
||||
context 'when it has been favourited' do
|
||||
before do
|
||||
FavouriteService.new.call(account, reblog)
|
||||
end
|
||||
|
@ -54,7 +54,7 @@ describe StatusCacheHydrator do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that has been reblogged' do
|
||||
context 'when it has been reblogged' do
|
||||
before do
|
||||
ReblogService.new.call(account, reblog)
|
||||
end
|
||||
|
@ -64,7 +64,7 @@ describe StatusCacheHydrator do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that has been pinned' do
|
||||
context 'when it has been pinned' do
|
||||
let(:reblog) { Fabricate(:status, account: account) }
|
||||
|
||||
before do
|
||||
|
@ -76,7 +76,7 @@ describe StatusCacheHydrator do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that has been followed tags' do
|
||||
context 'when it has been followed tags' do
|
||||
let(:followed_tag) { Fabricate(:tag) }
|
||||
|
||||
before do
|
||||
|
@ -90,7 +90,7 @@ describe StatusCacheHydrator do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that has a poll authored by the user' do
|
||||
context 'when it has a poll authored by the user' do
|
||||
let(:poll) { Fabricate(:poll, account: account) }
|
||||
let(:reblog) { Fabricate(:status, poll: poll, account: account) }
|
||||
|
||||
|
@ -99,7 +99,7 @@ describe StatusCacheHydrator do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that has been voted in' do
|
||||
context 'when it has been voted in' do
|
||||
let(:poll) { Fabricate(:poll, options: %w(Yellow Blue)) }
|
||||
let(:reblog) { Fabricate(:status, poll: poll) }
|
||||
|
||||
|
@ -112,7 +112,7 @@ describe StatusCacheHydrator do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that matches account filters' do
|
||||
context 'when it matches account filters' do
|
||||
let(:reblog) { Fabricate(:status, text: 'this toot is about that banned word') }
|
||||
|
||||
before do
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
describe StatusReachFinder do
|
||||
describe '#inboxes' do
|
||||
context 'for a local status' do
|
||||
context 'with a local status' do
|
||||
subject { described_class.new(status) }
|
||||
|
||||
let(:parent_status) { nil }
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe TextFormatter do
|
|||
|
||||
let(:preloaded_accounts) { nil }
|
||||
|
||||
context 'given text containing plain text' do
|
||||
context 'when given text containing plain text' do
|
||||
let(:text) { 'text' }
|
||||
|
||||
it 'paragraphizes the text' do
|
||||
|
@ -16,7 +16,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing line feeds' do
|
||||
context 'when given text containing line feeds' do
|
||||
let(:text) { "line\nfeed" }
|
||||
|
||||
it 'removes line feeds' do
|
||||
|
@ -24,7 +24,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing linkable mentions' do
|
||||
context 'when given text containing linkable mentions' do
|
||||
let(:preloaded_accounts) { [Fabricate(:account, username: 'alice')] }
|
||||
let(:text) { '@alice' }
|
||||
|
||||
|
@ -33,7 +33,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing unlinkable mentions' do
|
||||
context 'when given text containing unlinkable mentions' do
|
||||
let(:preloaded_accounts) { [] }
|
||||
let(:text) { '@alice' }
|
||||
|
||||
|
@ -42,7 +42,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a stand-alone medium URL' do
|
||||
context 'when given a stand-alone medium URL' do
|
||||
let(:text) { 'https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -50,7 +50,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a stand-alone google URL' do
|
||||
context 'when given a stand-alone google URL' do
|
||||
let(:text) { 'http://google.com' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -58,7 +58,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a stand-alone URL with a newer TLD' do
|
||||
context 'when given a stand-alone URL with a newer TLD' do
|
||||
let(:text) { 'http://example.gay' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -66,7 +66,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a stand-alone IDN URL' do
|
||||
context 'when given a stand-alone IDN URL' do
|
||||
let(:text) { 'https://nic.みんな/' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -78,7 +78,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with a trailing period' do
|
||||
context 'when given a URL with a trailing period' do
|
||||
let(:text) { 'http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona. ' }
|
||||
|
||||
it 'matches the full URL but not the period' do
|
||||
|
@ -86,7 +86,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL enclosed with parentheses' do
|
||||
context 'when given a URL enclosed with parentheses' do
|
||||
let(:text) { '(http://google.com/)' }
|
||||
|
||||
it 'matches the full URL but not the parentheses' do
|
||||
|
@ -94,7 +94,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with a trailing exclamation point' do
|
||||
context 'when given a URL with a trailing exclamation point' do
|
||||
let(:text) { 'http://www.google.com!' }
|
||||
|
||||
it 'matches the full URL but not the exclamation point' do
|
||||
|
@ -102,7 +102,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with a trailing single quote' do
|
||||
context 'when given a URL with a trailing single quote' do
|
||||
let(:text) { "http://www.google.com'" }
|
||||
|
||||
it 'matches the full URL but not the single quote' do
|
||||
|
@ -110,7 +110,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with a trailing angle bracket' do
|
||||
context 'when given a URL with a trailing angle bracket' do
|
||||
let(:text) { 'http://www.google.com>' }
|
||||
|
||||
it 'matches the full URL but not the angle bracket' do
|
||||
|
@ -118,7 +118,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with a query string' do
|
||||
context 'when given a URL with a query string' do
|
||||
context 'with escaped unicode character' do
|
||||
let(:text) { 'https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=autolink' }
|
||||
|
||||
|
@ -152,7 +152,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with parentheses in it' do
|
||||
context 'when given a URL with parentheses in it' do
|
||||
let(:text) { 'https://en.wikipedia.org/wiki/Diaspora_(software)' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -160,7 +160,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL in quotation marks' do
|
||||
context 'when given a URL in quotation marks' do
|
||||
let(:text) { '"https://example.com/"' }
|
||||
|
||||
it 'does not match the quotation marks' do
|
||||
|
@ -168,7 +168,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL in angle brackets' do
|
||||
context 'when given a URL in angle brackets' do
|
||||
let(:text) { '<https://example.com/>' }
|
||||
|
||||
it 'does not match the angle brackets' do
|
||||
|
@ -176,7 +176,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with Japanese path string' do
|
||||
context 'when given a URL with Japanese path string' do
|
||||
let(:text) { 'https://ja.wikipedia.org/wiki/日本' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -184,7 +184,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with Korean path string' do
|
||||
context 'when given a URL with Korean path string' do
|
||||
let(:text) { 'https://ko.wikipedia.org/wiki/대한민국' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -192,7 +192,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with a full-width space' do
|
||||
context 'when given a URL with a full-width space' do
|
||||
let(:text) { 'https://example.com/ abc123' }
|
||||
|
||||
it 'does not match the full-width space' do
|
||||
|
@ -200,7 +200,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL in Japanese quotation marks' do
|
||||
context 'when given a URL in Japanese quotation marks' do
|
||||
let(:text) { '「[https://example.org/」' }
|
||||
|
||||
it 'does not match the quotation marks' do
|
||||
|
@ -208,7 +208,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with Simplified Chinese path string' do
|
||||
context 'when given a URL with Simplified Chinese path string' do
|
||||
let(:text) { 'https://baike.baidu.com/item/中华人民共和国' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -216,7 +216,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL with Traditional Chinese path string' do
|
||||
context 'when given a URL with Traditional Chinese path string' do
|
||||
let(:text) { 'https://zh.wikipedia.org/wiki/臺灣' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -224,7 +224,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL containing unsafe code (XSS attack, visible part)' do
|
||||
context 'when given a URL containing unsafe code (XSS attack, visible part)' do
|
||||
let(:text) { 'http://example.com/b<del>b</del>' }
|
||||
|
||||
it 'does not include the HTML in the URL' do
|
||||
|
@ -236,7 +236,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a URL containing unsafe code (XSS attack, invisible part)' do
|
||||
context 'when given a URL containing unsafe code (XSS attack, invisible part)' do
|
||||
let(:text) { 'http://example.com/blahblahblahblah/a<script>alert("Hello")</script>' }
|
||||
|
||||
it 'does not include the HTML in the URL' do
|
||||
|
@ -248,7 +248,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing HTML code (script tag)' do
|
||||
context 'when given text containing HTML code (script tag)' do
|
||||
let(:text) { '<script>alert("Hello")</script>' }
|
||||
|
||||
it 'escapes the HTML' do
|
||||
|
@ -256,7 +256,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing HTML (XSS attack)' do
|
||||
context 'when given text containing HTML (XSS attack)' do
|
||||
let(:text) { %q{<img src="javascript:alert('XSS');">} }
|
||||
|
||||
it 'escapes the HTML' do
|
||||
|
@ -264,7 +264,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given an invalid URL' do
|
||||
context 'when given an invalid URL' do
|
||||
let(:text) { 'http://www\.google\.com' }
|
||||
|
||||
it 'outputs the raw URL' do
|
||||
|
@ -272,7 +272,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing a hashtag' do
|
||||
context 'when given text containing a hashtag' do
|
||||
let(:text) { '#hashtag' }
|
||||
|
||||
it 'creates a hashtag link' do
|
||||
|
@ -280,7 +280,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing a hashtag with Unicode chars' do
|
||||
context 'when given text containing a hashtag with Unicode chars' do
|
||||
let(:text) { '#hashtagタグ' }
|
||||
|
||||
it 'creates a hashtag link' do
|
||||
|
@ -288,7 +288,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text with a stand-alone xmpp: URI' do
|
||||
context 'when given text with a stand-alone xmpp: URI' do
|
||||
let(:text) { 'xmpp:user@instance.com' }
|
||||
|
||||
it 'matches the full URI' do
|
||||
|
@ -296,7 +296,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text with an xmpp: URI with a query-string' do
|
||||
context 'when given text with an xmpp: URI with a query-string' do
|
||||
let(:text) { 'please join xmpp:muc@instance.com?join right now' }
|
||||
|
||||
it 'matches the full URI' do
|
||||
|
@ -304,7 +304,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given text containing a magnet: URI' do
|
||||
context 'when given text containing a magnet: URI' do
|
||||
let(:text) { 'wikipedia gives this example of a magnet uri: magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a' }
|
||||
|
||||
it 'matches the full URI' do
|
||||
|
|
|
@ -49,10 +49,10 @@ RSpec.describe Account::Field, type: :model do
|
|||
|
||||
let(:account) { double('Account', local?: local) }
|
||||
|
||||
context 'for local accounts' do
|
||||
context 'with local accounts' do
|
||||
let(:local) { true }
|
||||
|
||||
context 'for a URL with misleading authentication' do
|
||||
context 'with a URL with misleading authentication' do
|
||||
let(:value) { 'https://spacex.com @h.43z.one' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -60,7 +60,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for a URL' do
|
||||
context 'with a URL' do
|
||||
let(:value) { 'https://example.com' }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -68,7 +68,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for an IDN URL' do
|
||||
context 'with an IDN URL' do
|
||||
let(:value) { 'https://twitter.com∕dougallj∕status∕1590357240443437057.ê.cc/twitter.html' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -76,7 +76,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for a URL with a non-normalized path' do
|
||||
context 'with a URL with a non-normalized path' do
|
||||
let(:value) { 'https://github.com/octocatxxxxxxxx/../mastodon' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -84,7 +84,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for text that is not a URL' do
|
||||
context 'with text that is not a URL' do
|
||||
let(:value) { 'Hello world' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -92,7 +92,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for text that contains a URL' do
|
||||
context 'with text that contains a URL' do
|
||||
let(:value) { 'Hello https://example.com world' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -100,7 +100,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for text which is blank' do
|
||||
context 'with text which is blank' do
|
||||
let(:value) { '' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -109,10 +109,10 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for remote accounts' do
|
||||
context 'with remote accounts' do
|
||||
let(:local) { false }
|
||||
|
||||
context 'for a link' do
|
||||
context 'with a link' do
|
||||
let(:value) { '<a href="https://www.patreon.com/mastodon" target="_blank" rel="nofollow noopener noreferrer me"><span class="invisible">https://www.</span><span class="">patreon.com/mastodon</span><span class="invisible"></span></a>' }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -120,7 +120,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for a link with misleading authentication' do
|
||||
context 'with a link with misleading authentication' do
|
||||
let(:value) { '<a href="https://google.com @h.43z.one" target="_blank" rel="nofollow noopener noreferrer me"><span class="invisible">https://</span><span class="">google.com</span><span class="invisible"> @h.43z.one</span></a>' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -128,7 +128,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for HTML that has more than just a link' do
|
||||
context 'with HTML that has more than just a link' do
|
||||
let(:value) { '<a href="https://google.com" target="_blank" rel="nofollow noopener noreferrer me"><span class="invisible">https://</span><span class="">google.com</span><span class="invisible"></span></a> @h.43z.one' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -136,7 +136,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for a link with different visible text' do
|
||||
context 'with a link with different visible text' do
|
||||
let(:value) { '<a href="https://google.com/bar">https://example.com/foo</a>' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -144,7 +144,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for text that is a URL but is not linked' do
|
||||
context 'with text that is a URL but is not linked' do
|
||||
let(:value) { 'https://example.com/foo' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -152,7 +152,7 @@ RSpec.describe Account::Field, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for text which is blank' do
|
||||
context 'with text which is blank' do
|
||||
let(:value) { '' }
|
||||
|
||||
it 'returns false' do
|
||||
|
|
|
@ -171,7 +171,7 @@ RSpec.describe Account, type: :model do
|
|||
describe '#possibly_stale?' do
|
||||
let(:account) { Fabricate(:account, last_webfingered_at: last_webfingered_at) }
|
||||
|
||||
context 'last_webfingered_at is nil' do
|
||||
context 'when last_webfingered_at is nil' do
|
||||
let(:last_webfingered_at) { nil }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -179,7 +179,7 @@ RSpec.describe Account, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'last_webfingered_at is more than 24 hours before' do
|
||||
context 'when last_webfingered_at is more than 24 hours before' do
|
||||
let(:last_webfingered_at) { 25.hours.ago }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -187,7 +187,7 @@ RSpec.describe Account, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'last_webfingered_at is less than 24 hours before' do
|
||||
context 'when last_webfingered_at is less than 24 hours before' do
|
||||
let(:last_webfingered_at) { 23.hours.ago }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -200,7 +200,7 @@ RSpec.describe Account, type: :model do
|
|||
let(:account) { Fabricate(:account, domain: domain) }
|
||||
let(:acct) { account.acct }
|
||||
|
||||
context 'domain is nil' do
|
||||
context 'when domain is nil' do
|
||||
let(:domain) { nil }
|
||||
|
||||
it 'returns nil' do
|
||||
|
@ -213,7 +213,7 @@ RSpec.describe Account, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'domain is present' do
|
||||
context 'when domain is present' do
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
it 'calls ResolveAccountService#call' do
|
||||
|
|
|
@ -20,7 +20,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
)
|
||||
end
|
||||
|
||||
context 'type is "disable"' do
|
||||
context 'when type is "disable"' do
|
||||
let(:type) { 'disable' }
|
||||
|
||||
it 'disable user' do
|
||||
|
@ -29,7 +29,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'type is "silence"' do
|
||||
context 'when type is "silence"' do
|
||||
let(:type) { 'silence' }
|
||||
|
||||
it 'silences account' do
|
||||
|
@ -38,7 +38,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'type is "suspend"' do
|
||||
context 'when type is "suspend"' do
|
||||
let(:type) { 'suspend' }
|
||||
|
||||
it 'suspends account' do
|
||||
|
@ -75,7 +75,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
describe '#report' do
|
||||
subject { account_action.report }
|
||||
|
||||
context 'report_id.present?' do
|
||||
context 'with report_id.present?' do
|
||||
before do
|
||||
account_action.report_id = Fabricate(:report).id
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context '!report_id.present?' do
|
||||
context 'with !report_id.present?' do
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
|
@ -95,7 +95,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
describe '#with_report?' do
|
||||
subject { account_action.with_report? }
|
||||
|
||||
context '!report.nil?' do
|
||||
context 'with !report.nil?' do
|
||||
before do
|
||||
account_action.report_id = Fabricate(:report).id
|
||||
end
|
||||
|
@ -105,7 +105,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context '!(!report.nil?)' do
|
||||
context 'with !(!report.nil?)' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
@ -115,7 +115,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
describe '.types_for_account' do
|
||||
subject { described_class.types_for_account(account) }
|
||||
|
||||
context 'account.local?' do
|
||||
context 'when Account.local?' do
|
||||
let(:account) { Fabricate(:account, domain: nil) }
|
||||
|
||||
it 'returns ["none", "disable", "sensitive", "silence", "suspend"]' do
|
||||
|
@ -123,7 +123,7 @@ RSpec.describe Admin::AccountAction, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context '!account.local?' do
|
||||
context 'with !account.local?' do
|
||||
let(:account) { Fabricate(:account, domain: 'hoge.com') }
|
||||
|
||||
it 'returns ["sensitive", "silence", "suspend"]' do
|
||||
|
|
|
@ -13,14 +13,14 @@ describe AccountInteractions do
|
|||
describe '.following_map' do
|
||||
subject { Account.following_map(target_account_ids, account_id) }
|
||||
|
||||
context 'account with Follow' do
|
||||
context 'when Account with Follow' do
|
||||
it 'returns { target_account_id => true }' do
|
||||
Fabricate(:follow, account: account, target_account: target_account)
|
||||
expect(subject).to eq(target_account_id => { reblogs: true, notify: false, languages: nil })
|
||||
end
|
||||
end
|
||||
|
||||
context 'account without Follow' do
|
||||
context 'when Account without Follow' do
|
||||
it 'returns {}' do
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
|
@ -30,14 +30,14 @@ describe AccountInteractions do
|
|||
describe '.followed_by_map' do
|
||||
subject { Account.followed_by_map(target_account_ids, account_id) }
|
||||
|
||||
context 'account with Follow' do
|
||||
context 'when Account with Follow' do
|
||||
it 'returns { target_account_id => true }' do
|
||||
Fabricate(:follow, account: target_account, target_account: account)
|
||||
expect(subject).to eq(target_account_id => true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'account without Follow' do
|
||||
context 'when Account without Follow' do
|
||||
it 'returns {}' do
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
|
@ -47,14 +47,14 @@ describe AccountInteractions do
|
|||
describe '.blocking_map' do
|
||||
subject { Account.blocking_map(target_account_ids, account_id) }
|
||||
|
||||
context 'account with Block' do
|
||||
context 'when Account with Block' do
|
||||
it 'returns { target_account_id => true }' do
|
||||
Fabricate(:block, account: account, target_account: target_account)
|
||||
expect(subject).to eq(target_account_id => true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'account without Block' do
|
||||
context 'when Account without Block' do
|
||||
it 'returns {}' do
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
|
@ -64,12 +64,12 @@ describe AccountInteractions do
|
|||
describe '.muting_map' do
|
||||
subject { Account.muting_map(target_account_ids, account_id) }
|
||||
|
||||
context 'account with Mute' do
|
||||
context 'when Account with Mute' do
|
||||
before do
|
||||
Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
|
||||
end
|
||||
|
||||
context 'if Mute#hide_notifications?' do
|
||||
context 'when Mute#hide_notifications?' do
|
||||
let(:hide) { true }
|
||||
|
||||
it 'returns { target_account_id => { notifications: true } }' do
|
||||
|
@ -77,7 +77,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'unless Mute#hide_notifications?' do
|
||||
context 'when not Mute#hide_notifications?' do
|
||||
let(:hide) { false }
|
||||
|
||||
it 'returns { target_account_id => { notifications: false } }' do
|
||||
|
@ -86,7 +86,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'account without Mute' do
|
||||
context 'when Account without Mute' do
|
||||
it 'returns {}' do
|
||||
expect(subject).to eq({})
|
||||
end
|
||||
|
@ -112,8 +112,8 @@ describe AccountInteractions do
|
|||
describe '#mute!' do
|
||||
subject { account.mute!(target_account, notifications: arg_notifications) }
|
||||
|
||||
context 'Mute does not exist yet' do
|
||||
context 'arg :notifications is nil' do
|
||||
context 'when Mute does not exist yet' do
|
||||
context 'when arg :notifications is nil' do
|
||||
let(:arg_notifications) { nil }
|
||||
|
||||
it 'creates Mute, and returns Mute' do
|
||||
|
@ -123,7 +123,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'arg :notifications is false' do
|
||||
context 'when arg :notifications is false' do
|
||||
let(:arg_notifications) { false }
|
||||
|
||||
it 'creates Mute, and returns Mute' do
|
||||
|
@ -133,7 +133,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'arg :notifications is true' do
|
||||
context 'when arg :notifications is true' do
|
||||
let(:arg_notifications) { true }
|
||||
|
||||
it 'creates Mute, and returns Mute' do
|
||||
|
@ -144,7 +144,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Mute already exists' do
|
||||
context 'when Mute already exists' do
|
||||
before do
|
||||
account.mute_relationships << mute
|
||||
end
|
||||
|
@ -156,10 +156,10 @@ describe AccountInteractions do
|
|||
hide_notifications: hide_notifications)
|
||||
end
|
||||
|
||||
context 'mute.hide_notifications is true' do
|
||||
context 'when mute.hide_notifications is true' do
|
||||
let(:hide_notifications) { true }
|
||||
|
||||
context 'arg :notifications is nil' do
|
||||
context 'when arg :notifications is nil' do
|
||||
let(:arg_notifications) { nil }
|
||||
|
||||
it 'returns Mute without updating mute.hide_notifications' do
|
||||
|
@ -169,7 +169,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'arg :notifications is false' do
|
||||
context 'when arg :notifications is false' do
|
||||
let(:arg_notifications) { false }
|
||||
|
||||
it 'returns Mute, and updates mute.hide_notifications false' do
|
||||
|
@ -179,7 +179,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'arg :notifications is true' do
|
||||
context 'when arg :notifications is true' do
|
||||
let(:arg_notifications) { true }
|
||||
|
||||
it 'returns Mute without updating mute.hide_notifications' do
|
||||
|
@ -190,10 +190,10 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'mute.hide_notifications is false' do
|
||||
context 'when mute.hide_notifications is false' do
|
||||
let(:hide_notifications) { false }
|
||||
|
||||
context 'arg :notifications is nil' do
|
||||
context 'when arg :notifications is nil' do
|
||||
let(:arg_notifications) { nil }
|
||||
|
||||
it 'returns Mute, and updates mute.hide_notifications true' do
|
||||
|
@ -203,7 +203,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'arg :notifications is false' do
|
||||
context 'when arg :notifications is false' do
|
||||
let(:arg_notifications) { false }
|
||||
|
||||
it 'returns Mute without updating mute.hide_notifications' do
|
||||
|
@ -213,7 +213,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'arg :notifications is true' do
|
||||
context 'when arg :notifications is true' do
|
||||
let(:arg_notifications) { true }
|
||||
|
||||
it 'returns Mute, and updates mute.hide_notifications true' do
|
||||
|
@ -253,7 +253,7 @@ describe AccountInteractions do
|
|||
describe '#unfollow!' do
|
||||
subject { account.unfollow!(target_account) }
|
||||
|
||||
context 'following target_account' do
|
||||
context 'when following target_account' do
|
||||
it 'returns destroyed Follow' do
|
||||
account.active_relationships.create(target_account: target_account)
|
||||
expect(subject).to be_a Follow
|
||||
|
@ -261,7 +261,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not following target_account' do
|
||||
context 'when not following target_account' do
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
|
@ -271,7 +271,7 @@ describe AccountInteractions do
|
|||
describe '#unblock!' do
|
||||
subject { account.unblock!(target_account) }
|
||||
|
||||
context 'blocking target_account' do
|
||||
context 'when blocking target_account' do
|
||||
it 'returns destroyed Block' do
|
||||
account.block_relationships.create(target_account: target_account)
|
||||
expect(subject).to be_a Block
|
||||
|
@ -279,7 +279,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not blocking target_account' do
|
||||
context 'when not blocking target_account' do
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
|
@ -289,7 +289,7 @@ describe AccountInteractions do
|
|||
describe '#unmute!' do
|
||||
subject { account.unmute!(target_account) }
|
||||
|
||||
context 'muting target_account' do
|
||||
context 'when muting target_account' do
|
||||
it 'returns destroyed Mute' do
|
||||
account.mute_relationships.create(target_account: target_account)
|
||||
expect(subject).to be_a Mute
|
||||
|
@ -297,7 +297,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not muting target_account' do
|
||||
context 'when not muting target_account' do
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
|
@ -309,7 +309,7 @@ describe AccountInteractions do
|
|||
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
|
||||
context 'muting the conversation' do
|
||||
context 'when muting the conversation' do
|
||||
it 'returns destroyed ConversationMute' do
|
||||
account.conversation_mutes.create(conversation: conversation)
|
||||
expect(subject).to be_a ConversationMute
|
||||
|
@ -317,7 +317,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not muting the conversation' do
|
||||
context 'when not muting the conversation' do
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
|
@ -329,7 +329,7 @@ describe AccountInteractions do
|
|||
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
context 'blocking the domain' do
|
||||
context 'when blocking the domain' do
|
||||
it 'returns destroyed AccountDomainBlock' do
|
||||
account_domain_block = Fabricate(:account_domain_block, domain: domain)
|
||||
account.domain_blocks << account_domain_block
|
||||
|
@ -338,7 +338,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'unblocking the domain' do
|
||||
context 'when unblocking the domain' do
|
||||
it 'returns nil' do
|
||||
expect(subject).to be_nil
|
||||
end
|
||||
|
@ -348,14 +348,14 @@ describe AccountInteractions do
|
|||
describe '#following?' do
|
||||
subject { account.following?(target_account) }
|
||||
|
||||
context 'following target_account' do
|
||||
context 'when following target_account' do
|
||||
it 'returns true' do
|
||||
account.active_relationships.create(target_account: target_account)
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not following target_account' do
|
||||
context 'when not following target_account' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
@ -365,14 +365,14 @@ describe AccountInteractions do
|
|||
describe '#followed_by?' do
|
||||
subject { account.followed_by?(target_account) }
|
||||
|
||||
context 'followed by target_account' do
|
||||
context 'when followed by target_account' do
|
||||
it 'returns true' do
|
||||
account.passive_relationships.create(account: target_account)
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not followed by target_account' do
|
||||
context 'when not followed by target_account' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
@ -382,14 +382,14 @@ describe AccountInteractions do
|
|||
describe '#blocking?' do
|
||||
subject { account.blocking?(target_account) }
|
||||
|
||||
context 'blocking target_account' do
|
||||
context 'when blocking target_account' do
|
||||
it 'returns true' do
|
||||
account.block_relationships.create(target_account: target_account)
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not blocking target_account' do
|
||||
context 'when not blocking target_account' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
@ -401,7 +401,7 @@ describe AccountInteractions do
|
|||
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
context 'blocking the domain' do
|
||||
context 'when blocking the domain' do
|
||||
it 'returns true' do
|
||||
account_domain_block = Fabricate(:account_domain_block, domain: domain)
|
||||
account.domain_blocks << account_domain_block
|
||||
|
@ -409,7 +409,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not blocking the domain' do
|
||||
context 'when not blocking the domain' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
@ -419,7 +419,7 @@ describe AccountInteractions do
|
|||
describe '#muting?' do
|
||||
subject { account.muting?(target_account) }
|
||||
|
||||
context 'muting target_account' do
|
||||
context 'when muting target_account' do
|
||||
it 'returns true' do
|
||||
mute = Fabricate(:mute, account: account, target_account: target_account)
|
||||
account.mute_relationships << mute
|
||||
|
@ -427,7 +427,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not muting target_account' do
|
||||
context 'when not muting target_account' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
@ -439,14 +439,14 @@ describe AccountInteractions do
|
|||
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
|
||||
context 'muting the conversation' do
|
||||
context 'when muting the conversation' do
|
||||
it 'returns true' do
|
||||
account.conversation_mutes.create(conversation: conversation)
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not muting the conversation' do
|
||||
context 'when not muting the conversation' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
@ -461,7 +461,7 @@ describe AccountInteractions do
|
|||
account.mute_relationships << mute
|
||||
end
|
||||
|
||||
context 'muting notifications of target_account' do
|
||||
context 'when muting notifications of target_account' do
|
||||
let(:hide) { true }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -469,7 +469,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not muting notifications of target_account' do
|
||||
context 'when not muting notifications of target_account' do
|
||||
let(:hide) { false }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -481,14 +481,14 @@ describe AccountInteractions do
|
|||
describe '#requested?' do
|
||||
subject { account.requested?(target_account) }
|
||||
|
||||
context 'requested by target_account' do
|
||||
context 'with requested by target_account' do
|
||||
it 'returns true' do
|
||||
Fabricate(:follow_request, account: account, target_account: target_account)
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not requested by target_account' do
|
||||
context 'when not requested by target_account' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
@ -500,7 +500,7 @@ describe AccountInteractions do
|
|||
|
||||
let(:status) { Fabricate(:status, account: account, favourites: favourites) }
|
||||
|
||||
context 'favorited' do
|
||||
context 'when favorited' do
|
||||
let(:favourites) { [Fabricate(:favourite, account: account)] }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -508,7 +508,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not favorited' do
|
||||
context 'when not favorited' do
|
||||
let(:favourites) { [] }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -522,7 +522,7 @@ describe AccountInteractions do
|
|||
|
||||
let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
|
||||
|
||||
context 'reblogged' do
|
||||
context 'with reblogged' do
|
||||
let(:reblogs) { [Fabricate(:status, account: account)] }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -530,7 +530,7 @@ describe AccountInteractions do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not reblogged' do
|
||||
context 'when not reblogged' do
|
||||
let(:reblogs) { [] }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -544,14 +544,14 @@ describe AccountInteractions do
|
|||
|
||||
let(:status) { Fabricate(:status, account: account) }
|
||||
|
||||
context 'pinned' do
|
||||
context 'when pinned' do
|
||||
it 'returns true' do
|
||||
Fabricate(:status_pin, account: account, status: status)
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'not pinned' do
|
||||
context 'when not pinned' do
|
||||
it 'returns false' do
|
||||
expect(subject).to be false
|
||||
end
|
||||
|
|
|
@ -156,7 +156,7 @@ RSpec.describe Remotable do
|
|||
context 'when the response is successful' do
|
||||
let(:code) { 200 }
|
||||
|
||||
context 'and contains Content-Disposition header' do
|
||||
context 'when contains Content-Disposition header' do
|
||||
let(:file) { 'filename="foo.txt"' }
|
||||
let(:headers) { { 'content-disposition' => file } }
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ RSpec.describe CustomEmojiFilter do
|
|||
let!(:custom_emoji_1) { Fabricate(:custom_emoji, domain: 'b') }
|
||||
let!(:custom_emoji_2) { Fabricate(:custom_emoji, domain: nil, shortcode: 'hoge') }
|
||||
|
||||
context 'params have values' do
|
||||
context 'local' do
|
||||
context 'when params have values' do
|
||||
context 'when local' do
|
||||
let(:params) { { local: true } }
|
||||
|
||||
it 'returns ActiveRecord::Relation' do
|
||||
|
@ -20,7 +20,7 @@ RSpec.describe CustomEmojiFilter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'remote' do
|
||||
context 'when remote' do
|
||||
let(:params) { { remote: true } }
|
||||
|
||||
it 'returns ActiveRecord::Relation' do
|
||||
|
@ -29,7 +29,7 @@ RSpec.describe CustomEmojiFilter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'by_domain' do
|
||||
context 'with by_domain' do
|
||||
let(:params) { { by_domain: 'a' } }
|
||||
|
||||
it 'returns ActiveRecord::Relation' do
|
||||
|
@ -38,7 +38,7 @@ RSpec.describe CustomEmojiFilter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'shortcode' do
|
||||
context 'when shortcode' do
|
||||
let(:params) { { shortcode: 'hoge' } }
|
||||
|
||||
it 'returns ActiveRecord::Relation' do
|
||||
|
@ -47,7 +47,7 @@ RSpec.describe CustomEmojiFilter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'else' do
|
||||
context 'when some other case' do
|
||||
let(:params) { { else: 'else' } }
|
||||
|
||||
it 'raises Mastodon::InvalidParameterError' do
|
||||
|
@ -58,7 +58,7 @@ RSpec.describe CustomEmojiFilter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'params without value' do
|
||||
context 'when params without value' do
|
||||
let(:params) { { hoge: nil } }
|
||||
|
||||
it 'returns ActiveRecord::Relation' do
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe CustomEmoji, type: :model do
|
|||
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) }
|
||||
|
||||
context 'shortcode is exact' do
|
||||
context 'when shortcode is exact' do
|
||||
let(:shortcode) { 'blobpats' }
|
||||
let(:search_term) { 'blobpats' }
|
||||
|
||||
|
@ -17,7 +17,7 @@ RSpec.describe CustomEmoji, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'shortcode is partial' do
|
||||
context 'when shortcode is partial' do
|
||||
let(:shortcode) { 'blobpats' }
|
||||
let(:search_term) { 'blob' }
|
||||
|
||||
|
@ -32,7 +32,7 @@ RSpec.describe CustomEmoji, type: :model do
|
|||
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) }
|
||||
|
||||
context 'domain is nil' do
|
||||
context 'when domain is nil' do
|
||||
let(:domain) { nil }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -40,7 +40,7 @@ RSpec.describe CustomEmoji, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'domain is present' do
|
||||
context 'when domain is present' do
|
||||
let(:domain) { 'example.com' }
|
||||
|
||||
it 'returns false' do
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe EmailDomainBlock, type: :model do
|
|||
describe 'block?' do
|
||||
let(:input) { nil }
|
||||
|
||||
context 'given an e-mail address' do
|
||||
context 'when given an e-mail address' do
|
||||
let(:input) { "foo@#{domain}" }
|
||||
|
||||
context do
|
||||
|
@ -33,7 +33,7 @@ RSpec.describe EmailDomainBlock, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given an array of domains' do
|
||||
context 'when given an array of domains' do
|
||||
let(:input) { %w(foo.com mail.foo.com) }
|
||||
|
||||
it 'returns true if the domain is blocked' do
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe MediaAttachment, type: :model do
|
|||
|
||||
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) }
|
||||
|
||||
context 'remote_url is blank' do
|
||||
context 'when remote_url is blank' do
|
||||
let(:remote_url) { '' }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -16,7 +16,7 @@ RSpec.describe MediaAttachment, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'remote_url is present' do
|
||||
context 'when remote_url is present' do
|
||||
let(:remote_url) { 'remote_url' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -30,10 +30,10 @@ RSpec.describe MediaAttachment, type: :model do
|
|||
|
||||
let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) }
|
||||
|
||||
context 'file is blank' do
|
||||
context 'when file is blank' do
|
||||
let(:file) { nil }
|
||||
|
||||
context 'remote_url is present' do
|
||||
context 'when remote_url is present' do
|
||||
let(:remote_url) { 'remote_url' }
|
||||
|
||||
it 'returns true' do
|
||||
|
@ -42,10 +42,10 @@ RSpec.describe MediaAttachment, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'file is present' do
|
||||
context 'when file is present' do
|
||||
let(:file) { attachment_fixture('avatar.gif') }
|
||||
|
||||
context 'remote_url is blank' do
|
||||
context 'when remote_url is blank' do
|
||||
let(:remote_url) { '' }
|
||||
|
||||
it 'returns false' do
|
||||
|
@ -53,7 +53,7 @@ RSpec.describe MediaAttachment, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'remote_url is present' do
|
||||
context 'when remote_url is present' do
|
||||
let(:remote_url) { 'remote_url' }
|
||||
|
||||
it 'returns true' do
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe Notification, type: :model do
|
|||
let(:favourite) { Fabricate(:favourite, status: status) }
|
||||
let(:mention) { Fabricate(:mention, status: status) }
|
||||
|
||||
context 'activity is reblog' do
|
||||
context 'when Activity is reblog' do
|
||||
let(:activity) { reblog }
|
||||
|
||||
it 'returns status' do
|
||||
|
@ -18,7 +18,7 @@ RSpec.describe Notification, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'activity is favourite' do
|
||||
context 'when Activity is favourite' do
|
||||
let(:type) { :favourite }
|
||||
let(:activity) { favourite }
|
||||
|
||||
|
@ -27,7 +27,7 @@ RSpec.describe Notification, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'activity is mention' do
|
||||
context 'when Activity is mention' do
|
||||
let(:activity) { mention }
|
||||
|
||||
it 'returns status' do
|
||||
|
@ -66,7 +66,7 @@ RSpec.describe Notification, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'notifications are empty' do
|
||||
context 'when notifications are empty' do
|
||||
let(:notifications) { [] }
|
||||
|
||||
it 'returns []' do
|
||||
|
@ -74,7 +74,7 @@ RSpec.describe Notification, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'notifications are present' do
|
||||
context 'when notifications are present' do
|
||||
before do
|
||||
notifications.each(&:reload)
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe RemoteFollow do
|
|||
describe '.initialize' do
|
||||
subject { remote_follow.acct }
|
||||
|
||||
context 'attrs with acct' do
|
||||
context 'when attrs with acct' do
|
||||
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
||||
|
||||
it 'returns acct' do
|
||||
|
@ -21,7 +21,7 @@ RSpec.describe RemoteFollow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'attrs without acct' do
|
||||
context 'when attrs without acct' do
|
||||
let(:attrs) { {} }
|
||||
|
||||
it do
|
||||
|
@ -33,7 +33,7 @@ RSpec.describe RemoteFollow do
|
|||
describe '#valid?' do
|
||||
subject { remote_follow.valid? }
|
||||
|
||||
context 'attrs with acct' do
|
||||
context 'when attrs with acct' do
|
||||
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
||||
|
||||
it do
|
||||
|
@ -41,7 +41,7 @@ RSpec.describe RemoteFollow do
|
|||
end
|
||||
end
|
||||
|
||||
context 'attrs without acct' do
|
||||
context 'when attrs without acct' do
|
||||
let(:attrs) { {} }
|
||||
|
||||
it do
|
||||
|
|
|
@ -89,13 +89,13 @@ describe Report do
|
|||
|
||||
let(:report) { Fabricate(:report, action_taken_at: action_taken) }
|
||||
|
||||
context 'if action is taken' do
|
||||
context 'when action is taken' do
|
||||
let(:action_taken) { Time.now.utc }
|
||||
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context 'if action not is taken' do
|
||||
context 'when action not is taken' do
|
||||
let(:action_taken) { nil }
|
||||
|
||||
it { is_expected.to be true }
|
||||
|
|
|
@ -40,7 +40,7 @@ RSpec.describe SessionActivation, type: :model do
|
|||
describe '.active?' do
|
||||
subject { described_class.active?(id) }
|
||||
|
||||
context 'id is absent' do
|
||||
context 'when id is absent' do
|
||||
let(:id) { nil }
|
||||
|
||||
it 'returns nil' do
|
||||
|
@ -48,17 +48,17 @@ RSpec.describe SessionActivation, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'id is present' do
|
||||
context 'when id is present' do
|
||||
let(:id) { '1' }
|
||||
let!(:session_activation) { Fabricate(:session_activation, session_id: id) }
|
||||
|
||||
context 'id exists as session_id' do
|
||||
context 'when id exists as session_id' do
|
||||
it 'returns true' do
|
||||
expect(subject).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'id does not exist as session_id' do
|
||||
context 'when id does not exist as session_id' do
|
||||
before do
|
||||
session_activation.update!(session_id: '2')
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ RSpec.describe SessionActivation, type: :model do
|
|||
end
|
||||
|
||||
describe '.deactivate' do
|
||||
context 'id is absent' do
|
||||
context 'when id is absent' do
|
||||
let(:id) { nil }
|
||||
|
||||
it 'returns nil' do
|
||||
|
@ -93,7 +93,7 @@ RSpec.describe SessionActivation, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'id exists' do
|
||||
context 'when id exists' do
|
||||
let(:id) { '1' }
|
||||
|
||||
it 'calls where.destroy_all' do
|
||||
|
|
|
@ -19,7 +19,7 @@ RSpec.describe Setting, type: :model do
|
|||
|
||||
let(:key) { 'key' }
|
||||
|
||||
context 'rails_initialized? is falsey' do
|
||||
context 'when rails_initialized? is falsey' do
|
||||
let(:rails_initialized) { false }
|
||||
|
||||
it 'calls RailsSettings::Base#[]' do
|
||||
|
@ -28,7 +28,7 @@ RSpec.describe Setting, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'rails_initialized? is truthy' do
|
||||
context 'when rails_initialized? is truthy' do
|
||||
before do
|
||||
allow(RailsSettings::Base).to receive(:cache_key).with(key, nil).and_return(cache_key)
|
||||
end
|
||||
|
@ -42,7 +42,7 @@ RSpec.describe Setting, type: :model do
|
|||
described_class[key]
|
||||
end
|
||||
|
||||
context 'Rails.cache does not exists' do
|
||||
context 'when Rails.cache does not exists' do
|
||||
before do
|
||||
allow(RailsSettings::Settings).to receive(:object).with(key).and_return(object)
|
||||
allow(described_class).to receive(:default_settings).and_return(default_settings)
|
||||
|
@ -60,11 +60,11 @@ RSpec.describe Setting, type: :model do
|
|||
described_class[key]
|
||||
end
|
||||
|
||||
context 'RailsSettings::Settings.object returns truthy' do
|
||||
context 'when RailsSettings::Settings.object returns truthy' do
|
||||
let(:object) { db_val }
|
||||
let(:db_val) { double(value: 'db_val') }
|
||||
|
||||
context 'default_value is a Hash' do
|
||||
context 'when default_value is a Hash' do
|
||||
let(:default_value) { { default_value: 'default_value' } }
|
||||
|
||||
it 'calls default_value.with_indifferent_access.merge!' do
|
||||
|
@ -75,7 +75,7 @@ RSpec.describe Setting, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'default_value is not a Hash' do
|
||||
context 'when default_value is not a Hash' do
|
||||
let(:default_value) { 'default_value' }
|
||||
|
||||
it 'returns db_val.value' do
|
||||
|
@ -84,7 +84,7 @@ RSpec.describe Setting, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'RailsSettings::Settings.object returns falsey' do
|
||||
context 'when RailsSettings::Settings.object returns falsey' do
|
||||
let(:object) { nil }
|
||||
|
||||
it 'returns default_settings[key]' do
|
||||
|
@ -93,7 +93,7 @@ RSpec.describe Setting, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Rails.cache exists' do
|
||||
context 'when Rails.cache exists' do
|
||||
before do
|
||||
Rails.cache.write(cache_key, cache_value)
|
||||
end
|
||||
|
@ -130,7 +130,7 @@ RSpec.describe Setting, type: :model do
|
|||
expect(described_class.all_as_records).to be_a Hash
|
||||
end
|
||||
|
||||
context 'records includes Setting with var as the key' do
|
||||
context 'when records includes Setting with var as the key' do
|
||||
let(:records) { [original_setting] }
|
||||
|
||||
it 'includes the original Setting' do
|
||||
|
@ -139,10 +139,10 @@ RSpec.describe Setting, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'records includes nothing' do
|
||||
context 'when records includes nothing' do
|
||||
let(:records) { [] }
|
||||
|
||||
context 'default_value is not a Hash' do
|
||||
context 'when default_value is not a Hash' do
|
||||
it 'includes Setting with value of default_value' do
|
||||
setting = described_class.all_as_records[key]
|
||||
|
||||
|
@ -152,7 +152,7 @@ RSpec.describe Setting, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'default_value is a Hash' do
|
||||
context 'when default_value is a Hash' do
|
||||
let(:default_value) { { 'foo' => 'fuga' } }
|
||||
|
||||
it 'returns {}' do
|
||||
|
@ -169,7 +169,7 @@ RSpec.describe Setting, type: :model do
|
|||
allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled)
|
||||
end
|
||||
|
||||
context 'RailsSettings::Default.enabled? is false' do
|
||||
context 'when RailsSettings::Default.enabled? is false' do
|
||||
let(:enabled) { false }
|
||||
|
||||
it 'returns {}' do
|
||||
|
@ -177,7 +177,7 @@ RSpec.describe Setting, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'RailsSettings::Settings.enabled? is true' do
|
||||
context 'when RailsSettings::Settings.enabled? is true' do
|
||||
let(:enabled) { true }
|
||||
|
||||
it 'returns instance of RailsSettings::Default' do
|
||||
|
|
|
@ -49,22 +49,22 @@ RSpec.describe Status, type: :model do
|
|||
end
|
||||
|
||||
describe '#verb' do
|
||||
context 'if destroyed?' do
|
||||
context 'when destroyed?' do
|
||||
it 'returns :delete' do
|
||||
subject.destroy!
|
||||
expect(subject.verb).to be :delete
|
||||
end
|
||||
end
|
||||
|
||||
context 'unless destroyed?' do
|
||||
context 'if reblog?' do
|
||||
context 'when not destroyed?' do
|
||||
context 'when reblog?' do
|
||||
it 'returns :share' do
|
||||
subject.reblog = other
|
||||
expect(subject.verb).to be :share
|
||||
end
|
||||
end
|
||||
|
||||
context 'unless reblog?' do
|
||||
context 'when not reblog?' do
|
||||
it 'returns :post' do
|
||||
subject.reblog = nil
|
||||
expect(subject.verb).to be :post
|
||||
|
@ -85,28 +85,28 @@ RSpec.describe Status, type: :model do
|
|||
end
|
||||
|
||||
describe '#hidden?' do
|
||||
context 'if private_visibility?' do
|
||||
context 'when private_visibility?' do
|
||||
it 'returns true' do
|
||||
subject.visibility = :private
|
||||
expect(subject.hidden?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'if direct_visibility?' do
|
||||
context 'when direct_visibility?' do
|
||||
it 'returns true' do
|
||||
subject.visibility = :direct
|
||||
expect(subject.hidden?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'if public_visibility?' do
|
||||
context 'when public_visibility?' do
|
||||
it 'returns false' do
|
||||
subject.visibility = :public
|
||||
expect(subject.hidden?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'if unlisted_visibility?' do
|
||||
context 'when unlisted_visibility?' do
|
||||
it 'returns false' do
|
||||
subject.visibility = :unlisted
|
||||
expect(subject.hidden?).to be false
|
||||
|
|
|
@ -56,7 +56,7 @@ RSpec.describe Web::PushSubscription, type: :model do
|
|||
context 'when policy is followed' do
|
||||
let(:policy) { 'followed' }
|
||||
|
||||
context 'and notification is from someone you follow' do
|
||||
context 'when notification is from someone you follow' do
|
||||
before do
|
||||
account.follow!(notification.from_account)
|
||||
end
|
||||
|
@ -66,7 +66,7 @@ RSpec.describe Web::PushSubscription, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'and notification is not from someone you follow' do
|
||||
context 'when notification is not from someone you follow' do
|
||||
it 'returns false' do
|
||||
expect(subject.pushable?(notification)).to be false
|
||||
end
|
||||
|
@ -76,7 +76,7 @@ RSpec.describe Web::PushSubscription, type: :model do
|
|||
context 'when policy is follower' do
|
||||
let(:policy) { 'follower' }
|
||||
|
||||
context 'and notification is from someone who follows you' do
|
||||
context 'when notification is from someone who follows you' do
|
||||
before do
|
||||
notification.from_account.follow!(account)
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ RSpec.describe Web::PushSubscription, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'and notification is not from someone who follows you' do
|
||||
context 'when notification is not from someone who follows you' do
|
||||
it 'returns false' do
|
||||
expect(subject.pushable?(notification)).to be false
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe AccountModerationNotePolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :create? do
|
||||
context 'staff' do
|
||||
context 'when staff' do
|
||||
it 'grants to create' do
|
||||
expect(subject).to permit(admin, AccountModerationNotePolicy)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not staff' do
|
||||
context 'when not staff' do
|
||||
it 'denies to create' do
|
||||
expect(subject).to_not permit(john, AccountModerationNotePolicy)
|
||||
end
|
||||
|
@ -29,19 +29,19 @@ RSpec.describe AccountModerationNotePolicy do
|
|||
target_account: Fabricate(:account))
|
||||
end
|
||||
|
||||
context 'admin' do
|
||||
context 'when admin' do
|
||||
it 'grants to destroy' do
|
||||
expect(subject).to permit(admin, account_moderation_note)
|
||||
end
|
||||
end
|
||||
|
||||
context 'owner' do
|
||||
context 'when owner' do
|
||||
it 'grants to destroy' do
|
||||
expect(subject).to permit(john, account_moderation_note)
|
||||
end
|
||||
end
|
||||
|
||||
context 'neither admin nor owner' do
|
||||
context 'when neither admin nor owner' do
|
||||
let(:kevin) { Fabricate(:account) }
|
||||
|
||||
it 'denies to destroy' do
|
||||
|
|
|
@ -10,13 +10,13 @@ RSpec.describe AccountPolicy do
|
|||
let(:alice) { Fabricate(:account) }
|
||||
|
||||
permissions :index? do
|
||||
context 'staff' do
|
||||
context 'when staff' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not staff' do
|
||||
context 'when not staff' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john)
|
||||
end
|
||||
|
@ -24,13 +24,13 @@ RSpec.describe AccountPolicy do
|
|||
end
|
||||
|
||||
permissions :show?, :unsilence?, :unsensitive?, :remove_avatar?, :remove_header? do
|
||||
context 'staff' do
|
||||
context 'when staff' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, alice)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not staff' do
|
||||
context 'when not staff' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, alice)
|
||||
end
|
||||
|
@ -42,13 +42,13 @@ RSpec.describe AccountPolicy do
|
|||
alice.suspend!
|
||||
end
|
||||
|
||||
context 'staff' do
|
||||
context 'when staff' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, alice)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not staff' do
|
||||
context 'when not staff' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, alice)
|
||||
end
|
||||
|
@ -56,13 +56,13 @@ RSpec.describe AccountPolicy do
|
|||
end
|
||||
|
||||
permissions :redownload? do
|
||||
context 'admin' do
|
||||
context 'when admin' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin' do
|
||||
context 'when not admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john)
|
||||
end
|
||||
|
@ -72,21 +72,21 @@ RSpec.describe AccountPolicy do
|
|||
permissions :suspend?, :silence? do
|
||||
let(:staff) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
|
||||
context 'staff' do
|
||||
context 'record is staff' do
|
||||
context 'when staff' do
|
||||
context 'when record is staff' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(admin, staff)
|
||||
end
|
||||
end
|
||||
|
||||
context 'record is not staff' do
|
||||
context 'when record is not staff' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, john)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'not staff' do
|
||||
context 'when not staff' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Account)
|
||||
end
|
||||
|
@ -96,21 +96,21 @@ RSpec.describe AccountPolicy do
|
|||
permissions :memorialize? do
|
||||
let(:other_admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
|
||||
context 'admin' do
|
||||
context 'record is admin' do
|
||||
context 'when admin' do
|
||||
context 'when record is admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(admin, other_admin)
|
||||
end
|
||||
end
|
||||
|
||||
context 'record is not admin' do
|
||||
context 'when record is not admin' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, john)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin' do
|
||||
context 'when not admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Account)
|
||||
end
|
||||
|
@ -118,13 +118,13 @@ RSpec.describe AccountPolicy do
|
|||
end
|
||||
|
||||
permissions :review? do
|
||||
context 'admin' do
|
||||
context 'when admin' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin' do
|
||||
context 'when not admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john)
|
||||
end
|
||||
|
@ -132,7 +132,7 @@ RSpec.describe AccountPolicy do
|
|||
end
|
||||
|
||||
permissions :destroy? do
|
||||
context 'admin' do
|
||||
context 'when admin' do
|
||||
context 'with a temporarily suspended account' do
|
||||
before { allow(alice).to receive(:suspended_temporarily?).and_return(true) }
|
||||
|
||||
|
@ -150,7 +150,7 @@ RSpec.describe AccountPolicy do
|
|||
end
|
||||
end
|
||||
|
||||
context 'not admin' do
|
||||
context 'when not admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, alice)
|
||||
end
|
||||
|
|
|
@ -8,20 +8,20 @@ RSpec.describe BackupPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :create? do
|
||||
context 'not user_signed_in?' do
|
||||
context 'when not user_signed_in?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(nil, Backup)
|
||||
end
|
||||
end
|
||||
|
||||
context 'user_signed_in?' do
|
||||
context 'no backups' do
|
||||
context 'when user_signed_in?' do
|
||||
context 'with no backups' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(john, Backup)
|
||||
end
|
||||
end
|
||||
|
||||
context 'backups are too old' do
|
||||
context 'when backups are too old' do
|
||||
it 'permits' do
|
||||
travel(-8.days) do
|
||||
Fabricate(:backup, user: john.user)
|
||||
|
@ -31,7 +31,7 @@ RSpec.describe BackupPolicy do
|
|||
end
|
||||
end
|
||||
|
||||
context 'backups are newer' do
|
||||
context 'when backups are newer' do
|
||||
it 'denies' do
|
||||
travel(-3.days) do
|
||||
Fabricate(:backup, user: john.user)
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe CustomEmojiPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :index?, :enable?, :disable? do
|
||||
context 'staff' do
|
||||
context 'when staff' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, CustomEmoji)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not staff' do
|
||||
context 'when not staff' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, CustomEmoji)
|
||||
end
|
||||
|
@ -23,13 +23,13 @@ RSpec.describe CustomEmojiPolicy do
|
|||
end
|
||||
|
||||
permissions :create?, :update?, :copy?, :destroy? do
|
||||
context 'admin' do
|
||||
context 'when admin' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, CustomEmoji)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin' do
|
||||
context 'when not admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, CustomEmoji)
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe DomainBlockPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :index?, :show?, :create?, :destroy? do
|
||||
context 'admin' do
|
||||
context 'when admin' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, DomainBlock)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin' do
|
||||
context 'when not admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, DomainBlock)
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe EmailDomainBlockPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :index?, :show?, :create?, :destroy? do
|
||||
context 'admin' do
|
||||
context 'when admin' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, EmailDomainBlock)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin' do
|
||||
context 'when not admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, EmailDomainBlock)
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe InstancePolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :index?, :show?, :destroy? do
|
||||
context 'admin' do
|
||||
context 'when admin' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, Instance)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin' do
|
||||
context 'when not admin' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Instance)
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ RSpec.describe InvitePolicy do
|
|||
let(:john) { Fabricate(:user).account }
|
||||
|
||||
permissions :index? do
|
||||
context 'staff?' do
|
||||
context 'when staff?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, Invite)
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ RSpec.describe InvitePolicy do
|
|||
end
|
||||
|
||||
permissions :create? do
|
||||
context 'has privilege' do
|
||||
context 'with privilege' do
|
||||
before do
|
||||
UserRole.everyone.update(permissions: UserRole::FLAGS[:invite_users])
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ RSpec.describe InvitePolicy do
|
|||
end
|
||||
end
|
||||
|
||||
context 'does not have privilege' do
|
||||
context 'when does not have privilege' do
|
||||
before do
|
||||
UserRole.everyone.update(permissions: UserRole::Flags::NONE)
|
||||
end
|
||||
|
@ -39,13 +39,13 @@ RSpec.describe InvitePolicy do
|
|||
end
|
||||
|
||||
permissions :deactivate_all? do
|
||||
context 'admin?' do
|
||||
context 'when admin?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, Invite)
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin?' do
|
||||
context 'when not admin?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Invite)
|
||||
end
|
||||
|
@ -53,20 +53,20 @@ RSpec.describe InvitePolicy do
|
|||
end
|
||||
|
||||
permissions :destroy? do
|
||||
context 'owner?' do
|
||||
context 'when owner?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(john, Fabricate(:invite, user: john.user))
|
||||
end
|
||||
end
|
||||
|
||||
context 'not owner?' do
|
||||
context 'admin?' do
|
||||
context 'when not owner?' do
|
||||
context 'when admin?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, Fabricate(:invite))
|
||||
end
|
||||
end
|
||||
|
||||
context 'not admin?' do
|
||||
context 'when not admin?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Fabricate(:invite))
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe RelayPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :update? do
|
||||
context 'admin?' do
|
||||
context 'when admin?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, Relay)
|
||||
end
|
||||
end
|
||||
|
||||
context '!admin?' do
|
||||
context 'with !admin?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Relay)
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe ReportNotePolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :create? do
|
||||
context 'staff?' do
|
||||
context 'when staff?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, ReportNote)
|
||||
end
|
||||
end
|
||||
|
||||
context '!staff?' do
|
||||
context 'with !staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, ReportNote)
|
||||
end
|
||||
|
@ -23,22 +23,22 @@ RSpec.describe ReportNotePolicy do
|
|||
end
|
||||
|
||||
permissions :destroy? do
|
||||
context 'admin?' do
|
||||
context 'when admin?' do
|
||||
it 'permit' do
|
||||
report_note = Fabricate(:report_note, account: john)
|
||||
expect(subject).to permit(admin, report_note)
|
||||
end
|
||||
end
|
||||
|
||||
context 'admin?' do
|
||||
context 'owner?' do
|
||||
context 'when admin?' do
|
||||
context 'when owner?' do
|
||||
it 'permit' do
|
||||
report_note = Fabricate(:report_note, account: john)
|
||||
expect(subject).to permit(john, report_note)
|
||||
end
|
||||
end
|
||||
|
||||
context '!owner?' do
|
||||
context 'with !owner?' do
|
||||
it 'denies' do
|
||||
report_note = Fabricate(:report_note)
|
||||
expect(subject).to_not permit(john, report_note)
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe ReportPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :update?, :index?, :show? do
|
||||
context 'staff?' do
|
||||
context 'when staff?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, Report)
|
||||
end
|
||||
end
|
||||
|
||||
context '!staff?' do
|
||||
context 'with !staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Report)
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe SettingsPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :update?, :show?, :destroy? do
|
||||
context 'admin?' do
|
||||
context 'when admin?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, Settings)
|
||||
end
|
||||
end
|
||||
|
||||
context '!admin?' do
|
||||
context 'with !admin?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Settings)
|
||||
end
|
||||
|
|
|
@ -9,13 +9,13 @@ RSpec.describe TagPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :index?, :show?, :update?, :review? do
|
||||
context 'staff?' do
|
||||
context 'when staff?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, Tag)
|
||||
end
|
||||
end
|
||||
|
||||
context '!staff?' do
|
||||
context 'with !staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, Tag)
|
||||
end
|
||||
|
|
|
@ -9,21 +9,21 @@ RSpec.describe UserPolicy do
|
|||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :reset_password?, :change_email? do
|
||||
context 'staff?' do
|
||||
context '!record.staff?' do
|
||||
context 'when staff?' do
|
||||
context 'with !record.staff?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, john.user)
|
||||
end
|
||||
end
|
||||
|
||||
context 'record.staff?' do
|
||||
context 'when record.staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(admin, admin.user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context '!staff?' do
|
||||
context 'with !staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, User)
|
||||
end
|
||||
|
@ -31,21 +31,21 @@ RSpec.describe UserPolicy do
|
|||
end
|
||||
|
||||
permissions :disable_2fa? do
|
||||
context 'admin?' do
|
||||
context '!record.staff?' do
|
||||
context 'when admin?' do
|
||||
context 'with !record.staff?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, john.user)
|
||||
end
|
||||
end
|
||||
|
||||
context 'record.staff?' do
|
||||
context 'when record.staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(admin, admin.user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context '!admin?' do
|
||||
context 'with !admin?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, User)
|
||||
end
|
||||
|
@ -53,15 +53,15 @@ RSpec.describe UserPolicy do
|
|||
end
|
||||
|
||||
permissions :confirm? do
|
||||
context 'staff?' do
|
||||
context '!record.confirmed?' do
|
||||
context 'when staff?' do
|
||||
context 'with !record.confirmed?' do
|
||||
it 'permits' do
|
||||
john.user.update(confirmed_at: nil)
|
||||
expect(subject).to permit(admin, john.user)
|
||||
end
|
||||
end
|
||||
|
||||
context 'record.confirmed?' do
|
||||
context 'when record.confirmed?' do
|
||||
it 'denies' do
|
||||
john.user.confirm!
|
||||
expect(subject).to_not permit(admin, john.user)
|
||||
|
@ -69,7 +69,7 @@ RSpec.describe UserPolicy do
|
|||
end
|
||||
end
|
||||
|
||||
context '!staff?' do
|
||||
context 'with !staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, User)
|
||||
end
|
||||
|
@ -77,13 +77,13 @@ RSpec.describe UserPolicy do
|
|||
end
|
||||
|
||||
permissions :enable? do
|
||||
context 'staff?' do
|
||||
context 'when staff?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, User)
|
||||
end
|
||||
end
|
||||
|
||||
context '!staff?' do
|
||||
context 'with !staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, User)
|
||||
end
|
||||
|
@ -91,21 +91,21 @@ RSpec.describe UserPolicy do
|
|||
end
|
||||
|
||||
permissions :disable? do
|
||||
context 'staff?' do
|
||||
context '!record.admin?' do
|
||||
context 'when staff?' do
|
||||
context 'with !record.admin?' do
|
||||
it 'permits' do
|
||||
expect(subject).to permit(admin, john.user)
|
||||
end
|
||||
end
|
||||
|
||||
context 'record.admin?' do
|
||||
context 'when record.admin?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(admin, admin.user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context '!staff?' do
|
||||
context 'with !staff?' do
|
||||
it 'denies' do
|
||||
expect(subject).to_not permit(john, User)
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
|||
let(:account_ids) { [Fabricate(:account).id] }
|
||||
let(:default_map) { { 1 => true } }
|
||||
|
||||
context 'options are not set' do
|
||||
context 'when options are not set' do
|
||||
let(:options) { {} }
|
||||
|
||||
it 'sets default maps' do
|
||||
|
@ -32,7 +32,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:following_map] is set' do
|
||||
context 'when options[:following_map] is set' do
|
||||
let(:options) { { following_map: { 2 => true } } }
|
||||
|
||||
it 'sets @following merged with default_map and options[:following_map]' do
|
||||
|
@ -40,7 +40,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:followed_by_map] is set' do
|
||||
context 'when options[:followed_by_map] is set' do
|
||||
let(:options) { { followed_by_map: { 3 => true } } }
|
||||
|
||||
it 'sets @followed_by merged with default_map and options[:followed_by_map]' do
|
||||
|
@ -48,7 +48,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:blocking_map] is set' do
|
||||
context 'when options[:blocking_map] is set' do
|
||||
let(:options) { { blocking_map: { 4 => true } } }
|
||||
|
||||
it 'sets @blocking merged with default_map and options[:blocking_map]' do
|
||||
|
@ -56,7 +56,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:muting_map] is set' do
|
||||
context 'when options[:muting_map] is set' do
|
||||
let(:options) { { muting_map: { 5 => true } } }
|
||||
|
||||
it 'sets @muting merged with default_map and options[:muting_map]' do
|
||||
|
@ -64,7 +64,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:requested_map] is set' do
|
||||
context 'when options[:requested_map] is set' do
|
||||
let(:options) { { requested_map: { 6 => true } } }
|
||||
|
||||
it 'sets @requested merged with default_map and options[:requested_map]' do
|
||||
|
@ -72,7 +72,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:requested_by_map] is set' do
|
||||
context 'when options[:requested_by_map] is set' do
|
||||
let(:options) { { requested_by_map: { 6 => true } } }
|
||||
|
||||
it 'sets @requested merged with default_map and options[:requested_by_map]' do
|
||||
|
@ -80,7 +80,7 @@ RSpec.describe AccountRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:domain_blocking_map] is set' do
|
||||
context 'when options[:domain_blocking_map] is set' do
|
||||
let(:options) { { domain_blocking_map: { 7 => true } } }
|
||||
|
||||
it 'sets @domain_blocking merged with default_map and options[:domain_blocking_map]' do
|
||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe StatusRelationshipsPresenter do
|
|||
let(:status_ids) { statuses.map(&:id) + statuses.map(&:reblog_of_id).compact }
|
||||
let(:default_map) { { 1 => true } }
|
||||
|
||||
context 'options are not set' do
|
||||
context 'when options are not set' do
|
||||
let(:options) { {} }
|
||||
|
||||
it 'sets default maps' do
|
||||
|
@ -30,7 +30,7 @@ RSpec.describe StatusRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:reblogs_map] is set' do
|
||||
context 'when options[:reblogs_map] is set' do
|
||||
let(:options) { { reblogs_map: { 2 => true } } }
|
||||
|
||||
it 'sets @reblogs_map merged with default_map and options[:reblogs_map]' do
|
||||
|
@ -38,7 +38,7 @@ RSpec.describe StatusRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:favourites_map] is set' do
|
||||
context 'when options[:favourites_map] is set' do
|
||||
let(:options) { { favourites_map: { 3 => true } } }
|
||||
|
||||
it 'sets @favourites_map merged with default_map and options[:favourites_map]' do
|
||||
|
@ -46,7 +46,7 @@ RSpec.describe StatusRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:bookmarks_map] is set' do
|
||||
context 'when options[:bookmarks_map] is set' do
|
||||
let(:options) { { bookmarks_map: { 4 => true } } }
|
||||
|
||||
it 'sets @bookmarks_map merged with default_map and options[:bookmarks_map]' do
|
||||
|
@ -54,7 +54,7 @@ RSpec.describe StatusRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:mutes_map] is set' do
|
||||
context 'when options[:mutes_map] is set' do
|
||||
let(:options) { { mutes_map: { 5 => true } } }
|
||||
|
||||
it 'sets @mutes_map merged with default_map and options[:mutes_map]' do
|
||||
|
@ -62,7 +62,7 @@ RSpec.describe StatusRelationshipsPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'options[:pins_map] is set' do
|
||||
context 'when options[:pins_map] is set' do
|
||||
let(:options) { { pins_map: { 6 => true } } }
|
||||
|
||||
it 'sets @pins_map merged with default_map and options[:pins_map]' do
|
||||
|
|
|
@ -20,7 +20,7 @@ describe AccountSearchService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'searching for a simple term that is not an exact match' do
|
||||
context 'when searching for a simple term that is not an exact match' do
|
||||
it 'does not return a nil entry in the array for the exact match' do
|
||||
account = Fabricate(:account, username: 'matchingusername')
|
||||
results = subject.call('match', nil, limit: 5)
|
||||
|
|
|
@ -20,13 +20,13 @@ describe AccountStatusesCleanupService, type: :service do
|
|||
let!(:another_old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) }
|
||||
let!(:recent_status) { Fabricate(:status, created_at: 1.day.ago, account: account) }
|
||||
|
||||
context 'given a budget of 1' do
|
||||
context 'when given a budget of 1' do
|
||||
it 'reports 1 deleted toot' do
|
||||
expect(subject.call(account_policy, 1)).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
context 'given a normal budget of 10' do
|
||||
context 'when given a normal budget of 10' do
|
||||
it 'reports 3 deleted statuses' do
|
||||
expect(subject.call(account_policy, 10)).to eq 3
|
||||
end
|
||||
|
|
|
@ -226,12 +226,12 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'statuses referencing other statuses' do
|
||||
context 'with statuses referencing other statuses' do
|
||||
before do
|
||||
stub_const 'ActivityPub::FetchRemoteStatusService::DISCOVERIES_PER_REQUEST', 5
|
||||
end
|
||||
|
||||
context 'using inReplyTo' do
|
||||
context 'when using inReplyTo' do
|
||||
let(:object) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
|
@ -267,7 +267,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using replies' do
|
||||
context 'when using replies' do
|
||||
let(:object) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
|
|
|
@ -5,7 +5,7 @@ require 'rails_helper'
|
|||
RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
context 'property values' do
|
||||
context 'with property values' do
|
||||
let(:payload) do
|
||||
{
|
||||
id: 'https://foo.test',
|
||||
|
@ -82,7 +82,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
account.suspend!(origin: suspension_origin)
|
||||
end
|
||||
|
||||
context 'locally' do
|
||||
context 'when locally' do
|
||||
let(:suspension_origin) { :local }
|
||||
|
||||
it 'does not unsuspend it' do
|
||||
|
@ -94,7 +94,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'remotely' do
|
||||
context 'when remotely' do
|
||||
let(:suspension_origin) { :remote }
|
||||
|
||||
it 'unsuspends it' do
|
||||
|
@ -112,7 +112,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'discovering many subdomains in a short timeframe' do
|
||||
context 'when discovering many subdomains in a short timeframe' do
|
||||
before do
|
||||
stub_const 'ActivityPub::ProcessAccountService::SUBDOMAINS_RATELIMIT', 5
|
||||
end
|
||||
|
@ -138,7 +138,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'accounts referencing other accounts' do
|
||||
context 'when Accounts referencing other accounts' do
|
||||
before do
|
||||
stub_const 'ActivityPub::ProcessAccountService::DISCOVERIES_PER_REQUEST', 5
|
||||
end
|
||||
|
|
|
@ -269,7 +269,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'originally without tags' do
|
||||
context 'when originally without tags' do
|
||||
before do
|
||||
subject.call(status, json)
|
||||
end
|
||||
|
@ -279,7 +279,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'originally with tags' do
|
||||
context 'when originally with tags' do
|
||||
let(:tags) { [Fabricate(:tag, name: 'test'), Fabricate(:tag, name: 'foo')] }
|
||||
|
||||
let(:payload) do
|
||||
|
@ -305,7 +305,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'originally without mentions' do
|
||||
context 'when originally without mentions' do
|
||||
before do
|
||||
subject.call(status, json)
|
||||
end
|
||||
|
@ -315,7 +315,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'originally with mentions' do
|
||||
context 'when originally with mentions' do
|
||||
let(:mentions) { [alice, bob] }
|
||||
|
||||
before do
|
||||
|
@ -327,7 +327,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'originally without media attachments' do
|
||||
context 'when originally without media attachments' do
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/foo.png').to_return(body: attachment_fixture('emojo.png'))
|
||||
subject.call(status, json)
|
||||
|
@ -362,7 +362,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'originally with media attachments' do
|
||||
context 'when originally with media attachments' do
|
||||
let(:media_attachments) { [Fabricate(:media_attachment, remote_url: 'https://example.com/foo.png'), Fabricate(:media_attachment, remote_url: 'https://example.com/unused.png')] }
|
||||
|
||||
let(:payload) do
|
||||
|
@ -404,7 +404,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'originally with a poll' do
|
||||
context 'when originally with a poll' do
|
||||
before do
|
||||
poll = Fabricate(:poll, status: status)
|
||||
status.update(preloadable_poll: poll)
|
||||
|
@ -420,7 +420,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'originally without a poll' do
|
||||
context 'when originally without a poll' do
|
||||
let(:payload) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe FetchLinkCardService, type: :service do
|
|||
subject.call(status)
|
||||
end
|
||||
|
||||
context 'in a local status' do
|
||||
context 'with a local status' do
|
||||
context do
|
||||
let(:status) { Fabricate(:status, text: 'Check out http://example.中国') }
|
||||
|
||||
|
@ -89,7 +89,7 @@ RSpec.describe FetchLinkCardService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'in a remote status' do
|
||||
context 'with a remote status' do
|
||||
let(:status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com'), text: 'Habt ihr ein paar gute Links zu <a>foo</a> #<span class="tag"><a href="https://quitter.se/tag/wannacry" target="_blank" rel="tag noopener noreferrer" title="https://quitter.se/tag/wannacry">Wannacry</a></span> herumfliegen? Ich will mal unter <br> <a href="https://github.com/qbi/WannaCry" target="_blank" rel="noopener noreferrer" title="https://github.com/qbi/WannaCry">https://github.com/qbi/WannaCry</a> was sammeln. !<a href="http://sn.jonkman.ca/group/416/id" target="_blank" rel="noopener noreferrer" title="http://sn.jonkman.ca/group/416/id">security</a> ') }
|
||||
|
||||
it 'parses out URLs' do
|
||||
|
|
|
@ -39,7 +39,7 @@ describe FetchOEmbedService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Both of JSON and XML provider are discoverable' do
|
||||
context 'when both of JSON and XML provider are discoverable' do
|
||||
before do
|
||||
stub_request(:get, 'https://host.test/oembed.html').to_return(
|
||||
status: 200,
|
||||
|
@ -66,7 +66,7 @@ describe FetchOEmbedService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'JSON provider is discoverable while XML provider is not' do
|
||||
context 'when JSON provider is discoverable while XML provider is not' do
|
||||
before do
|
||||
stub_request(:get, 'https://host.test/oembed.html').to_return(
|
||||
status: 200,
|
||||
|
@ -87,7 +87,7 @@ describe FetchOEmbedService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'XML provider is discoverable while JSON provider is not' do
|
||||
context 'when XML provider is discoverable while JSON provider is not' do
|
||||
before do
|
||||
stub_request(:get, 'https://host.test/oembed.html').to_return(
|
||||
status: 200,
|
||||
|
@ -108,7 +108,7 @@ describe FetchOEmbedService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Invalid XML provider is discoverable while JSON provider is not' do
|
||||
context 'with Invalid XML provider is discoverable while JSON provider is not' do
|
||||
before do
|
||||
stub_request(:get, 'https://host.test/oembed.html').to_return(
|
||||
status: 200,
|
||||
|
@ -122,7 +122,7 @@ describe FetchOEmbedService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Neither of JSON and XML provider is discoverable' do
|
||||
context 'with neither of JSON and XML provider is discoverable' do
|
||||
before do
|
||||
stub_request(:get, 'https://host.test/oembed.html').to_return(
|
||||
status: 200,
|
||||
|
@ -136,7 +136,7 @@ describe FetchOEmbedService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Empty JSON provider is discoverable' do
|
||||
context 'when empty JSON provider is discoverable' do
|
||||
before do
|
||||
stub_request(:get, 'https://host.test/oembed.html').to_return(
|
||||
status: 200,
|
||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe FetchRemoteStatusService, type: :service do
|
|||
}
|
||||
end
|
||||
|
||||
context 'protocol is :activitypub' do
|
||||
context 'when protocol is :activitypub' do
|
||||
subject { described_class.new.call(note[:id], prefetched_body: prefetched_body) }
|
||||
|
||||
let(:prefetched_body) { Oj.dump(note) }
|
||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe FollowService, type: :service do
|
|||
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
context 'local account' do
|
||||
context 'when local account' do
|
||||
describe 'locked account' do
|
||||
let(:bob) { Fabricate(:account, locked: true, username: 'bob') }
|
||||
|
||||
|
@ -138,7 +138,7 @@ RSpec.describe FollowService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'remote ActivityPub account' do
|
||||
context 'when remote ActivityPub account' do
|
||||
let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
|
||||
|
||||
before do
|
||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe ImportService, type: :service do
|
|||
stub_request(:post, 'https://example.com/inbox').to_return(status: 200)
|
||||
end
|
||||
|
||||
context 'import old-style list of muted users' do
|
||||
context 'when importing old-style list of muted users' do
|
||||
subject { ImportService.new }
|
||||
|
||||
let(:csv) { attachment_fixture('mute-imports.txt') }
|
||||
|
@ -51,7 +51,7 @@ RSpec.describe ImportService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'import new-style list of muted users' do
|
||||
context 'when importing new-style list of muted users' do
|
||||
subject { ImportService.new }
|
||||
|
||||
let(:csv) { attachment_fixture('new-mute-imports.txt') }
|
||||
|
@ -92,7 +92,7 @@ RSpec.describe ImportService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'import old-style list of followed users' do
|
||||
context 'when importing old-style list of followed users' do
|
||||
subject { ImportService.new }
|
||||
|
||||
let(:csv) { attachment_fixture('mute-imports.txt') }
|
||||
|
@ -134,7 +134,7 @@ RSpec.describe ImportService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'import new-style list of followed users' do
|
||||
context 'when importing new-style list of followed users' do
|
||||
subject { ImportService.new }
|
||||
|
||||
let(:csv) { attachment_fixture('new-following-imports.txt') }
|
||||
|
@ -181,7 +181,7 @@ RSpec.describe ImportService, type: :service do
|
|||
# Based on the bug report 20571 where UTF-8 encoded domains were rejecting import of their users
|
||||
#
|
||||
# https://github.com/mastodon/mastodon/issues/20571
|
||||
context 'utf-8 encoded domains' do
|
||||
context 'with a utf-8 encoded domains' do
|
||||
subject { ImportService.new }
|
||||
|
||||
let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') }
|
||||
|
@ -200,7 +200,7 @@ RSpec.describe ImportService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'import bookmarks' do
|
||||
context 'when importing bookmarks' do
|
||||
subject { ImportService.new }
|
||||
|
||||
let(:csv) { attachment_fixture('bookmark-imports.txt') }
|
||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
context 'for direct messages' do
|
||||
context 'with direct messages' do
|
||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct)) }
|
||||
let(:type) { :mention }
|
||||
|
||||
|
@ -58,14 +58,14 @@ RSpec.describe NotifyService, type: :service do
|
|||
user.save
|
||||
end
|
||||
|
||||
context 'if recipient is supposed to be following sender' do
|
||||
context 'when recipient is supposed to be following sender' do
|
||||
let(:enabled) { true }
|
||||
|
||||
it 'does not notify' do
|
||||
expect { subject }.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
context 'if the message chain is initiated by recipient, but is not direct message' do
|
||||
context 'when the message chain is initiated by recipient, but is not direct message' do
|
||||
let(:reply_to) { Fabricate(:status, account: recipient) }
|
||||
let!(:mention) { Fabricate(:mention, account: sender, status: reply_to) }
|
||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
|
||||
|
@ -75,7 +75,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'if the message chain is initiated by recipient, but without a mention to the sender, even if the sender sends multiple messages in a row' do
|
||||
context 'when the message chain is initiated by recipient, but without a mention to the sender, even if the sender sends multiple messages in a row' do
|
||||
let(:reply_to) { Fabricate(:status, account: recipient) }
|
||||
let!(:mention) { Fabricate(:mention, account: sender, status: reply_to) }
|
||||
let(:dummy_reply) { Fabricate(:status, account: sender, visibility: :direct, thread: reply_to) }
|
||||
|
@ -86,7 +86,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'if the message chain is initiated by the recipient with a mention to the sender' do
|
||||
context 'when the message chain is initiated by the recipient with a mention to the sender' do
|
||||
let(:reply_to) { Fabricate(:status, account: recipient, visibility: :direct) }
|
||||
let!(:mention) { Fabricate(:mention, account: sender, status: reply_to) }
|
||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
|
||||
|
@ -97,7 +97,7 @@ RSpec.describe NotifyService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'if recipient is NOT supposed to be following sender' do
|
||||
context 'when recipient is NOT supposed to be following sender' do
|
||||
let(:enabled) { false }
|
||||
|
||||
it 'does notify' do
|
||||
|
|
|
@ -33,10 +33,10 @@ RSpec.describe ProcessMentionsService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'resolving a mention to a remote account' do
|
||||
context 'with resolving a mention to a remote account' do
|
||||
let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}", visibility: :public) }
|
||||
|
||||
context 'ActivityPub' do
|
||||
context 'with ActivityPub' do
|
||||
context do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
|
||||
|
@ -49,7 +49,7 @@ RSpec.describe ProcessMentionsService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'mentioning a user several times when not saving records' do
|
||||
context 'when mentioning a user several times when not saving records' do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct} @#{remote_user.acct} @#{remote_user.acct}", visibility: :public) }
|
||||
|
||||
|
@ -89,7 +89,7 @@ RSpec.describe ProcessMentionsService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Temporarily-unreachable ActivityPub user' do
|
||||
context 'with a Temporarily-unreachable ActivityPub user' do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox', last_webfingered_at: nil) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -5,7 +5,7 @@ require 'rails_helper'
|
|||
RSpec.describe ReblogService, type: :service do
|
||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
context 'creates a reblog with appropriate visibility' do
|
||||
context 'when creates a reblog with appropriate visibility' do
|
||||
subject { ReblogService.new }
|
||||
|
||||
let(:visibility) { :public }
|
||||
|
@ -61,7 +61,7 @@ RSpec.describe ReblogService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'ActivityPub' do
|
||||
context 'with ActivityPub' do
|
||||
subject { ReblogService.new }
|
||||
|
||||
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe ReportService, type: :service do
|
|||
|
||||
let(:source_account) { Fabricate(:account) }
|
||||
|
||||
context 'for a remote account' do
|
||||
context 'with a remote account' do
|
||||
let(:remote_account) { Fabricate(:account, domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') }
|
||||
|
||||
before do
|
||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe ResolveAccountService, type: :service do
|
|||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:hoge@example.com').to_return(status: 410)
|
||||
end
|
||||
|
||||
context 'using skip_webfinger' do
|
||||
context 'when using skip_webfinger' do
|
||||
context 'when account is known' do
|
||||
let!(:remote_account) { Fabricate(:account, username: 'foo', domain: 'ap.example.com', protocol: 'activitypub') }
|
||||
|
||||
|
@ -78,7 +78,7 @@ RSpec.describe ResolveAccountService, type: :service do
|
|||
end
|
||||
|
||||
context 'when webfinger returns http gone' do
|
||||
context 'for a previously known account' do
|
||||
context 'with a previously known account' do
|
||||
before do
|
||||
Fabricate(:account, username: 'hoge', domain: 'example.com', last_webfingered_at: nil)
|
||||
allow(AccountDeletionWorker).to receive(:perform_async)
|
||||
|
@ -94,7 +94,7 @@ RSpec.describe ResolveAccountService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for a previously unknown account' do
|
||||
context 'with a previously unknown account' do
|
||||
it 'returns nil' do
|
||||
expect(subject.call('hoge@example.com')).to be_nil
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ describe ResolveURLService, type: :service do
|
|||
expect(subject.call(url)).to eq known_account
|
||||
end
|
||||
|
||||
context 'searching for a remote private status' do
|
||||
context 'when searching for a remote private status' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:poster) { Fabricate(:account, domain: 'example.com') }
|
||||
let(:url) { 'https://example.com/@foo/42' }
|
||||
|
@ -95,7 +95,7 @@ describe ResolveURLService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'searching for a local private status' do
|
||||
context 'when searching for a local private status' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:poster) { Fabricate(:account) }
|
||||
let!(:status) { Fabricate(:status, account: poster, visibility: :private) }
|
||||
|
@ -127,7 +127,7 @@ describe ResolveURLService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'searching for a link that redirects to a local public status' do
|
||||
context 'when searching for a link that redirects to a local public status' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:poster) { Fabricate(:account) }
|
||||
let!(:status) { Fabricate(:status, account: poster, visibility: :public) }
|
||||
|
|
|
@ -23,7 +23,7 @@ describe SearchService, type: :service do
|
|||
@query = 'http://test.host/query'
|
||||
end
|
||||
|
||||
context 'that does not find anything' do
|
||||
context 'when it does not find anything' do
|
||||
it 'returns the empty results' do
|
||||
service = double(call: nil)
|
||||
allow(ResolveURLService).to receive(:new).and_return(service)
|
||||
|
@ -34,7 +34,7 @@ describe SearchService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that finds an account' do
|
||||
context 'when it finds an account' do
|
||||
it 'includes the account in the results' do
|
||||
account = Account.new
|
||||
service = double(call: account)
|
||||
|
@ -46,7 +46,7 @@ describe SearchService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that finds a status' do
|
||||
context 'when it finds a status' do
|
||||
it 'includes the status in the results' do
|
||||
status = Status.new
|
||||
service = double(call: status)
|
||||
|
@ -60,7 +60,7 @@ describe SearchService, type: :service do
|
|||
end
|
||||
|
||||
describe 'with a non-url query' do
|
||||
context 'that matches an account' do
|
||||
context 'when it matches an account' do
|
||||
it 'includes the account in the results' do
|
||||
query = 'username'
|
||||
account = Account.new
|
||||
|
@ -73,7 +73,7 @@ describe SearchService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'that matches a tag' do
|
||||
context 'when it matches a tag' do
|
||||
it 'includes the tag in the results' do
|
||||
query = '#tag'
|
||||
tag = Tag.new
|
||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe UnallowDomainService, type: :service do
|
|||
let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) }
|
||||
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') }
|
||||
|
||||
context 'in limited federation mode' do
|
||||
context 'with limited federation mode' do
|
||||
before do
|
||||
allow(subject).to receive(:whitelist_mode?).and_return(true)
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ require 'rails_helper'
|
|||
RSpec.describe VerifyLinkService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
context 'given a local account' do
|
||||
context 'when given a local account' do
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
let(:field) { Account::Field.new(account, 'name' => 'Website', 'value' => 'http://example.com') }
|
||||
|
||||
|
@ -129,7 +129,7 @@ RSpec.describe VerifyLinkService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context 'given a remote account' do
|
||||
context 'when given a remote account' do
|
||||
let(:account) { Fabricate(:account, username: 'alice', domain: 'example.com', url: 'https://profile.example.com/alice') }
|
||||
let(:field) { Account::Field.new(account, 'name' => 'Website', 'value' => '<a href="http://example.com" rel="me"><span class="invisible">http://</span><span class="">example.com</span><span class="invisible"></span></a>') }
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do
|
|||
let(:status) { double(errors: errors, local?: local, reblog?: reblog, text: disallowed_tags.map { |x| "##{x}" }.join(' ')) }
|
||||
let(:errors) { double(add: nil) }
|
||||
|
||||
context 'for a remote reblog' do
|
||||
context 'with a remote reblog' do
|
||||
let(:local) { false }
|
||||
let(:reblog) { true }
|
||||
|
||||
|
@ -23,7 +23,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do
|
|||
end
|
||||
end
|
||||
|
||||
context 'for a local original status' do
|
||||
context 'with a local original status' do
|
||||
let(:local) { true }
|
||||
let(:reblog) { false }
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ describe EmailMxValidator do
|
|||
describe '#validate' do
|
||||
let(:user) { double(email: 'foo@example.com', sign_up_ip: '1.2.3.4', errors: double(add: nil)) }
|
||||
|
||||
context 'for an e-mail domain that is explicitly allowed' do
|
||||
context 'with an e-mail domain that is explicitly allowed' do
|
||||
around do |block|
|
||||
tmp = Rails.configuration.x.email_domains_whitelist
|
||||
Rails.configuration.x.email_domains_whitelist = 'example.com'
|
||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe FollowLimitValidator, type: :validator do
|
|||
let(:_nil) { true }
|
||||
let(:local) { false }
|
||||
|
||||
context 'follow.account.nil? || !follow.account.local?' do
|
||||
context 'with follow.account.nil? || !follow.account.local?' do
|
||||
let(:_nil) { true }
|
||||
|
||||
it 'not calls errors.add' do
|
||||
|
@ -26,11 +26,11 @@ RSpec.describe FollowLimitValidator, type: :validator do
|
|||
end
|
||||
end
|
||||
|
||||
context '!(follow.account.nil? || !follow.account.local?)' do
|
||||
context 'with !(follow.account.nil? || !follow.account.local?)' do
|
||||
let(:_nil) { false }
|
||||
let(:local) { true }
|
||||
|
||||
context 'limit_reached?' do
|
||||
context 'when limit_reached?' do
|
||||
let(:limit_reached) { true }
|
||||
|
||||
it 'calls errors.add' do
|
||||
|
@ -39,7 +39,7 @@ RSpec.describe FollowLimitValidator, type: :validator do
|
|||
end
|
||||
end
|
||||
|
||||
context '!limit_reached?' do
|
||||
context 'with !limit_reached?' do
|
||||
let(:limit_reached) { false }
|
||||
|
||||
it 'not calls errors.add' do
|
||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe PollValidator, type: :validator do
|
|||
expect(errors).to_not have_received(:add)
|
||||
end
|
||||
|
||||
context 'expires just 5 min ago' do
|
||||
context 'when expires is just 5 min ago' do
|
||||
let(:expires_at) { 5.minutes.from_now }
|
||||
|
||||
it 'not calls errors add' do
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue